From 12e37b6f1c9f42f2f02988b163383e78d64e6dad Mon Sep 17 00:00:00 2001 From: Severn Everett Date: Thu, 4 Apr 2024 11:54:45 +0200 Subject: [PATCH 1/6] Converted settings.gradle to settings.gradle.kts --- settings.gradle | 10 ---------- settings.gradle.kts | 11 +++++++++++ 2 files changed, 11 insertions(+), 10 deletions(-) delete mode 100644 settings.gradle create mode 100644 settings.gradle.kts diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 804646a..0000000 --- a/settings.gradle +++ /dev/null @@ -1,10 +0,0 @@ -pluginManagement { - repositories { - mavenCentral() - gradlePluginPortal() - } - plugins { - id 'org.jetbrains.kotlin.jvm' version kotlin_version - } -} -rootProject.name = 'kotlinx.team.infra' diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..9cacb65 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,11 @@ +pluginManagement { + repositories { + mavenCentral() + gradlePluginPortal() + } + plugins { + // TODO Re-introduce kotlin_version after upgrading Gradle + id("org.jetbrains.kotlin.jvm") version "1.5.0" + } +} +rootProject.name = "kotlinx.team.infra" From faadc7bbb957175ecf854edbac197178417caf50 Mon Sep 17 00:00:00 2001 From: Severn Everett Date: Thu, 4 Apr 2024 14:29:56 +0200 Subject: [PATCH 2/6] Converted build.gradle to build.gradle.kts --- build.gradle | 79 ---------------------------------------------- build.gradle.kts | 81 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 79 deletions(-) delete mode 100644 build.gradle create mode 100644 build.gradle.kts diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 4e1edfa..0000000 --- a/build.gradle +++ /dev/null @@ -1,79 +0,0 @@ -import java.nio.file.Files - -buildscript { - repositories { - mavenCentral() - } - dependencies { - classpath("org.jetbrains.kotlin:kotlin-sam-with-receiver:$kotlin_version") - } -} - -plugins { - id 'maven-publish' - id 'java-gradle-plugin' - id 'org.jetbrains.kotlin.jvm' -} -apply plugin: "kotlin-sam-with-receiver" - -// Load `local.properties` file, if it exists. You can put your spaceUser and spaceToken values there, that file is ignored by git -def localPropertiesFile = file("$project.rootDir/local.properties") -if (Files.exists(localPropertiesFile.toPath())) { - localPropertiesFile.withReader { reader -> - def localProperties = new Properties() - localProperties.load(reader) - localProperties.each { prop -> project.ext.set(prop.key, prop.value) } - } -} - -repositories { - mavenCentral() - gradlePluginPortal() -} - -gradlePlugin { - plugins { - teamInfraPlugin { - id = "kotlinx.team.infra" - implementationClass = "kotlinx.team.infra.InfraPlugin" - } - } -} - -sourceSets { - main { - kotlin.srcDirs = ['main/src'] - java.srcDirs = ['main/src'] - resources.srcDirs = ['main/resources'] - } - test { - kotlin.srcDirs = ['test/src'] - java.srcDirs = ['test/src'] - resources.srcDirs = ['test/resources'] - } -} - -dependencies { - api group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: kotlin_version - api group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib-jdk7', version: kotlin_version - api group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib-jdk8', version: kotlin_version - - compileOnly group: 'org.jetbrains.kotlin', name: 'kotlin-compiler', version: kotlin_version - compileOnly group: 'org.jetbrains.kotlin.multiplatform', name: 'org.jetbrains.kotlin.multiplatform.gradle.plugin', version: kotlin_version - - testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version" - testImplementation gradleTestKit() - testImplementation 'junit:junit:4.12' -} - -samWithReceiver { - annotation("org.gradle.api.HasImplicitReceiver") -} - -apply from: 'publish.gradle' - -if (project.hasProperty("teamcity")) { - gradle.taskGraph.beforeTask { - println("##teamcity[progressMessage 'Gradle: ${it.project.path}:${it.name}']") - } -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..0488cf2 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,81 @@ +import org.jetbrains.kotlin.samWithReceiver.gradle.SamWithReceiverExtension +import java.nio.file.Files +import java.util.Properties + +buildscript { + repositories { + mavenCentral() + } + dependencies { + // TODO Re-introduce kotlin_version after upgrading Gradle + classpath("org.jetbrains.kotlin:kotlin-sam-with-receiver:1.5.0") + } +} + +plugins { + id("maven-publish") + id("java-gradle-plugin") + id("org.jetbrains.kotlin.jvm") +} +apply(plugin = "kotlin-sam-with-receiver") + +// Load `local.properties` file, if it exists. You can put your spaceUser and spaceToken values there, that file is ignored by git +val localPropertiesFile = File("$project.rootDir/local.properties") +if (Files.exists(localPropertiesFile.toPath())) { + localPropertiesFile.reader().use { reader -> + val localProperties = Properties() + localProperties.load(reader) + localProperties.forEach { (key, value) -> project.ext.set(key.toString(), value) } + } +} + +repositories { + mavenCentral() + gradlePluginPortal() +} + +configure { + plugins { + create("teamInfraPlugin") { + id = "kotlinx.team.infra" + implementationClass = "kotlinx.team.infra.InfraPlugin" + } + } +} + +sourceSets { + getByName("main") { + java.srcDirs("main/src") + resources.srcDirs("main/resources") + } + getByName("test") { + java.srcDirs("test/src") + resources.srcDirs("test/resources") + } +} + +dependencies { + val kotlin_version = "1.5.0" + api("org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version") + api("org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version") + api("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version") + + compileOnly("org.jetbrains.kotlin:kotlin-compiler:$kotlin_version") + compileOnly("org.jetbrains.kotlin.multiplatform:org.jetbrains.kotlin.multiplatform.gradle.plugin:$kotlin_version") + + testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version") + testImplementation(gradleTestKit()) + testImplementation("junit:junit:4.12") +} + +configure { + annotation("org.gradle.api.HasImplicitReceiver") +} + +apply(from = "publish.gradle") + +if (project.hasProperty("teamcity")) { + gradle.taskGraph.beforeTask { + println("##teamcity[progressMessage 'Gradle: ${project.path}:$name']") + } +} From 26cd285314dd0f9729c7fa2824d9a91e605cd95c Mon Sep 17 00:00:00 2001 From: Severn Everett Date: Thu, 4 Apr 2024 16:29:39 +0200 Subject: [PATCH 3/6] Consolidating publish configuration in build.gradle.kts --- build.gradle.kts | 61 +++++++++++++++++++++++++++++++++++++++++++----- publish.gradle | 47 ------------------------------------- 2 files changed, 55 insertions(+), 53 deletions(-) delete mode 100644 publish.gradle diff --git a/build.gradle.kts b/build.gradle.kts index 0488cf2..3ca7a17 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,7 @@ import org.jetbrains.kotlin.samWithReceiver.gradle.SamWithReceiverExtension +import java.net.URI import java.nio.file.Files +import java.nio.file.Path import java.util.Properties buildscript { @@ -54,6 +56,59 @@ sourceSets { } } +configure { + annotation("org.gradle.api.HasImplicitReceiver") +} + +project.version = project.findProperty("releaseVersion") ?: project.version + +tasks.register("sourceJar") { + archiveClassifier.set("sources") + from(sourceSets.main.get().java.sourceDirectories) +} + +configure { + repositories { + maven { + name = "build" + url = Path.of(rootProject.buildDir.path, "maven").toUri() + } + maven { + name = "space" + url = URI.create("https://maven.pkg.jetbrains.space/kotlin/p/kotlinx/maven") + credentials { + username = project.findProperty("space.user") as? String + password = project.findProperty("space.token") as? String + } + } + } + + publications.configureEach { + if (this is MavenPublication) artifact(tasks["sourceJar"]) + } +} + +afterEvaluate { + tasks { + named("clean") { + publishing.repositories.forEach { repository -> + if (repository is MavenArtifactRepository && repository.name == "build") { + delete.add(repository.url) + } + } + } + + create("publishToBuildRepository") { + group = "publishing" + withType(PublishToMavenRepository::class.java) { + if (repository.name == "build") { + this@create.dependsOn(this) + } + } + } + } +} + dependencies { val kotlin_version = "1.5.0" api("org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version") @@ -68,12 +123,6 @@ dependencies { testImplementation("junit:junit:4.12") } -configure { - annotation("org.gradle.api.HasImplicitReceiver") -} - -apply(from = "publish.gradle") - if (project.hasProperty("teamcity")) { gradle.taskGraph.beforeTask { println("##teamcity[progressMessage 'Gradle: ${project.path}:$name']") diff --git a/publish.gradle b/publish.gradle deleted file mode 100644 index 0e825e3..0000000 --- a/publish.gradle +++ /dev/null @@ -1,47 +0,0 @@ -project.version = project.hasProperty('releaseVersion') ? project.property('releaseVersion') : project.version - -task sourceJar(type: Jar) { - archiveClassifier.set("sources") - from sourceSets.main.allJava.sourceDirectories -} - -publishing { - repositories { - maven { - name = 'build' - url = "$rootProject.buildDir/maven" - } - maven { - name = 'space' - url "https://maven.pkg.jetbrains.space/kotlin/p/kotlinx/maven" - credentials { - username = project.findProperty("space.user") - password = project.findProperty("space.token") - } - } - } - - publications.all { - it.artifact tasks.sourceJar - } -} - -afterEvaluate { - clean { - publishing.repositories.all { repository -> - if (repository.name == 'build') { - delete += repository.url - } - } - } - - task('publishToBuildRepository') { publish -> - group = 'publishing' - tasks.withType(PublishToMavenRepository) { task -> - if (task.repository.name == 'build') { - publish.dependsOn(task) - } - } - } -} - From 83f860e784bcacb969fe38e05f03040b7b386c1b Mon Sep 17 00:00:00 2001 From: Severn Everett Date: Thu, 4 Apr 2024 16:54:43 +0200 Subject: [PATCH 4/6] Consolidating Kotlin plugin configuration in build.gradle.kts --- build.gradle.kts | 19 +++++++++---------- gradle.properties | 2 +- settings.gradle.kts | 10 ---------- 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 3ca7a17..43f28c7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,16 +9,16 @@ buildscript { mavenCentral() } dependencies { - // TODO Re-introduce kotlin_version after upgrading Gradle - classpath("org.jetbrains.kotlin:kotlin-sam-with-receiver:1.5.0") + classpath("org.jetbrains.kotlin:kotlin-sam-with-receiver:${project.extra["kotlinVersion"]}") + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${project.extra["kotlinVersion"]}") } } plugins { id("maven-publish") id("java-gradle-plugin") - id("org.jetbrains.kotlin.jvm") } +apply(plugin = "org.jetbrains.kotlin.jvm") apply(plugin = "kotlin-sam-with-receiver") // Load `local.properties` file, if it exists. You can put your spaceUser and spaceToken values there, that file is ignored by git @@ -110,15 +110,14 @@ afterEvaluate { } dependencies { - val kotlin_version = "1.5.0" - api("org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version") - api("org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version") - api("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version") + api("org.jetbrains.kotlin:kotlin-stdlib") + api("org.jetbrains.kotlin:kotlin-stdlib-jdk7") + api("org.jetbrains.kotlin:kotlin-stdlib-jdk8") - compileOnly("org.jetbrains.kotlin:kotlin-compiler:$kotlin_version") - compileOnly("org.jetbrains.kotlin.multiplatform:org.jetbrains.kotlin.multiplatform.gradle.plugin:$kotlin_version") + compileOnly("org.jetbrains.kotlin:kotlin-compiler") + compileOnly("org.jetbrains.kotlin.multiplatform:org.jetbrains.kotlin.multiplatform.gradle.plugin:${project.extra["kotlinVersion"]}") - testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version") + testImplementation("org.jetbrains.kotlin:kotlin-test-junit") testImplementation(gradleTestKit()) testImplementation("junit:junit:4.12") } diff --git a/gradle.properties b/gradle.properties index a46d4fb..79bf376 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,4 +4,4 @@ kotlin.code.style=official version = 0.4.0 group = kotlinx.team -kotlin_version=1.5.0 +kotlinVersion=1.5.0 diff --git a/settings.gradle.kts b/settings.gradle.kts index 9cacb65..0ab02b7 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,11 +1 @@ -pluginManagement { - repositories { - mavenCentral() - gradlePluginPortal() - } - plugins { - // TODO Re-introduce kotlin_version after upgrading Gradle - id("org.jetbrains.kotlin.jvm") version "1.5.0" - } -} rootProject.name = "kotlinx.team.infra" From 6c1926dd9d62c22d92774f2e223888e5ebaf6497 Mon Sep 17 00:00:00 2001 From: Severn Everett Date: Fri, 5 Apr 2024 09:40:38 +0200 Subject: [PATCH 5/6] Upgrading Gradle to 8.7; Upgrading Kotlin to 1.9.23 --- build.gradle.kts | 12 ++-- gradle.properties | 2 +- gradle/wrapper/gradle-wrapper.properties | 3 +- main/src/kotlinx/team/infra/InfraPlugin.kt | 32 ++++++----- .../kotlinx/team/infra/NativeMultiplatform.kt | 16 ++++-- main/src/kotlinx/team/infra/Publishing.kt | 55 +++++++++++-------- main/src/kotlinx/team/infra/TeamCity.kt | 6 +- 7 files changed, 76 insertions(+), 50 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 43f28c7..14c1180 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -71,7 +71,7 @@ configure { repositories { maven { name = "build" - url = Path.of(rootProject.buildDir.path, "maven").toUri() + url = Path.of(rootProject.layout.buildDirectory.get().asFile.path, "maven").toUri() } maven { name = "space" @@ -117,13 +117,17 @@ dependencies { compileOnly("org.jetbrains.kotlin:kotlin-compiler") compileOnly("org.jetbrains.kotlin.multiplatform:org.jetbrains.kotlin.multiplatform.gradle.plugin:${project.extra["kotlinVersion"]}") + implementation("org.semver4j:semver4j:5.2.2") + testImplementation("org.jetbrains.kotlin:kotlin-test-junit") testImplementation(gradleTestKit()) - testImplementation("junit:junit:4.12") + testImplementation("junit:junit:4.13.2") } if (project.hasProperty("teamcity")) { - gradle.taskGraph.beforeTask { - println("##teamcity[progressMessage 'Gradle: ${project.path}:$name']") + gradle.taskGraph.whenReady { + tasks.forEach { task -> + task.doFirst { println("##teamcity[progressMessage 'Gradle: ${project.path}:${task.name}']") } + } } } diff --git a/gradle.properties b/gradle.properties index 79bf376..a916cee 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,4 +4,4 @@ kotlin.code.style=official version = 0.4.0 group = kotlinx.team -kotlinVersion=1.5.0 +kotlinVersion=1.9.23 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index be52383..61f9702 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionSha256Sum=544c35d6bd849ae8a5ed0bcea39ba677dc40f49df7d1835561582da2009b961d zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/main/src/kotlinx/team/infra/InfraPlugin.kt b/main/src/kotlinx/team/infra/InfraPlugin.kt index 06f8d4b..bedca80 100644 --- a/main/src/kotlinx/team/infra/InfraPlugin.kt +++ b/main/src/kotlinx/team/infra/InfraPlugin.kt @@ -1,17 +1,22 @@ package kotlinx.team.infra -import org.gradle.api.* -import org.gradle.util.* -import org.jetbrains.kotlin.gradle.plugin.* -import java.io.* -import java.nio.file.* +import org.gradle.api.GradleException +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.util.GradleVersion +import org.jetbrains.kotlin.gradle.plugin.KotlinBasePluginWrapper +import org.semver4j.Semver +import java.io.FileInputStream +import java.nio.file.Files +import java.nio.file.Paths import java.util.* +private const val REQUIRED_GRADLE_VERSION = "6.0" +private const val REQUIRED_KOTLIN_VERSION = "1.4.0" +private const val INFRA_EXTENSION_NAME = "infra" + @Suppress("unused") class InfraPlugin : Plugin { - private val requiredGradleVersion = "6.0" - private val requiredKotlinVersion = "1.4.0" - private val INFRA_EXTENSION_NAME = "infra" override fun apply(target: Project) = target.run { verifyGradleVersion() @@ -81,16 +86,17 @@ class InfraPlugin : Plugin { tryGetClass("org.jetbrains.kotlin.gradle.plugin.KotlinBasePluginWrapper") if (kotlinClass != null) { plugins.findPlugin(kotlinClass)?.run { - logger.infra("Detected Kotlin plugin version '$kotlinPluginVersion'") - if (VersionNumber.parse(kotlinPluginVersion) < VersionNumber.parse(requiredKotlinVersion)) - throw KotlinInfrastructureException("JetBrains Kotlin Infrastructure plugin requires Kotlin version $requiredKotlinVersion or higher") + logger.infra("Detected Kotlin plugin version '$pluginVersion'") + if (Semver(pluginVersion) < Semver(REQUIRED_KOTLIN_VERSION)) + throw KotlinInfrastructureException("JetBrains Kotlin Infrastructure plugin requires Kotlin version $REQUIRED_KOTLIN_VERSION or higher") } } } + @Suppress("UnusedReceiverParameter") private fun Project.verifyGradleVersion() { - if (GradleVersion.current() < GradleVersion.version(requiredGradleVersion)) - throw KotlinInfrastructureException("JetBrains Kotlin Infrastructure plugin requires Gradle version $requiredGradleVersion or higher") + if (GradleVersion.current() < GradleVersion.version(REQUIRED_GRADLE_VERSION)) + throw KotlinInfrastructureException("JetBrains Kotlin Infrastructure plugin requires Gradle version $REQUIRED_GRADLE_VERSION or higher") } } diff --git a/main/src/kotlinx/team/infra/NativeMultiplatform.kt b/main/src/kotlinx/team/infra/NativeMultiplatform.kt index c66bdeb..c0fae0e 100644 --- a/main/src/kotlinx/team/infra/NativeMultiplatform.kt +++ b/main/src/kotlinx/team/infra/NativeMultiplatform.kt @@ -48,20 +48,24 @@ abstract class NativeInfraExtension( commonMainSourceSet: KotlinSourceSet, commonTestSourceSet: KotlinSourceSet, ) { - protected val mainSourceSet = kotlin.sourceSets.maybeCreate("${sourceSetName}Main").apply { dependsOn(commonMainSourceSet) } - protected val testSourceSet = kotlin.sourceSets.maybeCreate("${sourceSetName}Test").apply { dependsOn(commonTestSourceSet) } + protected val mainSourceSet: KotlinSourceSet = kotlin.sourceSets + .maybeCreate("${sourceSetName}Main") + .apply { dependsOn(commonMainSourceSet) } + protected val testSourceSet: KotlinSourceSet = kotlin.sourceSets + .maybeCreate("${sourceSetName}Test") + .apply { dependsOn(commonTestSourceSet) } protected val sharedConfigs = mutableListOf Unit>() - fun shared(configure: Closure<*>) = shared { ConfigureUtil.configure(configure, this) } + fun shared(configure: Closure<*>) = shared { project.configure(this, configure) } fun shared(configure: KotlinNativeTarget.() -> Unit) { sharedConfigs.add(configure) } fun target(name: String) = target(name) { } - fun target(name: String, configure: Closure<*>) = target(name) { ConfigureUtil.configure(configure, this) } + fun target(name: String, configure: Closure<*>) = target(name) { project.configure(this, configure) } abstract fun target(name: String, configure: KotlinNativeTarget.() -> Unit) - fun common(name: String, configure: Closure<*>) = common(name) { ConfigureUtil.configure(configure, this) } + fun common(name: String, configure: Closure<*>) = common(name) { project.configure(this, configure) } abstract fun common(name: String, configure: NativeInfraExtension.() -> Unit) } @@ -130,7 +134,7 @@ class NativeBuildInfraExtension( val preset = nativePresets.singleOrNull { it.name == name } ?: return project.logger.infra("Creating target '${preset.name}' with dependency on '$sourceSetName'") - val target = kotlin.targetFromPreset(preset) { + kotlin.targetFromPreset(preset) { configure() sharedConfigs.forEach { config -> config() } } diff --git a/main/src/kotlinx/team/infra/Publishing.kt b/main/src/kotlinx/team/infra/Publishing.kt index baec4c8..dba564f 100644 --- a/main/src/kotlinx/team/infra/Publishing.kt +++ b/main/src/kotlinx/team/infra/Publishing.kt @@ -1,35 +1,44 @@ package kotlinx.team.infra -import groovy.lang.* -import org.gradle.api.* +import org.gradle.api.Action +import org.gradle.api.DefaultTask +import org.gradle.api.Project +import org.gradle.api.Task import org.gradle.api.model.ObjectFactory -import org.gradle.api.plugins.* -import org.gradle.api.publish.* +import org.gradle.api.plugins.ExtraPropertiesExtension +import org.gradle.api.publish.PublishingExtension import org.gradle.api.publish.maven.MavenPom import org.gradle.api.publish.maven.MavenPublication -import org.gradle.api.publish.maven.plugins.* -import org.gradle.api.publish.maven.tasks.* -import org.gradle.api.publish.plugins.* -import org.gradle.api.tasks.* +import org.gradle.api.publish.maven.plugins.MavenPublishPlugin +import org.gradle.api.publish.maven.tasks.AbstractPublishToMaven +import org.gradle.api.publish.maven.tasks.PublishToMavenRepository +import org.gradle.api.publish.plugins.PublishingPlugin +import org.gradle.api.tasks.Copy +import org.gradle.api.tasks.Delete +import org.gradle.api.tasks.TaskProvider import org.gradle.jvm.tasks.Jar import org.gradle.plugins.signing.SigningExtension import org.gradle.plugins.signing.SigningPlugin -import org.gradle.util.* -import java.net.* -import java.text.* -import java.util.* +import java.net.URI import javax.inject.Inject -open class PublishingConfiguration @Inject constructor(val objects: ObjectFactory) { +open class PublishingConfiguration @Inject constructor( + @Suppress("MemberVisibilityCanBePrivate") + val objects: ObjectFactory +) { var libraryRepoUrl: String? = null val sonatype = objects.newInstance() + + @Suppress("unused") fun sonatype(configure: Action) { configure.execute(sonatype) sonatype.isSelected = true } var includeProjects: MutableList = mutableListOf() + + @Suppress("unused") fun include(vararg name: String) { includeProjects.addAll(name) } @@ -60,10 +69,7 @@ fun Project.configureProjectVersion() { ext.set("infra.release", false) // Configure version val versionSuffix = project.findProperty("versionSuffix")?.toString() - if (versionSuffix != null && versionSuffix.isNotEmpty()) - "${project.version}-$versionSuffix" - else - project.version.toString() + if (!versionSuffix.isNullOrEmpty()) "${project.version}-$versionSuffix" else project.version.toString() } logger.infra("Configured root project version as '${project.version}'") @@ -71,7 +77,7 @@ fun Project.configureProjectVersion() { internal fun Project.configurePublishing(publishing: PublishingConfiguration) { val buildLocal = "buildLocal" - val compositeBuildLocal = "publishTo${buildLocal.capitalize()}" + val compositeBuildLocal = "publishTo${buildLocal.replaceFirstChar(Char::uppercaseChar)}" val rootBuildLocal = rootProject.tasks.maybeCreate(compositeBuildLocal).apply { group = PublishingPlugin.PUBLISH_TASK_GROUP } @@ -104,10 +110,12 @@ internal fun Project.configurePublishing(publishing: PublishingConfiguration) { gradle.includedBuilds.forEach { includedBuild -> logger.infra("Included build: ${includedBuild.name} from ${includedBuild.projectDir}") val includedPublishTask = includedBuild.task(":$compositeBuildLocal") - val includedName = includedBuild.name.split(".").joinToString(separator = "") { it.capitalize() } + val includedName = includedBuild.name + .split(".") + .joinToString(separator = "") { it.replaceFirstChar(Char::uppercaseChar) } val copyIncluded = task("copy${includedName}BuildLocal") { from(includedBuild.projectDir.resolve("build/maven")) - into(buildDir.resolve("maven")) + into(layout.buildDirectory.get().asFile.resolve("maven")) dependsOn(includedPublishTask) } rootBuildLocal.dependsOn(copyIncluded) @@ -123,10 +131,10 @@ private fun Project.applyMavenPublish() { } private fun Project.createBuildRepository(name: String, rootBuildLocal: Task) { - val dir = rootProject.buildDir.resolve("maven") + val dir = rootProject.layout.buildDirectory.get().asFile.resolve("maven") logger.infra("Enabling publishing to $name in $this") - val compositeTask = tasks.maybeCreate("publishTo${name.capitalize()}").apply { + val compositeTask = tasks.maybeCreate("publishTo${name.replaceFirstChar(Char::uppercaseChar)}").apply { group = PublishingPlugin.PUBLISH_TASK_GROUP description = "Publishes all Maven publications produced by this project to Maven repository '$name'" } @@ -228,6 +236,7 @@ private fun Project.configurePublications(publishing: PublishingConfiguration) { } } +@Suppress("unused") fun Project.mavenPublicationsPom(action: Action) { extensions.configure(PublishingExtension::class.java) { publications.configureEach { @@ -245,7 +254,7 @@ private fun MavenPublication.configureRequiredPomAttributes(project: Project, pu licenses { license { name.set("The Apache License, Version 2.0") - url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") + url.set("https://www.apache.org/licenses/LICENSE-2.0.txt") } } scm { diff --git a/main/src/kotlinx/team/infra/TeamCity.kt b/main/src/kotlinx/team/infra/TeamCity.kt index 966348b..5fef73b 100644 --- a/main/src/kotlinx/team/infra/TeamCity.kt +++ b/main/src/kotlinx/team/infra/TeamCity.kt @@ -20,8 +20,10 @@ open class TeamCityConfiguration { fun Project.configureTeamCityLogging() { if (project.hasProperty("teamcity")) { - gradle.taskGraph.beforeTask { - println("##teamcity[progressMessage 'Gradle: ${this.project.path}:${this.name}']") + gradle.taskGraph.whenReady { + tasks.forEach { task -> + task.doFirst { println("##teamcity[progressMessage 'Gradle: ${project.path}:${task.name}']") } + } } } } From 2fceaf1dc7fcdaa74f26617cf4181b204c05a4b6 Mon Sep 17 00:00:00 2001 From: Severn Everett Date: Tue, 9 Apr 2024 09:25:20 +0200 Subject: [PATCH 6/6] Reverting Gradle to 7.4.2 and Kotlin to 1.9.21; Updated project minimums in InfraPlugin.kt --- gradle.properties | 2 +- gradle/wrapper/gradle-wrapper.properties | 4 ++-- main/src/kotlinx/team/infra/InfraPlugin.kt | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gradle.properties b/gradle.properties index a916cee..191f98d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,4 +4,4 @@ kotlin.code.style=official version = 0.4.0 group = kotlinx.team -kotlinVersion=1.9.23 +kotlinVersion=1.9.21 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 61f9702..1730841 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip -distributionSha256Sum=544c35d6bd849ae8a5ed0bcea39ba677dc40f49df7d1835561582da2009b961d +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip +distributionSha256Sum=29e49b10984e585d8118b7d0bc452f944e386458df27371b49b4ac1dec4b7fda zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/main/src/kotlinx/team/infra/InfraPlugin.kt b/main/src/kotlinx/team/infra/InfraPlugin.kt index bedca80..3b5ed9c 100644 --- a/main/src/kotlinx/team/infra/InfraPlugin.kt +++ b/main/src/kotlinx/team/infra/InfraPlugin.kt @@ -11,8 +11,8 @@ import java.nio.file.Files import java.nio.file.Paths import java.util.* -private const val REQUIRED_GRADLE_VERSION = "6.0" -private const val REQUIRED_KOTLIN_VERSION = "1.4.0" +private const val REQUIRED_GRADLE_VERSION = "7.0" +private const val REQUIRED_KOTLIN_VERSION = "1.8.0" private const val INFRA_EXTENSION_NAME = "infra" @Suppress("unused")