Skip to content

Commit 3b1e82b

Browse files
committed
[WIP] migrate group id with constraints
1 parent 42c8e5d commit 3b1e82b

File tree

10 files changed

+160
-4
lines changed

10 files changed

+160
-4
lines changed

assertk/build.gradle.kts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,14 @@ kotlin {
6161
}
6262
}
6363
}
64+
65+
dependencies {
66+
constraints {
67+
commonMainImplementation("com.willowtreeapps.assertk:assert:${rootProject.version}") {
68+
because("groupId migration")
69+
}
70+
commonMainApi("com.willowtreeapps.assertk:assert:${rootProject.version}") {
71+
because("groupId migration")
72+
}
73+
}
74+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import org.gradle.api.Project
2+
import org.gradle.api.publish.maven.MavenPublication
3+
4+
// Copyright (C) 2018 Vanniktech - Niklas Baudy
5+
//Licensed under the Apache License, Version 2.0
6+
fun forMultiplatform(artifactId: String, publication: MavenPublication, project: Project): String {
7+
val projectName = project.name
8+
return if (publication.artifactId == projectName) {
9+
artifactId
10+
} else if (publication.artifactId.startsWith("$projectName-")) {
11+
// Publications for specific platform targets use derived artifact ids (e.g. library, library-jvm,
12+
// library-js) and the suffix needs to be preserved
13+
publication.artifactId.replace("$projectName-", "$artifactId-")
14+
} else {
15+
throw IllegalStateException(
16+
"The plugin can't handle the publication ${publication.name} artifactId " +
17+
"${publication.artifactId} in project $projectName",
18+
)
19+
}
20+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
plugins {
2+
`maven-publish`
3+
signing
4+
}
5+
6+
group = "com.willowtreeapps.assertk"
7+
version = rootProject.version
8+
9+
repositories {
10+
mavenCentral()
11+
}
12+
13+
val emptyJavadocJar by tasks.registering(Jar::class) {
14+
archiveClassifier.set("javadoc")
15+
}
16+
17+
publishing {
18+
publications.all {
19+
if (this is MavenPublication) {
20+
artifact(emptyJavadocJar)
21+
22+
val siteUrl = "https://github.com/assertk-org/assertk"
23+
val gitUrl = "https://github.com/assertk-org/assertk.git"
24+
25+
pom {
26+
name.set(project.name)
27+
description.set("Assertions for Kotlin inspired by assertj")
28+
url.set(siteUrl)
29+
30+
scm {
31+
url.set(siteUrl)
32+
connection.set(gitUrl)
33+
developerConnection.set(gitUrl)
34+
}
35+
36+
licenses {
37+
license {
38+
name.set("The Apache Software License, Version 2.0")
39+
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
40+
distribution.set("repo")
41+
}
42+
}
43+
44+
developers {
45+
developer {
46+
id.set("evant")
47+
name.set("Eva Tatarka")
48+
}
49+
}
50+
}
51+
}
52+
}
53+
}
54+
55+
signing {
56+
setRequired {
57+
findProperty("signing.keyId") != null
58+
}
59+
publishing.publications.all { sign(this) }
60+
}
61+
62+
// TODO: remove after https://youtrack.jetbrains.com/issue/KT-46466 is fixed
63+
project.tasks.withType(AbstractPublishToMaven::class.java).configureEach {
64+
dependsOn(project.tasks.withType(Sign::class.java))
65+
}

buildSrc/src/main/kotlin/assertk.publish.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ tasks.withType<DokkaTask>().configureEach {
1818
// Set source links to github
1919
sourceLink {
2020
localDirectory.set(file("src"))
21-
remoteUrl.set(java.net.URL("https://github.com/willowtreeapps/assertk/tree/v${project.version}/${project.name}/src"))
21+
remoteUrl.set(java.net.URL("https://github.com/assertk-org/assertk"))
2222
remoteLineSuffix.set("#L")
2323
}
2424
}
@@ -42,8 +42,8 @@ publishing {
4242
if (this is MavenPublication) {
4343
artifact(dokkaJavadocCommonJar)
4444

45-
val siteUrl = "https://github.com/willowtreeapps/assertk"
46-
val gitUrl = "https://github.com/willowtreeapps/assertk.git"
45+
val siteUrl = "https://github.com/assertk-org/assertk"
46+
val gitUrl = "https://github.com/assertk-org/assertk.git"
4747

4848
pom {
4949
name.set(project.name)

migration/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Empty artifact for migrating from com.willowtreeaps.assertk to org.assertk
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
plugins {
2+
id("assertk.multiplatform")
3+
id("assertk.migration")
4+
}
5+
6+
repositories {
7+
mavenLocal()
8+
}
9+
10+
kotlin {
11+
sourceSets {
12+
commonMain {
13+
dependencies {
14+
implementation("org.assertk:assertk:${rootProject.version}")
15+
}
16+
}
17+
}
18+
}
19+
20+
publishing {
21+
publications.all {
22+
if (this is MavenPublication) {
23+
artifactId = forMultiplatform("assertk-coroutines", this, project)
24+
}
25+
}
26+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package assertk

migration/assertk/build.gradle.kts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
plugins {
2+
id("assertk.multiplatform")
3+
id("assertk.migration")
4+
}
5+
6+
repositories {
7+
mavenLocal()
8+
}
9+
10+
kotlin {
11+
sourceSets {
12+
commonMain {
13+
dependencies {
14+
implementation("org.assertk:assertk:${rootProject.version}")
15+
}
16+
}
17+
}
18+
}
19+
20+
publishing {
21+
publications.all {
22+
if (this is MavenPublication) {
23+
artifactId = forMultiplatform("assertk", this, project)
24+
}
25+
}
26+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package assertk

settings.gradle.kts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,9 @@ rootProject.name = "assertk-project"
1111
include(
1212
":assertk",
1313
":assertk-coroutines",
14-
)
14+
":migration-assertk",
15+
":migration-assertk-coroutines"
16+
)
17+
18+
project(":migration-assertk").projectDir = file("migration/assertk")
19+
project(":migration-assertk-coroutines").projectDir = file("migration/assertk-coroutines")

0 commit comments

Comments
 (0)