From c0c15e2129cf67137b0b35ade3e6de3277912756 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Thu, 27 Apr 2023 00:01:00 +0200 Subject: [PATCH 1/3] add relocation pom for removing -en_GB --- build.gradle.kts | 54 ++++++++++++++++++- .../atrium-fluent-en_GB/build.gradle.kts | 2 +- 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index d8a5195a87..bb1ebcbee5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -258,13 +258,63 @@ configure(subprojectsWithoutToolAndSmokeTestProjects) { apply(plugin = "ch.tutteli.gradle.plugins.dokka") apply(plugin = "ch.tutteli.gradle.plugins.publish") - project.extensions.getByType().apply { + extensions.getByType().apply { resetLicenses("EUPL-1.2") } + + val languageSuffixes = setOf("-en_GB", "-de_CH") + if (languageSuffixes.any { name.contains(it) }) { + extensions.getByType().apply { + val pubs = publications.toList() + publications { + pubs + .filterIsInstance() + .forEach { pub -> + val artifactIdWithoutLanguage = languageSuffixes.fold(pub.artifactId) { id, suffix -> + id.replace(suffix, "") + } + pub.artifactId = artifactIdWithoutLanguage + + //TODO 1.1.0 remove again, consider to rename the project-name and directory + // we did not have a -metadata jar before, so no need for a relocation publication + if (!pub.artifactId.endsWith("metadata")) { + val oldArtifactId = if (pub.artifactId == name) { + "$name-common" + } else if (pub.artifactId.endsWith("-jvm")) { + name + } else { + pub.artifactId + } + + pub.artifactId = artifactIdWithoutLanguage + + create("${pub.name}-relocation") { + pom { + // Old artifact coordinates + groupId = pub.groupId + artifactId = oldArtifactId + version = pub.version + + distributionManagement { + relocation { + // New artifact coordinates + groupId.set(pub.groupId) + artifactId.set(artifactIdWithoutLanguage) + version.set(pub.version) + message.set("artifactId has changed, removed -en_GB as we drop support for a translated report and jvm has now the suffix -jvm and common no longer has the suffix -common") + } + } + } + } + } + } + } + } + } } configure(subprojectsWithoutToolAndSmokeTestProjects) { - // we don't specify a module-info.java in specs (so far) +// we don't specify a module-info.java in specs (so far) if (name != "atrium-specs") { apply(plugin = "ch.tutteli.gradle.plugins.kotlin.module.info") } diff --git a/bundles/fluent-en_GB/atrium-fluent-en_GB/build.gradle.kts b/bundles/fluent-en_GB/atrium-fluent-en_GB/build.gradle.kts index a389af7661..0f49367bbd 100644 --- a/bundles/fluent-en_GB/atrium-fluent-en_GB/build.gradle.kts +++ b/bundles/fluent-en_GB/atrium-fluent-en_GB/build.gradle.kts @@ -9,7 +9,7 @@ kotlin { api(prefixedProject("translations-en_GB")) } } - val jvmMain by getting{ + val jvmMain by getting { dependencies { api(prefixedProject("verbs")) api(prefixedProject("api-fluent-en_GB")) From eb4549bca50cd18863222f0053a8f90119412ebe Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Fri, 28 Apr 2023 11:04:29 +0200 Subject: [PATCH 2/3] use `configure` instead of extensions.getByType --- build.gradle.kts | 10 +++++----- misc/tools/bc-tests/build.gradle.kts | 13 +++++++------ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index bb1ebcbee5..043b0adf2e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -81,7 +81,7 @@ val bundleSmokeTests = subprojects.asSequence().filter { val subprojectsWithoutToolProjects = subprojects - toolProjects val subprojectsWithoutToolAndSmokeTestProjects = subprojectsWithoutToolProjects - bundleSmokeTests -extensions.getByType().apply { +configure { modeSimple.set(false) } @@ -127,7 +127,7 @@ configure(multiplatformProjects) { .allowedTestTasksWithoutTests.set(listOf("jsNodeTest")) } - extensions.getByType().apply { + configure { jvm { // for module-info.java and Java sources in test withJava() @@ -187,7 +187,7 @@ configure(multiplatformProjects) { // needs to be in afterEvaluate for now because the tutteli-spek-plugin overwrites it by using useJunitPlatform which // apparently reconfigures the TestFramework (even if already useJunitPlatform was used, so it's more a setJUnitPlatformAsTestFramework) afterEvaluate { - project.extensions.getByType().apply { + configure { jvm { testRuns["test"].executionTask.configure { useJUnitPlatform { @@ -258,13 +258,13 @@ configure(subprojectsWithoutToolAndSmokeTestProjects) { apply(plugin = "ch.tutteli.gradle.plugins.dokka") apply(plugin = "ch.tutteli.gradle.plugins.publish") - extensions.getByType().apply { + configure { resetLicenses("EUPL-1.2") } val languageSuffixes = setOf("-en_GB", "-de_CH") if (languageSuffixes.any { name.contains(it) }) { - extensions.getByType().apply { + configure { val pubs = publications.toList() publications { pubs diff --git a/misc/tools/bc-tests/build.gradle.kts b/misc/tools/bc-tests/build.gradle.kts index 91f1589d12..b6cdce5d31 100644 --- a/misc/tools/bc-tests/build.gradle.kts +++ b/misc/tools/bc-tests/build.gradle.kts @@ -173,7 +173,7 @@ bcConfigs.forEach { (oldVersion, apis, pair) -> } configure(listOf(project(":bc-tests:$oldVersion-specs"))) { - extensions.getByType().apply { + configure { jvm() js().nodejs {} sourceSets { @@ -265,7 +265,7 @@ bcConfigs.forEach { (oldVersion, apis, pair) -> configure(listOf(project(":bc-tests:$oldVersion-api-$apiName-bbc"))) { apply(plugin = "ch.tutteli.gradle.plugins.junitjacoco") - extensions.getByType().apply { + configure { val confName = "confBbc" jvm { @@ -337,7 +337,7 @@ bcConfigs.forEach { (oldVersion, apis, pair) -> apply(plugin = "ch.tutteli.gradle.plugins.junitjacoco") - extensions.getByType().apply { + configure { js().nodejs {} @@ -453,15 +453,16 @@ fun Project.createJacocoReportTask( project(":atrium-translations-de_CH") ) } + else -> throw IllegalStateException("re-adjust jacoco task") } projects.forEach { - //TODO 1.1.0 simplify once all project use new MPP plugin + //TODO 1.1.0 simplify, all projects use now the new MPP plugin val sourceSetContainer = it.extensions.findByType() if (sourceSetContainer != null) { sourceSets(sourceSetContainer["main"]) } else { - it.extensions.getByType().sourceSets.forEach { kotlinSourceSet -> + it.the().sourceSets.forEach { kotlinSourceSet -> sourceDirectories.from(kotlinSourceSet.kotlin.srcDirs) } } @@ -479,7 +480,7 @@ fun Project.createJacocoReportTask( } } - extensions.getByType().apply { + configure { toolVersion = jacocoToolVersion this.applyTo(runTask) } From 84b6a052a94c158351bc88f970e122b60d14a844 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Fri, 28 Apr 2023 15:29:08 +0200 Subject: [PATCH 3/3] use withType instead of toList + foreach to create the relocation pom --- build.gradle.kts | 74 ++++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 043b0adf2e..91fe826ba2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -265,50 +265,50 @@ configure(subprojectsWithoutToolAndSmokeTestProjects) { val languageSuffixes = setOf("-en_GB", "-de_CH") if (languageSuffixes.any { name.contains(it) }) { configure { - val pubs = publications.toList() - publications { - pubs - .filterIsInstance() - .forEach { pub -> - val artifactIdWithoutLanguage = languageSuffixes.fold(pub.artifactId) { id, suffix -> - id.replace(suffix, "") + publications.withType() + .matching { !it.name.endsWith("-relocation") } + .all { + val artifactIdBeforeLanguageRemoval = artifactId + val artifactIdWithoutLanguage = languageSuffixes.fold(artifactId) { id, suffix -> + id.replace(suffix, "") + } + + // TODO 1.1.0 consider to remove en_GB from the project name + artifactId = artifactIdWithoutLanguage + + //TODO 1.1.0 remove again, consider to rename the project-name and directory + // we did not have a -metadata jar before, so no need for a relocation publication + if (!artifactId.endsWith("metadata")) { + val oldArtifactId = if (artifactIdBeforeLanguageRemoval == project.name) { + "${project.name}-common" + } else if (artifactId.endsWith("-jvm")) { + project.name + } else { + artifactIdBeforeLanguageRemoval } - pub.artifactId = artifactIdWithoutLanguage - - //TODO 1.1.0 remove again, consider to rename the project-name and directory - // we did not have a -metadata jar before, so no need for a relocation publication - if (!pub.artifactId.endsWith("metadata")) { - val oldArtifactId = if (pub.artifactId == name) { - "$name-common" - } else if (pub.artifactId.endsWith("-jvm")) { - name - } else { - pub.artifactId - } - pub.artifactId = artifactIdWithoutLanguage - - create("${pub.name}-relocation") { - pom { - // Old artifact coordinates - groupId = pub.groupId - artifactId = oldArtifactId - version = pub.version - - distributionManagement { - relocation { - // New artifact coordinates - groupId.set(pub.groupId) - artifactId.set(artifactIdWithoutLanguage) - version.set(pub.version) - message.set("artifactId has changed, removed -en_GB as we drop support for a translated report and jvm has now the suffix -jvm and common no longer has the suffix -common") - } + println("old: $oldArtifactId, new: $artifactId") + val pub = this + publications.register("${pub.name}-relocation") { + pom { + // Old artifact coordinates + groupId = pub.groupId + artifactId = oldArtifactId + version = pub.version + + distributionManagement { + relocation { + // New artifact coordinates + groupId.set(pub.groupId) + artifactId.set(artifactIdWithoutLanguage) + version.set(pub.version) + message.set("artifactId has changed, removed -en_GB as we drop support for a translated report and jvm has now the suffix -jvm and common no longer has the suffix -common") } } } } } - } + } } } }