mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-14 19:57:04 +05:30
feat(build): migrate to Gradle JVM Toolchains
This commit is contained in:
parent
be9a888816
commit
fe752f839a
6 changed files with 27 additions and 39 deletions
|
@ -4,22 +4,9 @@
|
||||||
* license that can be found in the LICENSE file or at
|
* license that can be found in the LICENSE file or at
|
||||||
* https://opensource.org/licenses/MIT.
|
* https://opensource.org/licenses/MIT.
|
||||||
*/
|
*/
|
||||||
import org.gradle.api.JavaVersion
|
|
||||||
import org.gradle.api.tasks.compile.JavaCompile
|
|
||||||
import org.gradle.kotlin.dsl.withType
|
|
||||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
|
||||||
|
|
||||||
plugins { `kotlin-dsl` }
|
plugins { `kotlin-dsl` }
|
||||||
|
|
||||||
tasks.withType<JavaCompile>().configureEach {
|
kotlin.jvmToolchain { languageVersion.set(JavaLanguageVersion.of(17)) }
|
||||||
sourceCompatibility = JavaVersion.VERSION_17.toString()
|
|
||||||
targetCompatibility = JavaVersion.VERSION_17.toString()
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType<KotlinCompile>().configureEach {
|
|
||||||
compilerOptions { jvmTarget.set(JvmTarget.JVM_17) }
|
|
||||||
}
|
|
||||||
|
|
||||||
gradlePlugin {
|
gradlePlugin {
|
||||||
plugins {
|
plugins {
|
||||||
|
|
|
@ -16,7 +16,6 @@ import com.android.build.api.variant.LibraryAndroidComponentsExtension
|
||||||
import com.android.build.gradle.BaseExtension
|
import com.android.build.gradle.BaseExtension
|
||||||
import dev.msfjarvis.claw.gradle.LintConfig.configureLint
|
import dev.msfjarvis.claw.gradle.LintConfig.configureLint
|
||||||
import org.gradle.android.AndroidCacheFixPlugin
|
import org.gradle.android.AndroidCacheFixPlugin
|
||||||
import org.gradle.api.JavaVersion
|
|
||||||
import org.gradle.api.Plugin
|
import org.gradle.api.Plugin
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.api.artifacts.VersionCatalogsExtension
|
import org.gradle.api.artifacts.VersionCatalogsExtension
|
||||||
|
@ -53,11 +52,6 @@ class AndroidCommonPlugin : Plugin<Project> {
|
||||||
resources.excludes.add("**/META-INF/LGPL2.1")
|
resources.excludes.add("**/META-INF/LGPL2.1")
|
||||||
}
|
}
|
||||||
|
|
||||||
compileOptions {
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_17
|
|
||||||
targetCompatibility = JavaVersion.VERSION_17
|
|
||||||
}
|
|
||||||
|
|
||||||
testOptions {
|
testOptions {
|
||||||
animationsDisabled = true
|
animationsDisabled = true
|
||||||
unitTests.isReturnDefaultValues = true
|
unitTests.isReturnDefaultValues = true
|
||||||
|
|
|
@ -1,14 +1,17 @@
|
||||||
/*
|
/*
|
||||||
* Copyright © 2022 Harsh Shandilya.
|
* Copyright © 2022-2023 Harsh Shandilya.
|
||||||
* Use of this source code is governed by an MIT-style
|
* Use of this source code is governed by an MIT-style
|
||||||
* license that can be found in the LICENSE file or at
|
* license that can be found in the LICENSE file or at
|
||||||
* https://opensource.org/licenses/MIT.
|
* https://opensource.org/licenses/MIT.
|
||||||
*/
|
*/
|
||||||
package dev.msfjarvis.claw.gradle
|
package dev.msfjarvis.claw.gradle
|
||||||
|
|
||||||
|
import dev.msfjarvis.claw.gradle.KotlinCommonPlugin.Companion.JVM_TOOLCHAIN_ACTION
|
||||||
import org.gradle.api.Plugin
|
import org.gradle.api.Plugin
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.kotlin.dsl.apply
|
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
|
import org.jetbrains.kotlin.gradle.plugin.KotlinAndroidPluginWrapper
|
||||||
|
|
||||||
@Suppress("Unused")
|
@Suppress("Unused")
|
||||||
|
@ -19,5 +22,6 @@ class KotlinAndroidPlugin : Plugin<Project> {
|
||||||
apply(KotlinAndroidPluginWrapper::class)
|
apply(KotlinAndroidPluginWrapper::class)
|
||||||
apply(KotlinCommonPlugin::class)
|
apply(KotlinCommonPlugin::class)
|
||||||
}
|
}
|
||||||
|
project.extensions.getByType<KotlinProjectExtension>().jvmToolchain(JVM_TOOLCHAIN_ACTION)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,16 +6,16 @@
|
||||||
*/
|
*/
|
||||||
package dev.msfjarvis.claw.gradle
|
package dev.msfjarvis.claw.gradle
|
||||||
|
|
||||||
import org.gradle.api.JavaVersion
|
import org.gradle.api.Action
|
||||||
import org.gradle.api.Plugin
|
import org.gradle.api.Plugin
|
||||||
import org.gradle.api.Project
|
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.Test
|
||||||
import org.gradle.api.tasks.testing.logging.TestLogEvent
|
import org.gradle.api.tasks.testing.logging.TestLogEvent
|
||||||
|
import org.gradle.jvm.toolchain.JavaLanguageVersion
|
||||||
|
import org.gradle.jvm.toolchain.JavaToolchainSpec
|
||||||
import org.gradle.kotlin.dsl.withType
|
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.dsl.KotlinVersion
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
@Suppress("Unused")
|
@Suppress("Unused")
|
||||||
class KotlinCommonPlugin : Plugin<Project> {
|
class KotlinCommonPlugin : Plugin<Project> {
|
||||||
|
@ -27,18 +27,11 @@ class KotlinCommonPlugin : Plugin<Project> {
|
||||||
LintConfig.configureSubProject(project)
|
LintConfig.configureSubProject(project)
|
||||||
}
|
}
|
||||||
project.tasks.run {
|
project.tasks.run {
|
||||||
withType<JavaCompile>().configureEach {
|
withType<KotlinCompile>().configureEach {
|
||||||
sourceCompatibility = JavaVersion.VERSION_17.toString()
|
|
||||||
targetCompatibility = JavaVersion.VERSION_17.toString()
|
|
||||||
}
|
|
||||||
withType<KotlinJvmCompile>().configureEach {
|
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
allWarningsAsErrors.set(
|
allWarningsAsErrors.set(true)
|
||||||
project.providers.environmentVariable("GITHUB_WORKFLOW").isPresent
|
|
||||||
)
|
|
||||||
jvmTarget.set(JvmTarget.JVM_17)
|
|
||||||
freeCompilerArgs.addAll(ADDITIONAL_COMPILER_ARGS)
|
freeCompilerArgs.addAll(ADDITIONAL_COMPILER_ARGS)
|
||||||
languageVersion.set(KotlinVersion.KOTLIN_1_7)
|
languageVersion.set(KotlinVersion.KOTLIN_1_8)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
withType<Test>().configureEach {
|
withType<Test>().configureEach {
|
||||||
|
@ -49,10 +42,13 @@ class KotlinCommonPlugin : Plugin<Project> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private companion object {
|
companion object {
|
||||||
private val ADDITIONAL_COMPILER_ARGS =
|
private val ADDITIONAL_COMPILER_ARGS =
|
||||||
listOf(
|
listOf(
|
||||||
"-opt-in=kotlin.RequiresOptIn",
|
"-opt-in=kotlin.RequiresOptIn",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val JVM_TOOLCHAIN_ACTION =
|
||||||
|
Action<JavaToolchainSpec> { languageVersion.set(JavaLanguageVersion.of(17)) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,19 +8,25 @@ package dev.msfjarvis.claw.gradle
|
||||||
|
|
||||||
import com.android.build.api.dsl.Lint
|
import com.android.build.api.dsl.Lint
|
||||||
import com.android.build.gradle.LintPlugin
|
import com.android.build.gradle.LintPlugin
|
||||||
|
import dev.msfjarvis.claw.gradle.KotlinCommonPlugin.Companion.JVM_TOOLCHAIN_ACTION
|
||||||
import dev.msfjarvis.claw.gradle.LintConfig.configureLint
|
import dev.msfjarvis.claw.gradle.LintConfig.configureLint
|
||||||
import org.gradle.api.Plugin
|
import org.gradle.api.Plugin
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.kotlin.dsl.apply
|
import org.gradle.kotlin.dsl.apply
|
||||||
import org.gradle.kotlin.dsl.findByType
|
import org.gradle.kotlin.dsl.findByType
|
||||||
|
import org.gradle.kotlin.dsl.getByType
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPluginWrapper
|
import org.jetbrains.kotlin.gradle.plugin.KotlinPluginWrapper
|
||||||
|
|
||||||
@Suppress("Unused")
|
@Suppress("Unused")
|
||||||
class KotlinJvmPlugin : Plugin<Project> {
|
class KotlinJvmPlugin : Plugin<Project> {
|
||||||
override fun apply(project: Project) {
|
override fun apply(project: Project) {
|
||||||
project.pluginManager.apply(KotlinPluginWrapper::class)
|
project.pluginManager.run {
|
||||||
project.pluginManager.apply(LintPlugin::class)
|
apply(KotlinPluginWrapper::class)
|
||||||
|
apply(LintPlugin::class)
|
||||||
|
apply(KotlinCommonPlugin::class)
|
||||||
|
}
|
||||||
project.extensions.findByType<Lint>()?.configureLint(project, isJVM = true)
|
project.extensions.findByType<Lint>()?.configureLint(project, isJVM = true)
|
||||||
project.pluginManager.apply(KotlinCommonPlugin::class)
|
project.extensions.getByType<KotlinProjectExtension>().jvmToolchain(JVM_TOOLCHAIN_ACTION)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
@file:Suppress("UnstableApiUsage")
|
@file:Suppress("UnstableApiUsage")
|
||||||
|
|
||||||
pluginManagement {
|
pluginManagement {
|
||||||
|
plugins { id("org.gradle.toolchains.foojay-resolver-convention") version "0.5.0" }
|
||||||
repositories {
|
repositories {
|
||||||
exclusiveContent {
|
exclusiveContent {
|
||||||
forRepository { google() }
|
forRepository { google() }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue