diff --git a/assertk/build.gradle.kts b/assertk/build.gradle.kts index f95cf970..a544e6dd 100644 --- a/assertk/build.gradle.kts +++ b/assertk/build.gradle.kts @@ -61,3 +61,14 @@ kotlin { } } } + +dependencies { + constraints { + commonMainImplementation("com.willowtreeapps.assertk:assert:${rootProject.version}") { + because("groupId migration") + } + commonMainApi("com.willowtreeapps.assertk:assert:${rootProject.version}") { + because("groupId migration") + } + } +} diff --git a/buildSrc/src/main/kotlin/MigrationHelper.kt b/buildSrc/src/main/kotlin/MigrationHelper.kt new file mode 100644 index 00000000..a46f09d1 --- /dev/null +++ b/buildSrc/src/main/kotlin/MigrationHelper.kt @@ -0,0 +1,20 @@ +import org.gradle.api.Project +import org.gradle.api.publish.maven.MavenPublication + +// Copyright (C) 2018 Vanniktech - Niklas Baudy +//Licensed under the Apache License, Version 2.0 +fun forMultiplatform(artifactId: String, publication: MavenPublication, project: Project): String { + val projectName = project.name + return if (publication.artifactId == projectName) { + artifactId + } else if (publication.artifactId.startsWith("$projectName-")) { + // Publications for specific platform targets use derived artifact ids (e.g. library, library-jvm, + // library-js) and the suffix needs to be preserved + publication.artifactId.replace("$projectName-", "$artifactId-") + } else { + throw IllegalStateException( + "The plugin can't handle the publication ${publication.name} artifactId " + + "${publication.artifactId} in project $projectName", + ) + } +} diff --git a/buildSrc/src/main/kotlin/assertk.migration.gradle.kts b/buildSrc/src/main/kotlin/assertk.migration.gradle.kts new file mode 100644 index 00000000..c3b17acf --- /dev/null +++ b/buildSrc/src/main/kotlin/assertk.migration.gradle.kts @@ -0,0 +1,65 @@ +plugins { + `maven-publish` + signing +} + +group = "com.willowtreeapps.assertk" +version = rootProject.version + +repositories { + mavenCentral() +} + +val emptyJavadocJar by tasks.registering(Jar::class) { + archiveClassifier.set("javadoc") +} + +publishing { + publications.all { + if (this is MavenPublication) { + artifact(emptyJavadocJar) + + val siteUrl = "https://github.com/assertk-org/assertk" + val gitUrl = "https://github.com/assertk-org/assertk.git" + + pom { + name.set(project.name) + description.set("Assertions for Kotlin inspired by assertj") + url.set(siteUrl) + + scm { + url.set(siteUrl) + connection.set(gitUrl) + developerConnection.set(gitUrl) + } + + licenses { + license { + name.set("The Apache Software License, Version 2.0") + url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") + distribution.set("repo") + } + } + + developers { + developer { + id.set("evant") + name.set("Eva Tatarka") + } + } + } + } + } +} + +signing { + setRequired { + findProperty("signing.keyId") != null + } + publishing.publications.all { sign(this) } +} + +// TODO: remove after https://youtrack.jetbrains.com/issue/KT-46466 is fixed +project.tasks.withType(AbstractPublishToMaven::class.java).configureEach { + dependsOn(project.tasks.withType(Sign::class.java)) +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/assertk.publish.gradle.kts b/buildSrc/src/main/kotlin/assertk.publish.gradle.kts index ebe7531e..49270a67 100644 --- a/buildSrc/src/main/kotlin/assertk.publish.gradle.kts +++ b/buildSrc/src/main/kotlin/assertk.publish.gradle.kts @@ -18,7 +18,7 @@ tasks.withType().configureEach { // Set source links to github sourceLink { localDirectory.set(file("src")) - remoteUrl.set(java.net.URL("https://github.com/willowtreeapps/assertk/tree/v${project.version}/${project.name}/src")) + remoteUrl.set(java.net.URL("https://github.com/assertk-org/assertk")) remoteLineSuffix.set("#L") } } @@ -42,8 +42,8 @@ publishing { if (this is MavenPublication) { artifact(dokkaJavadocCommonJar) - val siteUrl = "https://github.com/willowtreeapps/assertk" - val gitUrl = "https://github.com/willowtreeapps/assertk.git" + val siteUrl = "https://github.com/assertk-org/assertk" + val gitUrl = "https://github.com/assertk-org/assertk.git" pom { name.set(project.name) diff --git a/migration/README.md b/migration/README.md new file mode 100644 index 00000000..513f6e03 --- /dev/null +++ b/migration/README.md @@ -0,0 +1 @@ +Empty artifact for migrating from com.willowtreeaps.assertk to org.assertk \ No newline at end of file diff --git a/migration/assertk-coroutines/build.gradle.kts b/migration/assertk-coroutines/build.gradle.kts new file mode 100644 index 00000000..74daaa1c --- /dev/null +++ b/migration/assertk-coroutines/build.gradle.kts @@ -0,0 +1,26 @@ +plugins { + id("assertk.multiplatform") + id("assertk.migration") +} + +repositories { + mavenLocal() +} + +kotlin { + sourceSets { + commonMain { + dependencies { + implementation("org.assertk:assertk:${rootProject.version}") + } + } + } +} + +publishing { + publications.all { + if (this is MavenPublication) { + artifactId = forMultiplatform("assertk-coroutines", this, project) + } + } +} \ No newline at end of file diff --git a/migration/assertk-coroutines/src/commonMain/kotlin/assertk/MigrationCoroutines.kt b/migration/assertk-coroutines/src/commonMain/kotlin/assertk/MigrationCoroutines.kt new file mode 100644 index 00000000..880c6084 --- /dev/null +++ b/migration/assertk-coroutines/src/commonMain/kotlin/assertk/MigrationCoroutines.kt @@ -0,0 +1 @@ +package assertk diff --git a/migration/assertk/build.gradle.kts b/migration/assertk/build.gradle.kts new file mode 100644 index 00000000..6da5d8e8 --- /dev/null +++ b/migration/assertk/build.gradle.kts @@ -0,0 +1,26 @@ +plugins { + id("assertk.multiplatform") + id("assertk.migration") +} + +repositories { + mavenLocal() +} + +kotlin { + sourceSets { + commonMain { + dependencies { + implementation("org.assertk:assertk:${rootProject.version}") + } + } + } +} + +publishing { + publications.all { + if (this is MavenPublication) { + artifactId = forMultiplatform("assertk", this, project) + } + } +} diff --git a/migration/assertk/src/commonMain/kotlin/assertk/Migration.kt b/migration/assertk/src/commonMain/kotlin/assertk/Migration.kt new file mode 100644 index 00000000..880c6084 --- /dev/null +++ b/migration/assertk/src/commonMain/kotlin/assertk/Migration.kt @@ -0,0 +1 @@ +package assertk diff --git a/settings.gradle.kts b/settings.gradle.kts index 97fb29f1..af7a9557 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -11,4 +11,9 @@ rootProject.name = "assertk-project" include( ":assertk", ":assertk-coroutines", -) \ No newline at end of file + ":migration-assertk", + ":migration-assertk-coroutines" +) + +project(":migration-assertk").projectDir = file("migration/assertk") +project(":migration-assertk-coroutines").projectDir = file("migration/assertk-coroutines")