diff options
Diffstat (limited to 'build-logic/src/main/kotlin')
4 files changed, 23 insertions, 15 deletions
diff --git a/build-logic/src/main/kotlin/app/passwordstore/gradle/AndroidCommon.kt b/build-logic/src/main/kotlin/app/passwordstore/gradle/AndroidCommon.kt index 82211f40..d73239c2 100644 --- a/build-logic/src/main/kotlin/app/passwordstore/gradle/AndroidCommon.kt +++ b/build-logic/src/main/kotlin/app/passwordstore/gradle/AndroidCommon.kt @@ -5,7 +5,6 @@ import app.passwordstore.gradle.flavors.configureSlimTests import com.android.build.api.dsl.ApplicationExtension import com.android.build.api.dsl.LibraryExtension import com.android.build.gradle.TestedExtension -import org.gradle.api.JavaVersion import org.gradle.api.Project import org.gradle.api.artifacts.VersionCatalogsExtension import org.gradle.api.tasks.testing.Test @@ -32,11 +31,6 @@ object AndroidCommon { resources.excludes.add("**/META-INF/LGPL2.1") } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } - testOptions { animationsDisabled = true unitTests.isReturnDefaultValues = true diff --git a/build-logic/src/main/kotlin/app/passwordstore/gradle/KotlinAndroidPlugin.kt b/build-logic/src/main/kotlin/app/passwordstore/gradle/KotlinAndroidPlugin.kt index 49f207a1..553e8acd 100644 --- a/build-logic/src/main/kotlin/app/passwordstore/gradle/KotlinAndroidPlugin.kt +++ b/build-logic/src/main/kotlin/app/passwordstore/gradle/KotlinAndroidPlugin.kt @@ -5,9 +5,13 @@ package app.passwordstore.gradle +import app.passwordstore.gradle.KotlinCommonPlugin.Companion.JVM_TOOLCHAIN_ACTION import org.gradle.api.Plugin import org.gradle.api.Project +import org.gradle.api.plugins.JavaPluginExtension import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.getByType +import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension import org.jetbrains.kotlin.gradle.plugin.KotlinAndroidPluginWrapper @Suppress("Unused") @@ -18,5 +22,7 @@ class KotlinAndroidPlugin : Plugin<Project> { apply(KotlinAndroidPluginWrapper::class) apply(KotlinCommonPlugin::class) } + project.extensions.getByType<JavaPluginExtension>().toolchain(JVM_TOOLCHAIN_ACTION) + project.extensions.getByType<KotlinProjectExtension>().jvmToolchain(JVM_TOOLCHAIN_ACTION) } } diff --git a/build-logic/src/main/kotlin/app/passwordstore/gradle/KotlinCommonPlugin.kt b/build-logic/src/main/kotlin/app/passwordstore/gradle/KotlinCommonPlugin.kt index 5052be3c..4b69abf7 100644 --- a/build-logic/src/main/kotlin/app/passwordstore/gradle/KotlinCommonPlugin.kt +++ b/build-logic/src/main/kotlin/app/passwordstore/gradle/KotlinCommonPlugin.kt @@ -5,14 +5,15 @@ package app.passwordstore.gradle -import org.gradle.api.JavaVersion +import org.gradle.api.Action import org.gradle.api.Plugin import org.gradle.api.Project -import org.gradle.api.tasks.compile.JavaCompile import org.gradle.api.tasks.testing.Test import org.gradle.api.tasks.testing.logging.TestLogEvent +import org.gradle.jvm.toolchain.JavaLanguageVersion +import org.gradle.jvm.toolchain.JavaToolchainSpec +import org.gradle.jvm.toolchain.JvmVendorSpec import org.gradle.kotlin.dsl.withType -import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.dsl.KotlinVersion import org.jetbrains.kotlin.gradle.tasks.KotlinCompile @@ -22,13 +23,8 @@ class KotlinCommonPlugin : Plugin<Project> { override fun apply(project: Project) { val isAppModule = project.pluginManager.hasPlugin("com.android.application") project.tasks.run { - withType<JavaCompile>().configureEach { - sourceCompatibility = JavaVersion.VERSION_17.toString() - targetCompatibility = JavaVersion.VERSION_17.toString() - } withType<KotlinCompile>().configureEach task@{ compilerOptions { - jvmTarget.set(JvmTarget.JVM_17) allWarningsAsErrors.set(true) languageVersion.set(KotlinVersion.KOTLIN_1_8) freeCompilerArgs.addAll(ADDITIONAL_COMPILER_ARGS) @@ -44,11 +40,17 @@ class KotlinCommonPlugin : Plugin<Project> { } } - private companion object { + companion object { private val ADDITIONAL_COMPILER_ARGS = listOf( "-opt-in=kotlin.RequiresOptIn", "-Xsuppress-version-warnings", ) + + val JVM_TOOLCHAIN_ACTION = + Action<JavaToolchainSpec> { + languageVersion.set(JavaLanguageVersion.of(17)) + vendor.set(JvmVendorSpec.ADOPTIUM) + } } } diff --git a/build-logic/src/main/kotlin/app/passwordstore/gradle/KotlinJVMLibrary.kt b/build-logic/src/main/kotlin/app/passwordstore/gradle/KotlinJVMLibrary.kt index c5cf84a0..2c55796b 100644 --- a/build-logic/src/main/kotlin/app/passwordstore/gradle/KotlinJVMLibrary.kt +++ b/build-logic/src/main/kotlin/app/passwordstore/gradle/KotlinJVMLibrary.kt @@ -5,13 +5,17 @@ package app.passwordstore.gradle +import app.passwordstore.gradle.KotlinCommonPlugin.Companion.JVM_TOOLCHAIN_ACTION import app.passwordstore.gradle.LintConfig.configureLint import com.android.build.api.dsl.Lint import com.android.build.gradle.LintPlugin import org.gradle.api.Plugin import org.gradle.api.Project +import org.gradle.api.plugins.JavaPluginExtension import org.gradle.kotlin.dsl.apply import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.getByType +import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension import org.jetbrains.kotlin.gradle.plugin.KotlinPluginWrapper @Suppress("Unused") @@ -24,5 +28,7 @@ class KotlinJVMLibrary : Plugin<Project> { apply(KotlinCommonPlugin::class) } project.extensions.configure<Lint> { configureLint(project, isJVM = true) } + project.extensions.getByType<JavaPluginExtension>().toolchain(JVM_TOOLCHAIN_ACTION) + project.extensions.getByType<KotlinProjectExtension>().jvmToolchain(JVM_TOOLCHAIN_ACTION) } } |