Browse Source

Add org.gradle.toolchains.foojay-resolver-convention to the examples (#3666)

According to https://developer.android.com/build/jdks we should:

1. [use JDK 17 for API 34](https://developer.android.com/build/jdks#compileSdk)
2. [use toolchain](https://developer.android.com/build/jdks#toolchain):
```
We recommend that you always specify the Java toolchain, and either ensure that the specified JDK is installed, or add a toolchain resolver to your build.
```

As we don't want to force people to have JDK 17 on their machine, we apply toolchain resolver that is recommended by Gradle:
```
id("org.gradle.toolchains.foojay-resolver-convention") version("0.4.0")
```

## Test
1. Remove JDK 17 from the computer, remove `jvmToolchain(17)`
2. Run `./gradlew assembleDebug`
3. It should fail with:
```
> Could not create task ':androidApp:compileDebugJavaWithJavac'.
   > Failed to calculate the value of task ':androidApp:compileDebugJavaWithJavac' property 'javaCompiler'.
      > No matching toolchains found for requested specification: {languageVersion=17, vendor=any, implementation=vendor-specific} for WINDOWS on x86_64.
         > No locally installed toolchains match and toolchain download repositories have not been configured.
```
4. restore `jvmToolchain(17)`
5. Run `./gradlew assembleDebug` again
6. It should succeed

## Issues
Fixes https://github.com/JetBrains/compose-multiplatform/issues/3615
pull/3669/head
Igor Demin 1 year ago committed by GitHub
parent
commit
021b099e1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      ci/templates/multiplatform-template/android/build.gradle.kts
  2. 12
      ci/templates/multiplatform-template/common/build.gradle.kts
  3. 2
      ci/templates/multiplatform-template/gradle.properties
  4. 4
      ci/templates/multiplatform-template/settings.gradle.kts
  5. 6
      examples/chat/androidApp/build.gradle.kts
  6. 4
      examples/chat/settings.gradle.kts
  7. 6
      examples/chat/shared/build.gradle.kts
  8. 6
      examples/cocoapods-ios-example/androidApp/build.gradle.kts
  9. 4
      examples/cocoapods-ios-example/settings.gradle.kts
  10. 6
      examples/cocoapods-ios-example/shared/build.gradle.kts
  11. 6
      examples/codeviewer/androidApp/build.gradle.kts
  12. 4
      examples/codeviewer/settings.gradle.kts
  13. 6
      examples/codeviewer/shared/build.gradle.kts
  14. 6
      examples/falling-balls/androidApp/build.gradle.kts
  15. 4
      examples/falling-balls/settings.gradle.kts
  16. 6
      examples/falling-balls/shared/build.gradle.kts
  17. 6
      examples/imageviewer/androidApp/build.gradle.kts
  18. 4
      examples/imageviewer/settings.gradle.kts
  19. 6
      examples/imageviewer/shared/build.gradle.kts
  20. 6
      examples/issues/android/build.gradle.kts
  21. 6
      examples/issues/common/build.gradle.kts
  22. 4
      examples/issues/settings.gradle.kts
  23. 6
      examples/minesweeper/androidApp/build.gradle.kts
  24. 4
      examples/minesweeper/settings.gradle.kts
  25. 6
      examples/minesweeper/shared/build.gradle.kts
  26. 6
      examples/todoapp-lite/androidApp/build.gradle.kts
  27. 4
      examples/todoapp-lite/settings.gradle.kts
  28. 6
      examples/todoapp-lite/shared/build.gradle.kts
  29. 6
      examples/visual-effects/androidApp/build.gradle.kts
  30. 4
      examples/visual-effects/settings.gradle.kts
  31. 6
      examples/visual-effects/shared/build.gradle.kts
  32. 6
      examples/widgets-gallery/androidApp/build.gradle.kts
  33. 4
      examples/widgets-gallery/settings.gradle.kts
  34. 6
      examples/widgets-gallery/shared/build.gradle.kts

11
ci/templates/multiplatform-template/android/build.gradle.kts

@ -5,18 +5,21 @@ plugins {
} }
android { android {
compileSdk = 33 compileSdk = 34
defaultConfig { defaultConfig {
minSdk = 26 minSdk = 26
targetSdk = 33 targetSdk = 34
versionCode = 1 versionCode = 1
versionName = "1.0" versionName = "1.0"
} }
compileOptions { compileOptions {
sourceCompatibility = JavaVersion.VERSION_11 sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_17
}
kotlin {
jvmToolchain(17)
} }
} }

12
ci/templates/multiplatform-template/common/build.gradle.kts

@ -28,18 +28,18 @@ kotlin {
} }
android { android {
compileSdk = 33 compileSdk = 34
defaultConfig { defaultConfig {
minSdk = 26 minSdk = 26
targetSdk = 33
} }
compileOptions { compileOptions {
sourceCompatibility = JavaVersion.VERSION_11 sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_17
}
kotlin {
jvmToolchain(17)
} }
sourceSets { sourceSets {
named("main") { named("main") {
manifest.srcFile("src/androidMain/AndroidManifest.xml") manifest.srcFile("src/androidMain/AndroidManifest.xml")

2
ci/templates/multiplatform-template/gradle.properties

@ -3,5 +3,5 @@ android.useAndroidX=true
android.enableJetifier=true android.enableJetifier=true
kotlin.code.style=official kotlin.code.style=official
kotlin.version=1.9.10 kotlin.version=1.9.10
agp.version=7.1.3 agp.version=8.0.2
compose.version=1.5.1 compose.version=1.5.1

4
ci/templates/multiplatform-template/settings.gradle.kts

@ -15,4 +15,8 @@ pluginManagement {
} }
} }
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version("0.4.0")
}
include(":common", ":android", ":desktop") include(":common", ":android", ":desktop")

6
examples/chat/androidApp/build.gradle.kts

@ -26,10 +26,10 @@ android {
versionName = "1.0" versionName = "1.0"
} }
compileOptions { compileOptions {
sourceCompatibility = JavaVersion.VERSION_11 sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_17
} }
kotlin { kotlin {
jvmToolchain(11) jvmToolchain(17)
} }
} }

4
examples/chat/settings.gradle.kts

@ -20,6 +20,10 @@ pluginManagement {
} }
} }
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version("0.4.0")
}
rootProject.name = "chat-mpp" rootProject.name = "chat-mpp"
include(":androidApp") include(":androidApp")

6
examples/chat/shared/build.gradle.kts

@ -103,10 +103,10 @@ android {
minSdk = 26 minSdk = 26
} }
compileOptions { compileOptions {
sourceCompatibility = JavaVersion.VERSION_11 sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_17
} }
kotlin { kotlin {
jvmToolchain(11) jvmToolchain(17)
} }
} }

6
examples/cocoapods-ios-example/androidApp/build.gradle.kts

@ -29,10 +29,10 @@ android {
versionName = "1.0" versionName = "1.0"
} }
compileOptions { compileOptions {
sourceCompatibility = JavaVersion.VERSION_11 sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_17
} }
kotlin { kotlin {
jvmToolchain(11) jvmToolchain(17)
} }
} }

4
examples/cocoapods-ios-example/settings.gradle.kts

@ -26,6 +26,10 @@ pluginManagement {
} }
} }
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version("0.4.0")
}
dependencyResolutionManagement { dependencyResolutionManagement {
repositories { repositories {
google() google()

6
examples/cocoapods-ios-example/shared/build.gradle.kts

@ -58,10 +58,10 @@ android {
minSdk = (findProperty("android.minSdk") as String).toInt() minSdk = (findProperty("android.minSdk") as String).toInt()
} }
compileOptions { compileOptions {
sourceCompatibility = JavaVersion.VERSION_11 sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_17
} }
kotlin { kotlin {
jvmToolchain(11) jvmToolchain(17)
} }
} }

6
examples/codeviewer/androidApp/build.gradle.kts

@ -26,10 +26,10 @@ android {
versionName = "1.0" versionName = "1.0"
} }
compileOptions { compileOptions {
sourceCompatibility = JavaVersion.VERSION_11 sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_17
} }
kotlin { kotlin {
jvmToolchain(11) jvmToolchain(17)
} }
} }

4
examples/codeviewer/settings.gradle.kts

@ -21,6 +21,10 @@ pluginManagement {
} }
} }
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version("0.4.0")
}
rootProject.name = "codeviewer" rootProject.name = "codeviewer"
include(":androidApp") include(":androidApp")

6
examples/codeviewer/shared/build.gradle.kts

@ -73,10 +73,10 @@ android {
minSdk = 26 minSdk = 26
} }
compileOptions { compileOptions {
sourceCompatibility = JavaVersion.VERSION_11 sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_17
} }
kotlin { kotlin {
jvmToolchain(11) jvmToolchain(17)
} }
} }

6
examples/falling-balls/androidApp/build.gradle.kts

@ -26,10 +26,10 @@ android {
versionName = "1.0" versionName = "1.0"
} }
compileOptions { compileOptions {
sourceCompatibility = JavaVersion.VERSION_11 sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_17
} }
kotlin { kotlin {
jvmToolchain(11) jvmToolchain(17)
} }
} }

4
examples/falling-balls/settings.gradle.kts

@ -20,6 +20,10 @@ pluginManagement {
} }
} }
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version("0.4.0")
}
rootProject.name = "falling-balls-mpp" rootProject.name = "falling-balls-mpp"
include(":androidApp") include(":androidApp")

6
examples/falling-balls/shared/build.gradle.kts

@ -116,10 +116,10 @@ android {
minSdk = 26 minSdk = 26
} }
compileOptions { compileOptions {
sourceCompatibility = JavaVersion.VERSION_11 sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_17
} }
kotlin { kotlin {
jvmToolchain(11) jvmToolchain(17)
} }
} }

6
examples/imageviewer/androidApp/build.gradle.kts

@ -27,11 +27,11 @@ android {
versionName = "1.0" versionName = "1.0"
} }
compileOptions { compileOptions {
sourceCompatibility = JavaVersion.VERSION_11 sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_17
} }
kotlin { kotlin {
jvmToolchain(11) jvmToolchain(17)
} }
} }

4
examples/imageviewer/settings.gradle.kts

@ -21,6 +21,10 @@ pluginManagement {
} }
} }
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version("0.4.0")
}
rootProject.name = "imageviewer" rootProject.name = "imageviewer"
include(":androidApp") include(":androidApp")

6
examples/imageviewer/shared/build.gradle.kts

@ -95,10 +95,10 @@ android {
minSdk = 26 minSdk = 26
} }
compileOptions { compileOptions {
sourceCompatibility = JavaVersion.VERSION_11 sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_17
} }
kotlin { kotlin {
jvmToolchain(11) jvmToolchain(17)
} }
} }

6
examples/issues/android/build.gradle.kts

@ -16,11 +16,11 @@ android {
versionName = "1.0" versionName = "1.0"
} }
compileOptions { compileOptions {
sourceCompatibility = JavaVersion.VERSION_11 sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_17
} }
kotlin { kotlin {
jvmToolchain(11) jvmToolchain(17)
} }
} }

6
examples/issues/common/build.gradle.kts

@ -46,11 +46,11 @@ android {
minSdk = 26 minSdk = 26
} }
compileOptions { compileOptions {
sourceCompatibility = JavaVersion.VERSION_11 sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_17
} }
kotlin { kotlin {
jvmToolchain(11) jvmToolchain(17)
} }
sourceSets { sourceSets {
named("main") { named("main") {

4
examples/issues/settings.gradle.kts

@ -19,4 +19,8 @@ pluginManagement {
} }
} }
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version("0.4.0")
}
include(":common", ":android", ":desktop") include(":common", ":android", ":desktop")

6
examples/minesweeper/androidApp/build.gradle.kts

@ -26,10 +26,10 @@ android {
versionName = "1.0" versionName = "1.0"
} }
compileOptions { compileOptions {
sourceCompatibility = JavaVersion.VERSION_11 sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_17
} }
kotlin { kotlin {
jvmToolchain(11) jvmToolchain(17)
} }
} }

4
examples/minesweeper/settings.gradle.kts

@ -20,6 +20,10 @@ pluginManagement {
} }
} }
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version("0.4.0")
}
rootProject.name = "minesweeper" rootProject.name = "minesweeper"
include(":androidApp") include(":androidApp")

6
examples/minesweeper/shared/build.gradle.kts

@ -126,10 +126,10 @@ android {
minSdk = 26 minSdk = 26
} }
compileOptions { compileOptions {
sourceCompatibility = JavaVersion.VERSION_11 sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_17
} }
kotlin { kotlin {
jvmToolchain(11) jvmToolchain(17)
} }
} }

6
examples/todoapp-lite/androidApp/build.gradle.kts

@ -27,10 +27,10 @@ android {
versionName = "1.0" versionName = "1.0"
} }
compileOptions { compileOptions {
sourceCompatibility = JavaVersion.VERSION_11 sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_17
} }
kotlin { kotlin {
jvmToolchain(11) jvmToolchain(17)
} }
} }

4
examples/todoapp-lite/settings.gradle.kts

@ -19,6 +19,10 @@ pluginManagement {
} }
} }
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version("0.4.0")
}
rootProject.name = "todoapp-lite" rootProject.name = "todoapp-lite"
include(":androidApp") include(":androidApp")

6
examples/todoapp-lite/shared/build.gradle.kts

@ -72,10 +72,10 @@ android {
minSdk = 26 minSdk = 26
} }
compileOptions { compileOptions {
sourceCompatibility = JavaVersion.VERSION_11 sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_17
} }
kotlin { kotlin {
jvmToolchain(11) jvmToolchain(17)
} }
} }

6
examples/visual-effects/androidApp/build.gradle.kts

@ -26,10 +26,10 @@ android {
versionName = "1.0" versionName = "1.0"
} }
compileOptions { compileOptions {
sourceCompatibility = JavaVersion.VERSION_11 sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_17
} }
kotlin { kotlin {
jvmToolchain(11) jvmToolchain(17)
} }
} }

4
examples/visual-effects/settings.gradle.kts

@ -20,6 +20,10 @@ pluginManagement {
} }
} }
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version("0.4.0")
}
rootProject.name = "visual-effects" rootProject.name = "visual-effects"
include(":androidApp") include(":androidApp")

6
examples/visual-effects/shared/build.gradle.kts

@ -71,10 +71,10 @@ android {
minSdk = 26 minSdk = 26
} }
compileOptions { compileOptions {
sourceCompatibility = JavaVersion.VERSION_11 sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_17
} }
kotlin { kotlin {
jvmToolchain(11) jvmToolchain(17)
} }
} }

6
examples/widgets-gallery/androidApp/build.gradle.kts

@ -26,10 +26,10 @@ android {
versionName = "1.0" versionName = "1.0"
} }
compileOptions { compileOptions {
sourceCompatibility = JavaVersion.VERSION_11 sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_17
} }
kotlin { kotlin {
jvmToolchain(11) jvmToolchain(17)
} }
} }

4
examples/widgets-gallery/settings.gradle.kts

@ -20,6 +20,10 @@ pluginManagement {
} }
} }
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version("0.4.0")
}
rootProject.name = "widgets-gallery" rootProject.name = "widgets-gallery"
include(":androidApp") include(":androidApp")

6
examples/widgets-gallery/shared/build.gradle.kts

@ -73,10 +73,10 @@ android {
minSdk = 26 minSdk = 26
} }
compileOptions { compileOptions {
sourceCompatibility = JavaVersion.VERSION_11 sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_17
} }
kotlin { kotlin {
jvmToolchain(11) jvmToolchain(17)
} }
} }

Loading…
Cancel
Save