From ea8df7e85abb85d14deff59dd056357bb5700feb Mon Sep 17 00:00:00 2001 From: Goooler Date: Thu, 5 Oct 2023 02:22:21 -0500 Subject: [PATCH] Simple property assignments in KTS (#2123) * Simple property assignments in KTS https://blog.gradle.org/simpler-kotlin-dsl-property-assignment * Fix conflicts --- build-logic/build.gradle.kts | 4 ++-- .../src/main/kotlin/ktlint-dokka.gradle.kts | 4 ++-- .../kotlin/ktlint-kotlin-common.gradle.kts | 4 ++-- .../main/kotlin/ktlint-publication.gradle.kts | 22 +++++++++---------- build.gradle.kts | 4 ++-- ktlint-cli/build.gradle.kts | 10 ++++----- ktlint-ruleset-template/build.gradle.kts | 12 +++++----- settings.gradle.kts | 2 +- 8 files changed, 31 insertions(+), 31 deletions(-) diff --git a/build-logic/build.gradle.kts b/build-logic/build.gradle.kts index 40848334f7..5871911a1f 100644 --- a/build-logic/build.gradle.kts +++ b/build-logic/build.gradle.kts @@ -25,11 +25,11 @@ kotlin { // @see https://github.com/pinterest/ktlint/pull/2120#discussion_r1260229055 for more details val buildLogicTargetJavaVersion = JavaVersion.VERSION_17 tasks.withType().configureEach { - options.release.set(buildLogicTargetJavaVersion.majorVersion.toInt()) + options.release = buildLogicTargetJavaVersion.majorVersion.toInt() } tasks.withType().configureEach { // Convert Java version (e.g. "1.8" or "11") to Kotlin JvmTarget ("8" resp. "11") - compilerOptions.jvmTarget.set(JvmTarget.fromTarget(buildLogicTargetJavaVersion.toString())) + compilerOptions.jvmTarget = JvmTarget.fromTarget(buildLogicTargetJavaVersion.toString()) } dependencies { diff --git a/build-logic/src/main/kotlin/ktlint-dokka.gradle.kts b/build-logic/src/main/kotlin/ktlint-dokka.gradle.kts index f1edc97255..cd95014d5d 100644 --- a/build-logic/src/main/kotlin/ktlint-dokka.gradle.kts +++ b/build-logic/src/main/kotlin/ktlint-dokka.gradle.kts @@ -10,11 +10,11 @@ java { tasks.dokkaJavadoc { notCompatibleWithConfigurationCache("https://github.com/Kotlin/dokka/issues/1217") - outputDirectory.set(buildDir.resolve("javadoc")) + outputDirectory = buildDir.resolve("javadoc") } tasks.named("javadocJar") { dependsOn(tasks.dokkaJavadoc) - archiveClassifier.set("javadoc") + archiveClassifier = "javadoc" from(tasks.dokkaJavadoc) } diff --git a/build-logic/src/main/kotlin/ktlint-kotlin-common.gradle.kts b/build-logic/src/main/kotlin/ktlint-kotlin-common.gradle.kts index 00143f52bc..8711cbcd8f 100644 --- a/build-logic/src/main/kotlin/ktlint-kotlin-common.gradle.kts +++ b/build-logic/src/main/kotlin/ktlint-kotlin-common.gradle.kts @@ -17,11 +17,11 @@ kotlin { } tasks.withType().configureEach { - options.release.set(javaTargetVersion.asInt()) + options.release = javaTargetVersion.asInt() } tasks.withType().configureEach { // Convert Java version (e.g. "1.8" or "11") to Kotlin JvmTarget ("8" resp. "11") - compilerOptions.jvmTarget.set(JvmTarget.fromTarget(JavaVersion.toVersion(javaTargetVersion).toString())) + compilerOptions.jvmTarget = JvmTarget.fromTarget(JavaVersion.toVersion(javaTargetVersion).toString()) } val requestedJdkVersion = project.findProperty("testJdkVersion")?.toString()?.toInt() diff --git a/build-logic/src/main/kotlin/ktlint-publication.gradle.kts b/build-logic/src/main/kotlin/ktlint-publication.gradle.kts index a296f9d2d7..b7ab03d08c 100644 --- a/build-logic/src/main/kotlin/ktlint-publication.gradle.kts +++ b/build-logic/src/main/kotlin/ktlint-publication.gradle.kts @@ -24,26 +24,26 @@ publishing { artifactId = localGradleProperty("POM_ARTIFACT_ID").get() pom { - name.set(localGradleProperty("POM_NAME").get()) - description.set(providers.gradleProperty("POM_DESCRIPTION")) - url.set(providers.gradleProperty("POM_URL")) + name = localGradleProperty("POM_NAME") + description = providers.gradleProperty("POM_DESCRIPTION") + url = providers.gradleProperty("POM_URL") licenses { license { - name.set(providers.gradleProperty("POM_LICENSE_NAME")) - url.set(providers.gradleProperty("POM_LICENSE_URL")) - distribution.set("repo") + name = providers.gradleProperty("POM_LICENSE_NAME") + url = providers.gradleProperty("POM_LICENSE_URL") + distribution = "repo" } } developers { developer { - id.set(providers.gradleProperty("POM_DEVELOPER_ID")) - name.set(providers.gradleProperty("POM_DEVELOPER_NAME")) + id = providers.gradleProperty("POM_DEVELOPER_ID") + name = providers.gradleProperty("POM_DEVELOPER_NAME") } } scm { - url.set(providers.gradleProperty("POM_SCM_URL")) - connection.set(providers.gradleProperty("POM_SCM_CONNECTION")) - developerConnection.set(providers.gradleProperty("POM_SCM_DEV_CONNECTION")) + url = providers.gradleProperty("POM_SCM_URL") + connection = providers.gradleProperty("POM_SCM_CONNECTION") + developerConnection = providers.gradleProperty("POM_SCM_DEV_CONNECTION") } } } diff --git a/build.gradle.kts b/build.gradle.kts index 68722c2cf0..2d922be66d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -36,7 +36,7 @@ tasks.register("ktlintCheck") { group = LifecycleBasePlugin.VERIFICATION_GROUP description = "Check Kotlin code style" classpath = ktlint - mainClass.set("com.pinterest.ktlint.Main") + mainClass = "com.pinterest.ktlint.Main" args( "**/src/**/*.kt", "**.kts", @@ -50,7 +50,7 @@ tasks.register("ktlintFormat") { group = LifecycleBasePlugin.VERIFICATION_GROUP description = "Check Kotlin code style and format" classpath = ktlint - mainClass.set("com.pinterest.ktlint.Main") + mainClass = "com.pinterest.ktlint.Main" jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED") args( "-F", diff --git a/ktlint-cli/build.gradle.kts b/ktlint-cli/build.gradle.kts index 7ae89c8bcd..5d39720780 100644 --- a/ktlint-cli/build.gradle.kts +++ b/ktlint-cli/build.gradle.kts @@ -138,7 +138,7 @@ tasks.register("shadowJarExecutableChecksum") { .parentFile }, ) - checksumAlgorithm.set(Checksum.Algorithm.MD5) + checksumAlgorithm = Checksum.Algorithm.MD5 } tasks.withType().configureEach { @@ -167,8 +167,8 @@ tasks.withType().configureEach { sdkman { val sdkmanVersion = providers.environmentVariable("SDKMAN_VERSION").orElse(project.version.toString()) - candidate.set("ktlint") - version.set(sdkmanVersion) - url.set("https://github.com/pinterest/ktlint/releases/download/$sdkmanVersion/ktlint-$sdkmanVersion.zip") - hashtag.set("ktlint") + candidate = "ktlint" + version = sdkmanVersion + url = "https://github.com/pinterest/ktlint/releases/download/$sdkmanVersion/ktlint-$sdkmanVersion.zip" + hashtag = "ktlint" } diff --git a/ktlint-ruleset-template/build.gradle.kts b/ktlint-ruleset-template/build.gradle.kts index b000658607..1408a0b950 100644 --- a/ktlint-ruleset-template/build.gradle.kts +++ b/ktlint-ruleset-template/build.gradle.kts @@ -8,13 +8,13 @@ group = "com.github.username" val sourcesJar by tasks.registering(Jar::class) { dependsOn(tasks.classes) - archiveClassifier.set("sources") + archiveClassifier = "sources" from(sourceSets.main.map { it.allSource }) } val javadocJar by tasks.registering(Jar::class) { dependsOn(tasks.javadoc) - archiveClassifier.set("javadoc") + archiveClassifier = "javadoc" from(tasks.javadoc.map { it.destinationDir!! }) } @@ -38,7 +38,7 @@ dependencies { val ktlintCheck by tasks.registering(JavaExec::class) { dependsOn(tasks.classes) group = LifecycleBasePlugin.VERIFICATION_GROUP - mainClass.set("com.pinterest.ktlint.Main") + mainClass = "com.pinterest.ktlint.Main" // Adding compiled classes of this ruleset to the classpath so that ktlint validates the ruleset using its own ruleset classpath(ktlint, sourceSets.main.map { it.output }) args("--log-level=debug", "src/**/*.kt") @@ -54,9 +54,9 @@ publishing { pom { licenses { license { - name.set("The Apache Software License, Version 2.0") - url.set("https://www.apache.org/licenses/LICENSE-2.0.txt") - distribution.set("repo") + name = "The Apache Software License, Version 2.0" + url = "https://www.apache.org/licenses/LICENSE-2.0.txt" + distribution = "repo" } } } diff --git a/settings.gradle.kts b/settings.gradle.kts index f0db0c3b25..a147144890 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -8,7 +8,7 @@ pluginManagement { } dependencyResolutionManagement { - repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositoriesMode = RepositoriesMode.FAIL_ON_PROJECT_REPOS repositories { mavenCentral() }