bump gradle version. gradle build scripts tidy up. Make versions more consistent, share some config

This commit is contained in:
Adam 2022-02-09 11:53:58 +01:00
parent 11cbb89821
commit 96412bf7c9
13 changed files with 3752 additions and 61 deletions

View file

@ -7,36 +7,54 @@ plugins {
`project-report`
}
object Versions {
const val jvmTarget = "11"
const val kotlinTarget = "1.6"
const val gradleNodePlugin = "3.2.0"
const val gradleDockerComposePlugin = "0.15.0"
const val kotlin = "1.6.10"
const val kotlinXSerialization = "1.3.2"
const val kvision = "5.8.1"
const val semver = "1.1.2"
const val kotest = "5.1.0"
}
dependencies {
val kotlinVersion = "1.6.10"
implementation(enforcedPlatform("org.jetbrains.kotlin:kotlin-bom:$kotlinVersion"))
implementation(enforcedPlatform("org.jetbrains.kotlin:kotlin-bom:${Versions.kotlin}"))
implementation("org.jetbrains.kotlin:kotlin-serialization")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.kotlin}")
val kotlinXSerializationVersion = "1.3.2"
implementation(enforcedPlatform("org.jetbrains.kotlinx:kotlinx-serialization-bom:$kotlinXSerializationVersion"))
implementation(enforcedPlatform("org.jetbrains.kotlinx:kotlinx-serialization-bom:${Versions.kotlinXSerialization}"))
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json")
// implementation("com.charleskorn.kaml:kaml:0.37.0")
implementation("com.github.node-gradle:gradle-node-plugin:3.1.1")
implementation("com.github.node-gradle:gradle-node-plugin:${Versions.gradleNodePlugin}")
implementation("net.swiftzer.semver:semver:1.1.2")
implementation("io.kotest:kotest-framework-multiplatform-plugin-gradle:${Versions.kotest}")
implementation("io.kvision:io.kvision.gradle.plugin:${Versions.kvision}")
implementation("net.swiftzer.semver:semver:${Versions.semver}")
// https://github.com/avast/gradle-docker-compose-plugin
implementation("com.avast.gradle:gradle-docker-compose-plugin:0.14.12")
implementation("com.avast.gradle:gradle-docker-compose-plugin:${Versions.gradleDockerComposePlugin}")
}
val projectJvmTarget = "11"
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = projectJvmTarget
apiVersion = "1.6"
languageVersion = "1.6"
jvmTarget = Versions.jvmTarget
apiVersion = Versions.kotlinTarget
languageVersion = Versions.kotlinTarget
}
kotlinOptions.freeCompilerArgs += listOf(
@ -50,11 +68,11 @@ tasks.withType<KotlinCompile>().configureEach {
kotlin {
jvmToolchain {
(this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(projectJvmTarget))
(this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(Versions.jvmTarget))
}
kotlinDslPluginOptions {
jvmTarget.set(projectJvmTarget)
jvmTarget.set(Versions.jvmTarget)
}
}

View file

@ -0,0 +1,13 @@
object Versions {
const val kotlinLang = "1.6"
const val jvmTarget = "11"
const val node = "14.19.0"
const val kotlinWrappers = "0.0.1-pre.294-kotlin-1.6.10"
const val junit = "5.8.2"
const val kotest = "5.1.0"
const val mockk = "1.12.1"
}

View file

@ -1,8 +1,25 @@
package dev.adamko.kafkatorio
import kotlinx.serialization.json.Json
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension
val jsonMapper = Json {
prettyPrint = true
prettyPrintIndent = " "
}
/**
* `kotlin-js` adds a directory in the root-dir for the Yarn lock.
* That's a bit annoying. It's a little neater if it's in the
* gradle dir, next to the version-catalog.
*/
fun Project.relocateKotlinJsStore() {
afterEvaluate {
rootProject.extensions.configure<YarnRootExtension> {
lockFileDirectory = rootProject.rootDir.resolve("gradle/kotlin-js-store")
}
}
}

View file

@ -1,8 +1,9 @@
package dev.adamko.kafkatorio.lang
import Versions
import dev.adamko.kafkatorio.relocateKotlinJsStore
import org.jetbrains.kotlin.gradle.targets.js.npm.NpmProject
import org.jetbrains.kotlin.gradle.targets.js.npm.tasks.RootPackageJsonTask
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension
plugins {
@ -11,10 +12,9 @@ plugins {
}
dependencies {
val kotlinWrappersVersion = "0.0.1-pre.276-kotlin-1.6.0"
implementation(
project.dependencies.platform(
"org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:${kotlinWrappersVersion}"
"org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:${Versions.kotlinWrappers}"
)
)
}
@ -42,9 +42,4 @@ val nodeModulesDir: Directory by extra {
file
}
rootProject.extensions.configure<YarnRootExtension> {
// kotlin-js adds a directory in the root-dir for the Yarn lock.
// That's a bit annoying. It's a little neater if it's in the
// gradle dir, next to the version-catalog.
lockFileDirectory = rootProject.rootDir.resolve("gradle/kotlin-js-store")
}
relocateKotlinJsStore()

View file

@ -9,7 +9,7 @@ plugins {
kotlin {
jvmToolchain {
(this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(11))
(this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(Versions.jvmTarget))
}
}
@ -17,30 +17,28 @@ dependencies {
implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
val junitVersion = "5.8.2"
testImplementation(platform("org.junit:junit-bom:$junitVersion"))
testImplementation(platform("org.junit:junit-bom:${Versions.junit}"))
testImplementation("org.junit.jupiter:junit-jupiter")
testRuntimeOnly("org.junit.platform:junit-platform-launcher") {
because("Only needed to run tests in a version of IntelliJ IDEA that bundles older versions")
}
val kotestVersion = "5.0.3"
testImplementation(platform("io.kotest:kotest-bom:$kotestVersion"))
testImplementation(platform("io.kotest:kotest-bom:${Versions.kotest}"))
testImplementation("io.kotest:kotest-runner-junit5")
testImplementation("io.kotest:kotest-assertions-core")
testImplementation("io.kotest:kotest-property")
testImplementation("io.kotest:kotest-assertions-json")
testImplementation("io.mockk:mockk:1.12.1")
testImplementation("io.mockk:mockk:${Versions.mockk}")
}
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = "11"
apiVersion = "1.6"
languageVersion = "1.6"
jvmTarget = Versions.jvmTarget
apiVersion = Versions.kotlinLang
languageVersion = Versions.kotlinLang
}
kotlinOptions.freeCompilerArgs += listOf(

View file

@ -1,9 +1,6 @@
package dev.adamko.kafkatorio.lang
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.kotlin
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension
import dev.adamko.kafkatorio.relocateKotlinJsStore
plugins {
@ -13,21 +10,4 @@ plugins {
}
afterEvaluate {
rootProject.extensions.configure<NodeJsRootExtension> {
val projectNodeInstallDir = file("$rootDir/.gradle").resolve("nodejs")
if (installationDir != projectNodeInstallDir) {
installationDir = projectNodeInstallDir
}
}
rootProject.extensions.configure<YarnRootExtension> {
// kotlin-js adds a directory in the root-dir for the Yarn lock.
// That's a bit annoying. It's a little neater if it's in the
// gradle dir, next to the version-catalog.
lockFileDirectory = rootProject.rootDir.resolve("gradle/kotlin-js-store")
}
}
relocateKotlinJsStore()

View file

@ -1,5 +1,6 @@
package dev.adamko.kafkatorio.lang
import Versions
import com.github.gradle.node.NodePlugin
import com.github.gradle.node.npm.task.NpmInstallTask
import dev.adamko.kafkatorio.gradle.areJsonPropertiesUpToDate
@ -20,7 +21,7 @@ plugins {
node {
download.set(true)
version.set("14.18.0")
version.set(Versions.node)
distBaseUrl.set(null as String?) // set by dependencyResolutionManagement
}
@ -56,6 +57,7 @@ val updatePackageJson by tasks.registering(UpdatePackageJson::class) {
}
tasks.assemble { dependsOn(updatePackageJson) }
tasks.withType<NpmInstallTask> {
dependsOn(updatePackageJson)
}