diff --git a/buildSrc/src/main/kotlin/build-dependency-library-conventions.gradle.kts b/buildSrc/src/main/kotlin/build-dependency-library-conventions.gradle.kts index 35c05cb..78c8b31 100644 --- a/buildSrc/src/main/kotlin/build-dependency-library-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/build-dependency-library-conventions.gradle.kts @@ -13,4 +13,7 @@ group = "com.huanshankeji" java { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 + + withSourcesJar() + withJavadocJar() } diff --git a/buildSrc/src/main/kotlin/plugin-conventions.gradle.kts b/buildSrc/src/main/kotlin/plugin-conventions.gradle.kts index bb95c1e..b3038b4 100644 --- a/buildSrc/src/main/kotlin/plugin-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/plugin-conventions.gradle.kts @@ -8,7 +8,7 @@ dependencies { implementation(kotlin("gradle-plugin", "1.6.10")) } -version = "0.1.1-kotlin-1.6.10-SNAPSHOT" +version = "0.1.4-kotlin-1.6.10-SNAPSHOT" pluginBundle { website = "https://github.com/huanshankeji/gradle-plugin" diff --git a/common-gradle-dependencies/build.gradle.kts b/common-gradle-dependencies/build.gradle.kts index 1f31010..4f3e4c5 100644 --- a/common-gradle-dependencies/build.gradle.kts +++ b/common-gradle-dependencies/build.gradle.kts @@ -2,4 +2,6 @@ plugins { id("build-dependency-library-conventions") } -version = "0.1.0-20220522-kotlin-1.6.10" +// `SNAPSHOT` means it's under development until that version, +// and `dev` means it has been under development since that version. +version = "0.1.1-20220527-kotlin-1.6.10" diff --git a/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/CommonDependencies.kt b/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/CommonDependencies.kt index 914e372..69c7c3b 100644 --- a/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/CommonDependencies.kt +++ b/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/CommonDependencies.kt @@ -1,5 +1,7 @@ package com.huanshankeji +import org.gradle.api.artifacts.dsl.DependencyHandler + // some but not all default dependencies object CommonDependencies { object KotlinCommon { @@ -83,11 +85,18 @@ object CommonDependencies { object Vertx { val defaultVersion = DefaultVersions.vertx - fun stackDepchain(version: String = defaultVersion) = - "io.vertx:vertx-stack-depchain:$version" - fun module(module: String) = + private fun stackDepchain(version: String = defaultVersion) = + moduleWithVersion("stack-depchain", version) + + fun DependencyHandler.platformStackDepchain(version: String = defaultVersion) = + platform(stackDepchain(version)) + + fun moduleWithoutVersion(module: String) = "io.vertx:vertx-$module" + + fun moduleWithVersion(module: String, version: String = defaultVersion) = + "${moduleWithoutVersion(module)}:$version" } object Arrow { diff --git a/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/DefaultVersions.kt b/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/DefaultVersions.kt index 0de73df..ce1d6a3 100644 --- a/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/DefaultVersions.kt +++ b/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/DefaultVersions.kt @@ -3,7 +3,7 @@ package com.huanshankeji object DefaultVersions { val kotlin = "1.6.10" - val kotlinCommon = "0.1.0-kotlin-1.6.10" + val kotlinCommon = "0.1.1-kotlin-1.6.10" val exposed = "0.38.2" val kotlinxCoroutines = "1.6.1" diff --git a/kotlin-common-gradle-plugins/build.gradle.kts b/kotlin-common-gradle-plugins/build.gradle.kts index 20c8d87..ef6fa11 100644 --- a/kotlin-common-gradle-plugins/build.gradle.kts +++ b/kotlin-common-gradle-plugins/build.gradle.kts @@ -4,6 +4,7 @@ plugins { dependencies { //api(project(":common-gradle-dependencies")) + //implementation("io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.30.0") } gradlePlugin { @@ -38,5 +39,13 @@ gradlePlugin { "kotlin-multiplatform-jvm-and-js-browser-default-maven-publish-conventions", "Kotlin Multiplatform conventions with the JVM target and the JS browser target, and with default Maven publish" ) + scriptConventionsPlugin( + "kotlin-jvm-library-sonatype-ossrh-publish-conventions", + "Kotlin/JVM library conventions with Sonatype OSSRH Maven Central publish" + ) + scriptConventionsPlugin( + "kotlin-multiplatform-jvm-and-js-browser-sonatype-ossrh-publish-conventions", + "Kotlin Multiplatform conventions with the JVM target and the JS browser target, and with Sonatype OSSRH Maven Central publish" + ) } } diff --git a/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/default-maven-publish.gradle.kts b/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/default-maven-publish.gradle.kts index a07a221..31a7ffb 100644 --- a/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/default-maven-publish.gradle.kts +++ b/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/default-maven-publish.gradle.kts @@ -5,9 +5,3 @@ plugins { } group = "com.huanshankeji" - -publishing { - repositories { - mavenCentral() - } -} diff --git a/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-jvm-library-sonatype-ossrh-publish-conventions.gradle.kts b/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-jvm-library-sonatype-ossrh-publish-conventions.gradle.kts new file mode 100644 index 0000000..0c52912 --- /dev/null +++ b/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-jvm-library-sonatype-ossrh-publish-conventions.gradle.kts @@ -0,0 +1,6 @@ +package com.huanshankeji + +plugins { + id("com.huanshankeji.kotlin-jvm-library-default-maven-publish-conventions") + id("com.huanshankeji.sonatype-ossrh-publish") +} diff --git a/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-multiplatform-jvm-and-js-browser-default-maven-publish-conventions.gradle.kts b/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-multiplatform-jvm-and-js-browser-default-maven-publish-conventions.gradle.kts index e26cd75..7c8a756 100644 --- a/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-multiplatform-jvm-and-js-browser-default-maven-publish-conventions.gradle.kts +++ b/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-multiplatform-jvm-and-js-browser-default-maven-publish-conventions.gradle.kts @@ -5,10 +5,6 @@ plugins { id("com.huanshankeji.default-maven-publish") } -publishing { - publications { - withType { - artifactId = "$defaultPrefixForPublishing-$artifactId" - } - } +publishing.publications.withType { + artifactId = "$defaultPrefixForPublishing-$artifactId" } diff --git a/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-multiplatform-jvm-and-js-browser-sonatype-ossrh-publish-conventions.gradle.kts b/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-multiplatform-jvm-and-js-browser-sonatype-ossrh-publish-conventions.gradle.kts new file mode 100644 index 0000000..2de2905 --- /dev/null +++ b/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-multiplatform-jvm-and-js-browser-sonatype-ossrh-publish-conventions.gradle.kts @@ -0,0 +1,14 @@ +package com.huanshankeji + +plugins { + id("com.huanshankeji.kotlin-multiplatform-jvm-and-js-browser-default-maven-publish-conventions") + id("com.huanshankeji.sonatype-ossrh-publish") +} + +val javadocJar by tasks.registering(Jar::class) { + archiveClassifier.set("javadoc") +} + +publishing.publications.withType { + artifact(javadocJar) +} diff --git a/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/nexus-staging.gradle.kts b/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/nexus-staging.gradle.kts new file mode 100644 index 0000000..ac81c71 --- /dev/null +++ b/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/nexus-staging.gradle.kts @@ -0,0 +1,14 @@ +package com.huanshankeji + +/* TODO: this script is not working yet. +plugins { + id("io.codearte.nexus-staging") +} + +group = "com.huanshankeji" + +nexusStaging { + serverUrl = "https://s01.oss.sonatype.org/service/local/" + // TODO +} +*/ diff --git a/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/sonatype-ossrh-publish.gradle.kts b/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/sonatype-ossrh-publish.gradle.kts new file mode 100644 index 0000000..0f5151c --- /dev/null +++ b/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/sonatype-ossrh-publish.gradle.kts @@ -0,0 +1,20 @@ +package com.huanshankeji + +plugins { + id("com.huanshankeji.default-maven-publish") + signing +} + +signing { + sign(publishing.publications) +} + +publishing.repositories.maven { + val releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" + val snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/" + url = uri(if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl) + credentials { + username = project.property("ossrhUsername") as String + password = project.property("ossrhPassword") as String + } +}