Skip to content

Commit

Permalink
Merge pull request #1416 from robstoll/relocation-pom
Browse files Browse the repository at this point in the history
add relocation pom for removing -en_GB
  • Loading branch information
robstoll committed Apr 28, 2023
2 parents 128317a + 84b6a05 commit 5e4841e
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 12 deletions.
60 changes: 55 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ val bundleSmokeTests = subprojects.asSequence().filter {
val subprojectsWithoutToolProjects = subprojects - toolProjects
val subprojectsWithoutToolAndSmokeTestProjects = subprojectsWithoutToolProjects - bundleSmokeTests

extensions.getByType<ch.tutteli.gradle.plugins.dokka.DokkaPluginExtension>().apply {
configure<ch.tutteli.gradle.plugins.dokka.DokkaPluginExtension> {
modeSimple.set(false)
}

Expand Down Expand Up @@ -127,7 +127,7 @@ configure(multiplatformProjects) {
.allowedTestTasksWithoutTests.set(listOf("jsNodeTest"))
}

extensions.getByType<KotlinMultiplatformExtension>().apply {
configure<KotlinMultiplatformExtension> {
jvm {
// for module-info.java and Java sources in test
withJava()
Expand Down Expand Up @@ -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<KotlinMultiplatformExtension>().apply {
configure<KotlinMultiplatformExtension> {
jvm {
testRuns["test"].executionTask.configure {
useJUnitPlatform {
Expand Down Expand Up @@ -258,13 +258,63 @@ configure(subprojectsWithoutToolAndSmokeTestProjects) {
apply(plugin = "ch.tutteli.gradle.plugins.dokka")
apply(plugin = "ch.tutteli.gradle.plugins.publish")

project.extensions.getByType<ch.tutteli.gradle.plugins.publish.PublishPluginExtension>().apply {
configure<ch.tutteli.gradle.plugins.publish.PublishPluginExtension> {
resetLicenses("EUPL-1.2")
}

val languageSuffixes = setOf("-en_GB", "-de_CH")
if (languageSuffixes.any { name.contains(it) }) {
configure<PublishingExtension> {
publications.withType<MavenPublication>()
.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
}

println("old: $oldArtifactId, new: $artifactId")
val pub = this
publications.register<MavenPublication>("${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")
}
Expand Down
2 changes: 1 addition & 1 deletion bundles/fluent-en_GB/atrium-fluent-en_GB/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
13 changes: 7 additions & 6 deletions misc/tools/bc-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ bcConfigs.forEach { (oldVersion, apis, pair) ->
}

configure(listOf(project(":bc-tests:$oldVersion-specs"))) {
extensions.getByType<KotlinMultiplatformExtension>().apply {
configure<KotlinMultiplatformExtension> {
jvm()
js().nodejs {}
sourceSets {
Expand Down Expand Up @@ -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<KotlinMultiplatformExtension>().apply {
configure<KotlinMultiplatformExtension> {
val confName = "confBbc"

jvm {
Expand Down Expand Up @@ -337,7 +337,7 @@ bcConfigs.forEach { (oldVersion, apis, pair) ->

apply(plugin = "ch.tutteli.gradle.plugins.junitjacoco")

extensions.getByType<KotlinMultiplatformExtension>().apply {
configure<KotlinMultiplatformExtension> {

js().nodejs {}

Expand Down Expand Up @@ -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<SourceSetContainer>()
if (sourceSetContainer != null) {
sourceSets(sourceSetContainer["main"])
} else {
it.extensions.getByType<KotlinMultiplatformExtension>().sourceSets.forEach { kotlinSourceSet ->
it.the<KotlinMultiplatformExtension>().sourceSets.forEach { kotlinSourceSet ->
sourceDirectories.from(kotlinSourceSet.kotlin.srcDirs)
}
}
Expand All @@ -479,7 +480,7 @@ fun Project.createJacocoReportTask(
}
}

extensions.getByType<JacocoPluginExtension>().apply {
configure<JacocoPluginExtension> {
toolVersion = jacocoToolVersion
this.applyTo<JavaExec>(runTask)
}
Expand Down

0 comments on commit 5e4841e

Please sign in to comment.