diff --git a/.github/actions/artifact-android-local-tests/action.yml b/.github/actions/artifact-android-local-tests/action.yml index c6e468a4b5a..e499dc35f36 100644 --- a/.github/actions/artifact-android-local-tests/action.yml +++ b/.github/actions/artifact-android-local-tests/action.yml @@ -12,21 +12,28 @@ runs: path: | ~/.gradle/caches ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + key: ${{ runner.os }}-gradle-java-${{ env.USE_JAVA_VERSION_FOR_GRADLE }}-kotlin-${{ env.USE_KOTLIN_VERSION }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} restore-keys: | + ${{ runner.os }}-gradle-java-${{ env.USE_JAVA_VERSION_FOR_GRADLE }}-kotlin-${{ env.USE_KOTLIN_VERSION }}- + ${{ runner.os }}-gradle-java-${{ env.USE_JAVA_VERSION_FOR_GRADLE }}- ${{ runner.os }}-gradle- - name: 'Download local snapshot for tests' uses: actions/download-artifact@v4 with: name: local-snapshot path: ~/.m2/repository/com/google/dagger - - name: 'Install Java ${{ env.USE_JAVA_VERSION_FOR_GRADLE }}' + - name: 'Install Java ${{ env.USE_JAVA_VERSION_FOR_GRADLE }} (Target)' uses: actions/setup-java@v4 with: distribution: '${{ env.USE_JAVA_DISTRIBUTION }}' java-version: '${{ env.USE_JAVA_VERSION_FOR_GRADLE }}' - - name: 'Gradle Android local tests (AGP ${{ env.USE_AGP_VERSION }})' - run: ./util/run-local-gradle-android-tests.sh "${{ env.USE_AGP_VERSION }}" + - name: 'Install Java 21 (Gradle Boot JDK)' + uses: actions/setup-java@v4 + with: + distribution: '${{ env.USE_JAVA_DISTRIBUTION }}' + java-version: '21' + - name: 'Gradle Android local tests (AGP ${{ env.USE_AGP_VERSION }}, Java ${{ env.USE_JAVA_VERSION_FOR_GRADLE }}, Kotlin ${{ env.USE_KOTLIN_VERSION }})' + run: ./util/run-local-gradle-android-tests.sh "${{ env.USE_AGP_VERSION }}" "${{ env.USE_JAVA_VERSION_FOR_GRADLE }}" "${{ env.USE_KOTLIN_VERSION }}" "${{ env.USE_KSP_VERSION }}" shell: bash - name: 'Upload test reports (AGP ${{ env.USE_AGP_VERSION }})' if: ${{ always() }} diff --git a/.github/actions/artifact-java-local-tests/action.yml b/.github/actions/artifact-java-local-tests/action.yml index bfe997a1fcb..f22c539e5f3 100644 --- a/.github/actions/artifact-java-local-tests/action.yml +++ b/.github/actions/artifact-java-local-tests/action.yml @@ -12,14 +12,16 @@ runs: path: | ~/.gradle/caches ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + key: ${{ runner.os }}-gradle-java-${{ env.USE_JAVA_VERSION_FOR_GRADLE }}-kotlin-${{ env.USE_KOTLIN_VERSION }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} restore-keys: | + ${{ runner.os }}-gradle-java-${{ env.USE_JAVA_VERSION_FOR_GRADLE }}-kotlin-${{ env.USE_KOTLIN_VERSION }}- + ${{ runner.os }}-gradle-java-${{ env.USE_JAVA_VERSION_FOR_GRADLE }}- ${{ runner.os }}-gradle- - name: 'Download local snapshot for tests' uses: actions/download-artifact@v4 with: name: local-snapshot path: ~/.m2/repository/com/google/dagger - - name: 'Gradle Java local tests' - run: ./util/run-local-gradle-tests.sh + - name: 'Gradle Java local tests (Java ${{ env.USE_JAVA_VERSION_FOR_GRADLE }}, Kotlin ${{ env.USE_KOTLIN_VERSION }})' + run: ./util/run-local-gradle-tests.sh "${{ env.USE_JAVA_VERSION_FOR_GRADLE }}" "${{ env.USE_KOTLIN_VERSION }}" "${{ env.USE_KSP_VERSION }}" shell: bash diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 482ac9f5004..7d355c4351b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,9 +61,23 @@ jobs: - uses: actions/checkout@v4 - uses: ./.github/actions/artifact-verification-tests artifact-java-local-tests: - name: 'Artifact Java local tests' + name: 'Artifact Java local tests (Java ${{ matrix.java }}, Kotlin ${{ matrix.kotlin }})' needs: bazel-build runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - java: '11' + kotlin: '2.3.21' + ksp: '2.3.7' + - java: '21' + kotlin: '2.3.21' + ksp: '2.3.7' + env: + USE_JAVA_VERSION_FOR_GRADLE: ${{ matrix.java }} + USE_KOTLIN_VERSION: ${{ matrix.kotlin }} + USE_KSP_VERSION: ${{ matrix.ksp }} steps: - uses: actions/checkout@v4 - uses: ./.github/actions/artifact-java-local-tests @@ -75,9 +89,26 @@ jobs: - uses: actions/checkout@v4 - uses: ./.github/actions/test-gradle-plugin artifact-android-local-tests: - name: 'Artifact Android local tests' + name: 'Artifact Android local tests (AGP ${{ matrix.agp }}, Java ${{ matrix.java }}, Kotlin ${{ matrix.kotlin }})' needs: bazel-build runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - agp: '9.0.0' + java: '11' + kotlin: '2.3.21' + ksp: '2.3.7' + - agp: '9.0.0' + java: '21' + kotlin: '2.3.21' + ksp: '2.3.7' + env: + USE_AGP_VERSION: ${{ matrix.agp }} + USE_JAVA_VERSION_FOR_GRADLE: ${{ matrix.java }} + USE_KOTLIN_VERSION: ${{ matrix.kotlin }} + USE_KSP_VERSION: ${{ matrix.ksp }} steps: - uses: actions/checkout@v4 - uses: ./.github/actions/artifact-android-local-tests diff --git a/javatests/artifacts/dagger-android-ksp/app/build.gradle b/javatests/artifacts/dagger-android-ksp/app/build.gradle index 8fd22f271e5..04cdfb9b107 100644 --- a/javatests/artifacts/dagger-android-ksp/app/build.gradle +++ b/javatests/artifacts/dagger-android-ksp/app/build.gradle @@ -30,10 +30,6 @@ android { versionName "1.0" } namespace "dagger.android.ksp" - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - } testOptions { unitTests.includeAndroidResources = true } @@ -48,9 +44,6 @@ android { } } -kotlin { - jvmToolchain(17) -} dependencies { implementation 'androidx.appcompat:appcompat:1.2.0' diff --git a/javatests/artifacts/dagger-android-ksp/build.gradle b/javatests/artifacts/dagger-android-ksp/build.gradle index eebe988889d..3dd7b711e1f 100644 --- a/javatests/artifacts/dagger-android-ksp/build.gradle +++ b/javatests/artifacts/dagger-android-ksp/build.gradle @@ -16,13 +16,15 @@ buildscript { ext { - agp_version = System.getenv('AGP_VERSION') - kotlin_version = "2.3.21" - ksp_version = "2.3.7" + agp_version = project.findProperty("agpVersion") ?: System.getenv('AGP_VERSION') + kotlin_version = project.findProperty("kotlinVersion") ?: "2.3.21" + ksp_version = project.findProperty("kspVersion") ?: "2.3.7" + java_version = project.findProperty("javaVersion") ?: "11" } repositories { google() mavenCentral() + gradlePluginPortal() mavenLocal() } dependencies { @@ -42,4 +44,21 @@ allprojects { task clean(type: Delete) { delete rootProject.buildDir +} + +subprojects { + plugins.withType(com.android.build.gradle.BasePlugin).configureEach { + project.android { + compileOptions { + sourceCompatibility JavaVersion.toVersion(project.findProperty("javaVersion") ?: "11") + targetCompatibility JavaVersion.toVersion(project.findProperty("javaVersion") ?: "11") + } + } + } + + plugins.withType(org.jetbrains.kotlin.gradle.plugin.KotlinBasePluginWrapper).configureEach { + kotlin { + jvmToolchain((project.findProperty("javaVersion") ?: "11").toInteger()) + } + } } \ No newline at end of file diff --git a/javatests/artifacts/dagger-android/simple/app/build.gradle b/javatests/artifacts/dagger-android/simple/app/build.gradle index 68dd0e9e224..bc65b1ec44c 100644 --- a/javatests/artifacts/dagger-android/simple/app/build.gradle +++ b/javatests/artifacts/dagger-android/simple/app/build.gradle @@ -28,10 +28,6 @@ android { versionName "1.0" } namespace "dagger.android.simple" - compileOptions { - sourceCompatibility JavaVersion.VERSION_11 - targetCompatibility JavaVersion.VERSION_11 - } testOptions { unitTests.includeAndroidResources = true } diff --git a/javatests/artifacts/dagger-android/simple/build.gradle b/javatests/artifacts/dagger-android/simple/build.gradle index bf52aa2ef6d..202f0831599 100644 --- a/javatests/artifacts/dagger-android/simple/build.gradle +++ b/javatests/artifacts/dagger-android/simple/build.gradle @@ -16,7 +16,8 @@ buildscript { ext { - agp_version = System.getenv('AGP_VERSION') + agp_version = project.findProperty("agpVersion") ?: System.getenv('AGP_VERSION') + java_version = project.findProperty("javaVersion") ?: "11" } repositories { google() @@ -47,3 +48,14 @@ allprojects { } } } + +subprojects { + plugins.withType(com.android.build.gradle.BasePlugin).configureEach { + project.android { + compileOptions { + sourceCompatibility JavaVersion.toVersion(project.findProperty("javaVersion") ?: "11") + targetCompatibility JavaVersion.toVersion(project.findProperty("javaVersion") ?: "11") + } + } + } +} diff --git a/javatests/artifacts/dagger-ksp/build.gradle b/javatests/artifacts/dagger-ksp/build.gradle index 5c393922000..93ca7b256af 100644 --- a/javatests/artifacts/dagger-ksp/build.gradle +++ b/javatests/artifacts/dagger-ksp/build.gradle @@ -17,8 +17,9 @@ buildscript { ext { dagger_version = "LOCAL-SNAPSHOT" - kotlin_version = "2.3.21" - ksp_version = "2.3.7" + kotlin_version = project.findProperty("kotlinVersion") ?: "2.3.21" + ksp_version = project.findProperty("kspVersion") ?: "2.3.7" + java_version = project.findProperty("javaVersion") ?: "11" junit_version = "4.13" truth_version = "1.0.1" } @@ -48,3 +49,13 @@ allprojects { } } } + +subprojects { + plugins.withType(JavaPlugin) { + java { + toolchain { + languageVersion = JavaLanguageVersion.of(java_version.toInteger()) + } + } + } +} diff --git a/javatests/artifacts/dagger-ksp/kotlin-app/build.gradle b/javatests/artifacts/dagger-ksp/kotlin-app/build.gradle index bb707a52c36..52d1d6ebf0e 100644 --- a/javatests/artifacts/dagger-ksp/kotlin-app/build.gradle +++ b/javatests/artifacts/dagger-ksp/kotlin-app/build.gradle @@ -20,12 +20,6 @@ plugins { id 'com.google.devtools.ksp' } -java { - toolchain { - languageVersion.set(JavaLanguageVersion.of(11)) - } -} - dependencies { implementation project(path: ':kotlin-app:kotlin-library') diff --git a/javatests/artifacts/dagger-ksp/kotlin-app/kotlin-library/build.gradle b/javatests/artifacts/dagger-ksp/kotlin-app/kotlin-library/build.gradle index 6f6ce382565..bb996d77450 100644 --- a/javatests/artifacts/dagger-ksp/kotlin-app/kotlin-library/build.gradle +++ b/javatests/artifacts/dagger-ksp/kotlin-app/kotlin-library/build.gradle @@ -21,7 +21,7 @@ plugins { java { toolchain { - languageVersion.set(JavaLanguageVersion.of(11)) + languageVersion.set(JavaLanguageVersion.of(java_version.toInteger())) } } diff --git a/javatests/artifacts/dagger/build.gradle b/javatests/artifacts/dagger/build.gradle index 4dbe565fa82..6748b3e98ef 100644 --- a/javatests/artifacts/dagger/build.gradle +++ b/javatests/artifacts/dagger/build.gradle @@ -17,8 +17,9 @@ buildscript { ext { dagger_version = "LOCAL-SNAPSHOT" - kotlin_version = "2.3.21" - ksp_version = "2.3.7" + kotlin_version = project.findProperty("kotlinVersion") ?: "2.3.21" + ksp_version = project.findProperty("kspVersion") ?: "2.3.7" + java_version = project.findProperty("javaVersion") ?: "11" junit_version = "4.13" truth_version = "1.0.1" } @@ -40,3 +41,15 @@ allprojects { } } } + +subprojects { + if (name != 'build-tests') { + plugins.withType(JavaPlugin) { + java { + toolchain { + languageVersion = JavaLanguageVersion.of(java_version.toInteger()) + } + } + } + } +} diff --git a/javatests/artifacts/dagger/java-app/build.gradle b/javatests/artifacts/dagger/java-app/build.gradle index 775fc1e3e04..65003c5e926 100644 --- a/javatests/artifacts/dagger/java-app/build.gradle +++ b/javatests/artifacts/dagger/java-app/build.gradle @@ -19,12 +19,6 @@ plugins { id 'application' } -java { - toolchain { - languageVersion.set(JavaLanguageVersion.of(11)) - } -} - dependencies { implementation "com.google.dagger:dagger:$dagger_version" annotationProcessor "com.google.dagger:dagger-compiler:$dagger_version" diff --git a/javatests/artifacts/dagger/kotlin-app/build.gradle b/javatests/artifacts/dagger/kotlin-app/build.gradle index 225e9c68f5b..d2c8e859ea5 100644 --- a/javatests/artifacts/dagger/kotlin-app/build.gradle +++ b/javatests/artifacts/dagger/kotlin-app/build.gradle @@ -20,12 +20,6 @@ plugins { id 'org.jetbrains.kotlin.kapt' version "$kotlin_version" } -java { - toolchain { - languageVersion.set(JavaLanguageVersion.of(11)) - } -} - dependencies { implementation project(path: ':kotlin-app:kotlin-library') diff --git a/javatests/artifacts/dagger/kotlin-app/kotlin-library/build.gradle b/javatests/artifacts/dagger/kotlin-app/kotlin-library/build.gradle index 54aaf404ad8..33d209b69ed 100644 --- a/javatests/artifacts/dagger/kotlin-app/kotlin-library/build.gradle +++ b/javatests/artifacts/dagger/kotlin-app/kotlin-library/build.gradle @@ -21,7 +21,7 @@ plugins { java { toolchain { - languageVersion.set(JavaLanguageVersion.of(11)) + languageVersion.set(JavaLanguageVersion.of(java_version.toInteger())) } } diff --git a/javatests/artifacts/dagger/transitive-annotation-app/build.gradle b/javatests/artifacts/dagger/transitive-annotation-app/build.gradle index 460a88db802..0a9850913aa 100644 --- a/javatests/artifacts/dagger/transitive-annotation-app/build.gradle +++ b/javatests/artifacts/dagger/transitive-annotation-app/build.gradle @@ -19,12 +19,6 @@ plugins { id 'application' } -java { - toolchain { - languageVersion.set(JavaLanguageVersion.of(11)) - } -} - dependencies { implementation project(":transitive-annotation-app:library1") implementation "com.google.dagger:dagger:$dagger_version" diff --git a/javatests/artifacts/dagger/transitive-annotation-app/library1/build.gradle b/javatests/artifacts/dagger/transitive-annotation-app/library1/build.gradle index 3ab3f28589d..b7e912f41e2 100644 --- a/javatests/artifacts/dagger/transitive-annotation-app/library1/build.gradle +++ b/javatests/artifacts/dagger/transitive-annotation-app/library1/build.gradle @@ -19,12 +19,6 @@ plugins { id 'java-library' } -java { - toolchain { - languageVersion.set(JavaLanguageVersion.of(11)) - } -} - dependencies { implementation project(":transitive-annotation-app:library2") implementation "com.google.dagger:dagger:$dagger_version" diff --git a/javatests/artifacts/dagger/transitive-annotation-app/library2/build.gradle b/javatests/artifacts/dagger/transitive-annotation-app/library2/build.gradle index 74065335232..4c53a11c115 100644 --- a/javatests/artifacts/dagger/transitive-annotation-app/library2/build.gradle +++ b/javatests/artifacts/dagger/transitive-annotation-app/library2/build.gradle @@ -18,9 +18,3 @@ plugins { id 'java' id 'java-library' } - -java { - toolchain { - languageVersion.set(JavaLanguageVersion.of(11)) - } -} diff --git a/javatests/artifacts/dagger/transitive-annotation-kotlin-app/build.gradle b/javatests/artifacts/dagger/transitive-annotation-kotlin-app/build.gradle index dae99b059c5..05b7648caa8 100644 --- a/javatests/artifacts/dagger/transitive-annotation-kotlin-app/build.gradle +++ b/javatests/artifacts/dagger/transitive-annotation-kotlin-app/build.gradle @@ -20,12 +20,6 @@ plugins { id 'org.jetbrains.kotlin.kapt' version "$kotlin_version" } -java { - toolchain { - languageVersion.set(JavaLanguageVersion.of(11)) - } -} - kapt { correctErrorTypes = true } diff --git a/javatests/artifacts/dagger/transitive-annotation-kotlin-app/library1/build.gradle b/javatests/artifacts/dagger/transitive-annotation-kotlin-app/library1/build.gradle index 4363993d294..8aa15622234 100644 --- a/javatests/artifacts/dagger/transitive-annotation-kotlin-app/library1/build.gradle +++ b/javatests/artifacts/dagger/transitive-annotation-kotlin-app/library1/build.gradle @@ -20,12 +20,6 @@ plugins { id 'org.jetbrains.kotlin.kapt' } -java { - toolchain { - languageVersion.set(JavaLanguageVersion.of(11)) - } -} - kapt { correctErrorTypes = true } diff --git a/javatests/artifacts/dagger/transitive-annotation-kotlin-app/library2/build.gradle b/javatests/artifacts/dagger/transitive-annotation-kotlin-app/library2/build.gradle index 38619464409..66d1a9a30f0 100644 --- a/javatests/artifacts/dagger/transitive-annotation-kotlin-app/library2/build.gradle +++ b/javatests/artifacts/dagger/transitive-annotation-kotlin-app/library2/build.gradle @@ -23,9 +23,3 @@ plugins { kapt { correctErrorTypes = true } - -java { - toolchain { - languageVersion.set(JavaLanguageVersion.of(11)) - } -} diff --git a/javatests/artifacts/hilt-android/simple/app-java-only/build.gradle b/javatests/artifacts/hilt-android/simple/app-java-only/build.gradle index b4e3f7f934c..6d3b932c3ce 100644 --- a/javatests/artifacts/hilt-android/simple/app-java-only/build.gradle +++ b/javatests/artifacts/hilt-android/simple/app-java-only/build.gradle @@ -29,10 +29,6 @@ android { versionName "1.0" } namespace "dagger.hilt.android.simple" - compileOptions { - sourceCompatibility JavaVersion.VERSION_11 - targetCompatibility JavaVersion.VERSION_11 - } testOptions { unitTests.includeAndroidResources = true } diff --git a/javatests/artifacts/hilt-android/simple/app/build.gradle.kts b/javatests/artifacts/hilt-android/simple/app/build.gradle.kts index 1791241402f..b1cd7dcf334 100644 --- a/javatests/artifacts/hilt-android/simple/app/build.gradle.kts +++ b/javatests/artifacts/hilt-android/simple/app/build.gradle.kts @@ -16,6 +16,8 @@ import java.io.File +val java_version: String by project + plugins { id("com.android.application") id("com.google.dagger.hilt.android") @@ -113,10 +115,6 @@ android { testInstrumentationRunner = "dagger.hilt.android.simple.SimpleEmulatorTestRunner" } namespace = "dagger.hilt.android.simple" - compileOptions { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 - } testOptions { unitTests.isIncludeAndroidResources = true } lint { checkReleaseBuilds = false } sourceSets { diff --git a/javatests/artifacts/hilt-android/simple/build.gradle b/javatests/artifacts/hilt-android/simple/build.gradle index 8394fc62c66..c71048189fa 100644 --- a/javatests/artifacts/hilt-android/simple/build.gradle +++ b/javatests/artifacts/hilt-android/simple/build.gradle @@ -17,12 +17,14 @@ buildscript { ext { dagger_version = 'LOCAL-SNAPSHOT' - kotlin_version = "2.3.21" - agp_version = System.getenv('AGP_VERSION') + kotlin_version = project.findProperty("kotlinVersion") ?: "2.3.21" + java_version = project.findProperty("javaVersion") ?: "11" + agp_version = project.findProperty("agpVersion") ?: System.getenv('AGP_VERSION') } repositories { google() mavenCentral() + gradlePluginPortal() mavenLocal() } dependencies { @@ -63,4 +65,19 @@ subprojects { implementation(platform("org.jetbrains.kotlin:kotlin-bom:$kotlin_version")) } } + + plugins.withType(com.android.build.gradle.BasePlugin).configureEach { + project.android { + compileOptions { + sourceCompatibility JavaVersion.toVersion(project.findProperty("javaVersion") ?: "11") + targetCompatibility JavaVersion.toVersion(project.findProperty("javaVersion") ?: "11") + } + } + } + + plugins.withType(org.jetbrains.kotlin.gradle.plugin.KotlinBasePluginWrapper).configureEach { + kotlin { + jvmToolchain((project.findProperty("javaVersion") ?: "11").toInteger()) + } + } } diff --git a/javatests/artifacts/hilt-android/simple/deep-android-lib/build.gradle b/javatests/artifacts/hilt-android/simple/deep-android-lib/build.gradle index 8e91a98c850..9b7dd90a3df 100644 --- a/javatests/artifacts/hilt-android/simple/deep-android-lib/build.gradle +++ b/javatests/artifacts/hilt-android/simple/deep-android-lib/build.gradle @@ -14,10 +14,6 @@ android { versionName "1.0" } namespace "dagger.hilt.android.simple.deep" - compileOptions { - sourceCompatibility JavaVersion.VERSION_11 - targetCompatibility JavaVersion.VERSION_11 - } } dependencies { diff --git a/javatests/artifacts/hilt-android/simple/deep-lib/build.gradle b/javatests/artifacts/hilt-android/simple/deep-lib/build.gradle index 6a907827c88..7dcbedd0fb1 100644 --- a/javatests/artifacts/hilt-android/simple/deep-lib/build.gradle +++ b/javatests/artifacts/hilt-android/simple/deep-lib/build.gradle @@ -4,7 +4,7 @@ plugins { java { toolchain { - languageVersion.set(JavaLanguageVersion.of(11)) + languageVersion.set(JavaLanguageVersion.of(java_version.toInteger())) } } diff --git a/javatests/artifacts/hilt-android/simple/earlyentrypoint/build.gradle b/javatests/artifacts/hilt-android/simple/earlyentrypoint/build.gradle index 7db4758da3d..b82227c7582 100644 --- a/javatests/artifacts/hilt-android/simple/earlyentrypoint/build.gradle +++ b/javatests/artifacts/hilt-android/simple/earlyentrypoint/build.gradle @@ -14,10 +14,6 @@ android { versionName "1.0" } namespace "dagger.hilt.android.simple.earlyentrypoint" - compileOptions { - sourceCompatibility JavaVersion.VERSION_11 - targetCompatibility JavaVersion.VERSION_11 - } testOptions { unitTests.includeAndroidResources = true } diff --git a/javatests/artifacts/hilt-android/simple/feature/build.gradle b/javatests/artifacts/hilt-android/simple/feature/build.gradle index af537a23b62..d150cc9ede6 100644 --- a/javatests/artifacts/hilt-android/simple/feature/build.gradle +++ b/javatests/artifacts/hilt-android/simple/feature/build.gradle @@ -29,10 +29,6 @@ android { versionName "1.0" } namespace "dagger.hilt.android.simple.feature" - compileOptions { - sourceCompatibility JavaVersion.VERSION_11 - targetCompatibility JavaVersion.VERSION_11 - } flavorDimensions "tier" productFlavors { free { @@ -44,9 +40,6 @@ android { } } -kotlin { - jvmToolchain(11) -} kapt { correctErrorTypes true diff --git a/javatests/artifacts/hilt-android/simple/lib/build.gradle b/javatests/artifacts/hilt-android/simple/lib/build.gradle index 0c2e33a15fe..3b27e0a9aef 100644 --- a/javatests/artifacts/hilt-android/simple/lib/build.gradle +++ b/javatests/artifacts/hilt-android/simple/lib/build.gradle @@ -20,7 +20,7 @@ plugins { java { toolchain { - languageVersion.set(JavaLanguageVersion.of(11)) + languageVersion.set(JavaLanguageVersion.of(java_version.toInteger())) } } diff --git a/javatests/artifacts/hilt-android/simple/uitest/build.gradle b/javatests/artifacts/hilt-android/simple/uitest/build.gradle index 2779d8e15b9..b2a9ba82751 100644 --- a/javatests/artifacts/hilt-android/simple/uitest/build.gradle +++ b/javatests/artifacts/hilt-android/simple/uitest/build.gradle @@ -29,10 +29,6 @@ android { } namespace "dagger.hilt.android.simple.uitest" targetProjectPath ':app' - compileOptions { - sourceCompatibility JavaVersion.VERSION_11 - targetCompatibility JavaVersion.VERSION_11 - } } hilt { diff --git a/javatests/artifacts/hilt-android/simpleKotlin/android-library/build.gradle b/javatests/artifacts/hilt-android/simpleKotlin/android-library/build.gradle index 1e29feae154..3c588ad2aa7 100644 --- a/javatests/artifacts/hilt-android/simpleKotlin/android-library/build.gradle +++ b/javatests/artifacts/hilt-android/simpleKotlin/android-library/build.gradle @@ -1,5 +1,6 @@ plugins { id 'com.android.library' + id 'com.android.experimental.built-in-kotlin' id 'com.android.legacy-kapt' id 'com.google.devtools.ksp' } @@ -15,10 +16,6 @@ android { versionName "1.0" } namespace "dagger.hilt.android.simpleKotlin.lib" - compileOptions { - sourceCompatibility JavaVersion.VERSION_11 - targetCompatibility JavaVersion.VERSION_11 - } flavorDimensions "tier", "processorConfig" productFlavors { free { @@ -36,9 +33,6 @@ android { } } -kotlin { - jvmToolchain(11) -} dependencies { implementation project(':deep-android-lib') diff --git a/javatests/artifacts/hilt-android/simpleKotlin/app/build.gradle b/javatests/artifacts/hilt-android/simpleKotlin/app/build.gradle index 85ed291bf92..e844d8c1249 100644 --- a/javatests/artifacts/hilt-android/simpleKotlin/app/build.gradle +++ b/javatests/artifacts/hilt-android/simpleKotlin/app/build.gradle @@ -54,10 +54,6 @@ android { dimension "processorConfig" } } - compileOptions { - sourceCompatibility JavaVersion.VERSION_11 - targetCompatibility JavaVersion.VERSION_11 - } testOptions { unitTests.includeAndroidResources = true } @@ -75,9 +71,6 @@ android { } } -kotlin { - jvmToolchain(11) -} hilt { enableTransformForLocalTests = true diff --git a/javatests/artifacts/hilt-android/simpleKotlin/build.gradle b/javatests/artifacts/hilt-android/simpleKotlin/build.gradle index 765822175d8..320fcf7fbf9 100644 --- a/javatests/artifacts/hilt-android/simpleKotlin/build.gradle +++ b/javatests/artifacts/hilt-android/simpleKotlin/build.gradle @@ -16,9 +16,10 @@ buildscript { ext { - kotlin_version = "2.3.21" - ksp_version = "2.3.7" - agp_version = System.getenv('AGP_VERSION') + kotlin_version = project.findProperty("kotlinVersion") ?: "2.3.21" + ksp_version = project.findProperty("kspVersion") ?: "2.3.7" + java_version = project.findProperty("javaVersion") ?: "11" + agp_version = project.findProperty("agpVersion") ?: System.getenv('AGP_VERSION') } repositories { google() @@ -54,3 +55,20 @@ allprojects { } } } + +subprojects { + plugins.withType(com.android.build.gradle.BasePlugin).configureEach { + project.android { + compileOptions { + sourceCompatibility JavaVersion.toVersion(project.findProperty("javaVersion") ?: "11") + targetCompatibility JavaVersion.toVersion(project.findProperty("javaVersion") ?: "11") + } + } + } + + plugins.withType(org.jetbrains.kotlin.gradle.plugin.KotlinBasePluginWrapper).configureEach { + kotlin { + jvmToolchain((project.findProperty("javaVersion") ?: "11").toInteger()) + } + } +} diff --git a/javatests/artifacts/hilt-android/simpleKotlin/deep-android-lib/build.gradle b/javatests/artifacts/hilt-android/simpleKotlin/deep-android-lib/build.gradle index b4b8ada9309..e94534a1d41 100644 --- a/javatests/artifacts/hilt-android/simpleKotlin/deep-android-lib/build.gradle +++ b/javatests/artifacts/hilt-android/simpleKotlin/deep-android-lib/build.gradle @@ -18,10 +18,6 @@ android { testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } namespace "dagger.hilt.android.simpleKotlin.deep" - compileOptions { - sourceCompatibility JavaVersion.VERSION_11 - targetCompatibility JavaVersion.VERSION_11 - } lintOptions { checkReleaseBuilds = false } @@ -36,9 +32,6 @@ android { } } -kotlin { - jvmToolchain(11) -} dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" diff --git a/javatests/artifacts/hilt-android/simpleKotlin/deep-kotlin-lib/build.gradle b/javatests/artifacts/hilt-android/simpleKotlin/deep-kotlin-lib/build.gradle index 24e7246a916..606e5fae31e 100644 --- a/javatests/artifacts/hilt-android/simpleKotlin/deep-kotlin-lib/build.gradle +++ b/javatests/artifacts/hilt-android/simpleKotlin/deep-kotlin-lib/build.gradle @@ -3,9 +3,6 @@ plugins { id 'com.google.devtools.ksp' } -kotlin { - jvmToolchain(11) -} dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" diff --git a/javatests/artifacts/hilt-android/simpleKotlin/kotlin-library/build.gradle b/javatests/artifacts/hilt-android/simpleKotlin/kotlin-library/build.gradle index ed01615c9e7..439324ca2e3 100644 --- a/javatests/artifacts/hilt-android/simpleKotlin/kotlin-library/build.gradle +++ b/javatests/artifacts/hilt-android/simpleKotlin/kotlin-library/build.gradle @@ -3,9 +3,6 @@ plugins { id 'com.google.devtools.ksp' } -kotlin { - jvmToolchain(11) -} dependencies { implementation project(':deep-kotlin-lib') diff --git a/util/install-maven.sh b/util/install-maven.sh index d6fdf40b0d8..b1f3bdd0b6a 100755 --- a/util/install-maven.sh +++ b/util/install-maven.sh @@ -10,7 +10,10 @@ function install-maven-version { exit 2 fi - local current_version=$(mvn --version | grep 'Apache Maven [0-9.]*' | cut -d' ' -f3) + local current_version="" + if command -v mvn &> /dev/null; then + current_version=$(mvn --version | grep 'Apache Maven [0-9.]*' | cut -d' ' -f3) + fi if [[ "$current_version" == "$version" ]]; then echo "Maven version $version is already installed." exit 0 @@ -29,7 +32,7 @@ function install-maven-version { popd # Replace old symlink with new one - sudo unlink /usr/bin/mvn + sudo rm -f /usr/bin/mvn sudo ln -s /usr/share/apache-maven-${version}/bin/mvn /usr/bin/mvn } diff --git a/util/run-local-gradle-android-tests.sh b/util/run-local-gradle-android-tests.sh index 16913136eaa..a0c1dcac631 100755 --- a/util/run-local-gradle-android-tests.sh +++ b/util/run-local-gradle-android-tests.sh @@ -2,8 +2,20 @@ set -ex +if [ $# -lt 2 ]; then + echo "Usage: $0 [KOTLIN_VERSION] [KSP_VERSION]" + exit 1 +fi readonly AGP_VERSION_INPUT=$1 -readonly COMMON_GRADLE_ARGS="--no-daemon --stacktrace --configuration-cache" +readonly JAVA_VERSION_INPUT=$2 +readonly KOTLIN_VERSION_INPUT=$3 +readonly KSP_VERSION_INPUT=$4 + +GRADLE_ARGS="--no-daemon --stacktrace --configuration-cache" +GRADLE_ARGS+=" -PagpVersion=$AGP_VERSION_INPUT" +GRADLE_ARGS+=" -PjavaVersion=$JAVA_VERSION_INPUT" +GRADLE_ARGS+="${KOTLIN_VERSION_INPUT:+ -PkotlinVersion=$KOTLIN_VERSION_INPUT}" +GRADLE_ARGS+="${KSP_VERSION_INPUT:+ -PkspVersion=$KSP_VERSION_INPUT}" readonly JAVA_ANDROID_GRADLE_PROJECTS=( "javatests/artifacts/dagger-android/simple" @@ -17,13 +29,13 @@ readonly KOTLIN_ANDROID_GRADLE_PROJECTS=( for project in "${JAVA_ANDROID_GRADLE_PROJECTS[@]}"; do echo "Running gradle tests for $project with AGP $AGP_VERSION_INPUT" - AGP_VERSION=$AGP_VERSION_INPUT ./$project/gradlew -p $project assembleDebug $COMMON_GRADLE_ARGS - AGP_VERSION=$AGP_VERSION_INPUT ./$project/gradlew -p $project testDebugUnitTest --continue $COMMON_GRADLE_ARGS + ./$project/gradlew -p $project assembleDebug $GRADLE_ARGS + ./$project/gradlew -p $project testDebugUnitTest --continue $GRADLE_ARGS done for project in "${KOTLIN_ANDROID_GRADLE_PROJECTS[@]}"; do echo "Running gradle tests for $project with AGP $AGP_VERSION_INPUT" - AGP_VERSION=$AGP_VERSION_INPUT ./$project/gradlew -p $project assembleDebug $COMMON_GRADLE_ARGS - AGP_VERSION=$AGP_VERSION_INPUT ./$project/gradlew -p $project testWithKaptDebugUnitTest --continue $COMMON_GRADLE_ARGS - AGP_VERSION=$AGP_VERSION_INPUT ./$project/gradlew -p $project testWithKspDebugUnitTest --continue $COMMON_GRADLE_ARGS + ./$project/gradlew -p $project assembleDebug $GRADLE_ARGS + ./$project/gradlew -p $project testWithKaptDebugUnitTest --continue $GRADLE_ARGS + ./$project/gradlew -p $project testWithKspDebugUnitTest --continue $GRADLE_ARGS done diff --git a/util/run-local-gradle-tests.sh b/util/run-local-gradle-tests.sh index fca68826ee4..b754cae820f 100755 --- a/util/run-local-gradle-tests.sh +++ b/util/run-local-gradle-tests.sh @@ -2,12 +2,25 @@ set -ex +if [ $# -lt 1 ]; then + echo "Usage: $0 [KOTLIN_VERSION] [KSP_VERSION]" + exit 1 +fi +readonly JAVA_VERSION_INPUT=$1 +readonly KOTLIN_VERSION_INPUT=$2 +readonly KSP_VERSION_INPUT=$3 + +GRADLE_ARGS="--no-daemon --stacktrace" +GRADLE_ARGS+=" -PjavaVersion=$JAVA_VERSION_INPUT" +GRADLE_ARGS+="${KOTLIN_VERSION_INPUT:+ -PkotlinVersion=$KOTLIN_VERSION_INPUT}" +GRADLE_ARGS+="${KSP_VERSION_INPUT:+ -PkspVersion=$KSP_VERSION_INPUT}" + readonly GRADLE_PROJECTS=( "javatests/artifacts/dagger" "javatests/artifacts/dagger-ksp" ) for project in "${GRADLE_PROJECTS[@]}"; do echo "Running gradle tests for $project" - ./$project/gradlew -p $project build --no-daemon --stacktrace - ./$project/gradlew -p $project test --continue --no-daemon --stacktrace + ./$project/gradlew -p $project build $GRADLE_ARGS + ./$project/gradlew -p $project test --continue $GRADLE_ARGS done