diff --git a/architecture-common-gradle-plugins/build.gradle.kts b/architecture-common-gradle-plugins/build.gradle.kts index 275e6a6..30d875a 100644 --- a/architecture-common-gradle-plugins/build.gradle.kts +++ b/architecture-common-gradle-plugins/build.gradle.kts @@ -11,14 +11,14 @@ dependencies { //api(project(":common-gradle-dependencies")) implementation(project(":common-gradle-dependencies")) - implementation("org.jetbrains.compose:compose-gradle-plugin:1.2.0-alpha01-dev686") + implementation("org.jetbrains.compose:compose-gradle-plugin:1.1.1") } gradlePlugin { plugins { val `package` = group as String - fun scriptConventionsPlugin(shortName: String, displayNameAndDescription: String) = - scriptPlugin(`package`, shortName, displayNameAndDescription) + fun scriptConventionsPlugin(shortName: String, displayName: String, description: String = displayName) = + scriptPlugin(`package`, shortName, displayName, description) scriptConventionsPlugin( "kotlin-jvm-common-app-conventions", diff --git a/architecture-common-gradle-plugins/src/main/kotlin/com/huanshankeji/GenerateKotlinJsBrowserWebrootForVertxWebPlugin.kt b/architecture-common-gradle-plugins/src/main/kotlin/com/huanshankeji/GenerateKotlinJsBrowserWebrootForVertxWebPlugin.kt index cf9499c..df918c7 100644 --- a/architecture-common-gradle-plugins/src/main/kotlin/com/huanshankeji/GenerateKotlinJsBrowserWebrootForVertxWebPlugin.kt +++ b/architecture-common-gradle-plugins/src/main/kotlin/com/huanshankeji/GenerateKotlinJsBrowserWebrootForVertxWebPlugin.kt @@ -19,16 +19,20 @@ class GenerateKotlinJsBrowserWebrootForVertxWebPlugin : Plugin { /*val jsBrowserDistributionTask by lazy { tasks.getByPath(extension.webFrontendProjectPath.get() + ":jsBrowserDistribution") as KotlinWebpack }*/ - val jsBrowserProductionWebpack by lazy { - tasks.getByPath(extension.webFrontendProjectPath.get() + ":jsBrowserProductionWebpack") as KotlinWebpack + val jsBrowserWebpack by lazy { + tasks.getByPath( + extension.webFrontendProjectPath.get() + + if (extension.production.get()) ":jsBrowserProductionWebpack" else ":jsBrowserDevelopmentWebpack" + ) as KotlinWebpack } val copyJsBrowserDistributionToResourcesWebroot = "copyJsBrowserDistributionToResourcesWebroot" val browserDistributionResourcesDirectory = buildDir.resolve("browserDistributionResources") tasks.register(copyJsBrowserDistributionToResourcesWebroot) { - dependsOn(jsBrowserProductionWebpack) - from(jsBrowserProductionWebpack.destinationDirectory) - include("*.html", "*.css", "*.js") + dependsOn(jsBrowserWebpack) + from(jsBrowserWebpack.destinationDirectory) + if (extension.production.get()) + include("*.html", "*.css", "*.js") into(browserDistributionResourcesDirectory.resolve("webroot")) } @@ -41,5 +45,6 @@ class GenerateKotlinJsBrowserWebrootForVertxWebPlugin : Plugin { interface Extension { val webFrontendProjectPath: Property + val production: Property } } \ No newline at end of file diff --git a/architecture-common-gradle-plugins/src/main/kotlin/com/huanshankeji/VersionsAndDependencies.kt b/architecture-common-gradle-plugins/src/main/kotlin/com/huanshankeji/VersionsAndDependencies.kt new file mode 100644 index 0000000..3e509be --- /dev/null +++ b/architecture-common-gradle-plugins/src/main/kotlin/com/huanshankeji/VersionsAndDependencies.kt @@ -0,0 +1,4 @@ +package com.huanshankeji + +internal val commonVersions = CommonVersions() +internal val commonDependencies = CommonDependencies(commonVersions) diff --git a/architecture-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-jvm-common-app-conventions.gradle.kts b/architecture-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-jvm-common-app-conventions.gradle.kts index 64ce4a3..cd9941c 100644 --- a/architecture-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-jvm-common-app-conventions.gradle.kts +++ b/architecture-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-jvm-common-app-conventions.gradle.kts @@ -8,11 +8,11 @@ dependencies { implementation(platform(kotlin("bom"))) testImplementation(kotlin("test")) - testImplementation("org.junit.jupiter:junit-jupiter-api:${DefaultVersions.junitJupiter}") + testImplementation("org.junit.jupiter:junit-jupiter-api:${commonVersions.junitJupiter}") testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine") - implementation(CommonDependencies.Kotlinx.Coroutines.core()) - testImplementation(CommonDependencies.Kotlinx.Coroutines.test()) + implementation(commonDependencies.kotlinx.coroutines.core()) + testImplementation(commonDependencies.kotlinx.coroutines.test()) } tasks.test { diff --git a/architecture-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-multiplatform-app-conventions.gradle.kts b/architecture-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-multiplatform-app-conventions.gradle.kts index c884e1c..f2a5693 100644 --- a/architecture-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-multiplatform-app-conventions.gradle.kts +++ b/architecture-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-multiplatform-app-conventions.gradle.kts @@ -9,14 +9,14 @@ kotlin { val commonMain by getting { dependencies { //implementation(platform(kotlin("bom", kotlinVersion))) - implementation(CommonDependencies.Kotlinx.Coroutines.core()) + implementation(commonDependencies.kotlinx.coroutines.core()) } } val commonTest by getting { dependencies { implementation(kotlin("test")) - implementation(CommonDependencies.Kotlinx.Coroutines.test()) + implementation(commonDependencies.kotlinx.coroutines.test()) } } diff --git a/buildSrc/src/main/kotlin/ScriptPlugins.kt b/buildSrc/src/main/kotlin/ScriptPlugins.kt index ecfda09..1740ab5 100644 --- a/buildSrc/src/main/kotlin/ScriptPlugins.kt +++ b/buildSrc/src/main/kotlin/ScriptPlugins.kt @@ -2,9 +2,9 @@ import org.gradle.api.NamedDomainObjectContainer import org.gradle.plugin.devel.PluginDeclaration fun NamedDomainObjectContainer.scriptPlugin( - `package`: String, shortName: String, displayNameAndDescription: String + `package`: String, shortName: String, displayName: String, description: String = displayName ) = getByName("$`package`.$shortName") { - displayName = displayNameAndDescription - description = displayNameAndDescription + this.displayName = displayName + this.description = description } 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 34d321a..7058cda 100644 --- a/buildSrc/src/main/kotlin/plugin-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/plugin-conventions.gradle.kts @@ -5,13 +5,13 @@ plugins { dependencies { // Not specifying version can cause build issues when added to a project's buildscript dependencies. - implementation(kotlin("gradle-plugin", "1.6.21")) + implementation(kotlin("gradle-plugin", "1.6.10")) } -version = "0.1.1" +version = "0.1.8-kotlin-1.6.10" pluginBundle { - website = "https://github.com/huanshankeji/gradle-plugin" - vcsUrl = "https://github.com/huanshankeji/gradle-plugin.git" + website = "https://github.com/huanshankeji/gradle-common" + vcsUrl = "$website.git" tags = listOf("kotlin", "multiplatform") } diff --git a/common-gradle-dependencies/build.gradle.kts b/common-gradle-dependencies/build.gradle.kts index 969c828..c6e411d 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-20220520-dev" +// "x.y.z" indicates the version of the way of organizing the code, +// and the date indicates the version when the dependency versions are updated. +version = "0.2.0-20220714-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..d15a962 100644 --- a/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/CommonDependencies.kt +++ b/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/CommonDependencies.kt @@ -1,9 +1,11 @@ package com.huanshankeji +import org.gradle.api.artifacts.dsl.DependencyHandler + // some but not all default dependencies -object CommonDependencies { - object KotlinCommon { - val defaultVersion = DefaultVersions.kotlinCommon +class CommonDependencies(val versions: CommonVersions = CommonVersions()) { + inner class KotlinCommon internal constructor() { + val defaultVersion = versions.kotlinCommon fun module(module: String, version: String = defaultVersion) = "com.huanshankeji:kotlin-common-$module:$version" @@ -14,20 +16,24 @@ object CommonDependencies { fun coroutines(version: String = defaultVersion) = module("coroutines", version) fun exposed(version: String = defaultVersion) = module("exposed", version) - object Ktor { + inner class Ktor internal constructor() { fun module(module: String, version: String = defaultVersion) = - KotlinCommon.module("ktor-$module", version) + this@KotlinCommon.module("ktor-$module", version) fun client(version: String = defaultVersion) = module("client", version) } + val ktor = Ktor() + fun serialization(version: String = defaultVersion) = module("serialization", version) fun vertx(version: String = defaultVersion) = module("vertx", version) } - object Kotlinx { - object Coroutines { - val defaultVersion = DefaultVersions.kotlinxCoroutines + val kotlinCommon = KotlinCommon() + + inner class Kotlinx internal constructor() { + inner class Coroutines internal constructor() { + val defaultVersion = versions.kotlinxCoroutines fun module(module: String, version: String = defaultVersion) = kotlinx("coroutines-$module", version) @@ -35,14 +41,18 @@ object CommonDependencies { fun test(version: String = defaultVersion) = module("test", version) } - object Html { - val defaultVersion = DefaultVersions.kotlinxHtml + val coroutines = Coroutines() + + inner class Html internal constructor() { + val defaultVersion = versions.kotlinxHtml fun module(module: String, version: String = defaultVersion) = "org.jetbrains.kotlinx:kotlinx-html-$module:$version" } - object Serialization { - val defaultVersion = DefaultVersions.kotlinxSerialization + val html = Html() + + inner class Serialization internal constructor() { + val defaultVersion = versions.kotlinxSerialization fun module(module: String, version: String = defaultVersion) = kotlinx("serialization-$module", version) @@ -50,13 +60,20 @@ object CommonDependencies { fun protobuf(version: String = defaultVersion) = module("protobuf", version) fun json(version: String = defaultVersion) = module("json", version) } + + val serialization = Serialization() + + fun datetime(version: String = versions.kotlinxDatetime) = + kotlinx("datetime", version) } + val kotlinx = Kotlinx() + // official libraries from JetBrains - object Exposed { - val defaultVersion = DefaultVersions.exposed + inner class Exposed internal constructor() { + val defaultVersion = versions.exposed fun module(module: String, version: String = defaultVersion) = "org.jetbrains.exposed:exposed-$module:$version" @@ -64,38 +81,55 @@ object CommonDependencies { module("core", version) } - object Ktor { - val defaultVersion = DefaultVersions.ktor + val exposed = Exposed() + + inner class Ktor internal constructor() { + val defaultVersion = versions.ktor fun module(module: String, version: String = defaultVersion) = "io.ktor:ktor-$module:$version" - object Client { + inner class Client internal constructor() { fun module(module: String, version: String = defaultVersion) = - Ktor.module("client-$module", version) + this@Ktor.module("client-$module", version) fun core(version: String = defaultVersion) = module("core", version) } + + val client = Client() } + val ktor = Ktor() + // others - object Vertx { - val defaultVersion = DefaultVersions.vertx - fun stackDepchain(version: String = defaultVersion) = - "io.vertx:vertx-stack-depchain:$version" + inner class Vertx internal constructor() { + val defaultVersion = versions.vertx + + private fun stackDepchain(version: String = defaultVersion) = + moduleWithVersion("stack-depchain", version) - fun module(module: String) = + 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 { - val defaultVersion = DefaultVersions.arrow + val vertx = Vertx() + + inner class Arrow internal constructor() { + val defaultVersion = versions.arrow fun module(module: String, version: String = defaultVersion) = "io.arrow-kt:arrow-$module:$version" fun core(version: String = defaultVersion) = module("core", version) } + + val arrow = Arrow() } \ No newline at end of file diff --git a/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/CommonVersions.kt b/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/CommonVersions.kt new file mode 100644 index 0000000..c6edcd6 --- /dev/null +++ b/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/CommonVersions.kt @@ -0,0 +1,21 @@ +package com.huanshankeji + +class CommonVersions( + val kotlin: String = "1.6.10", + + val kotlinCommon: String = "0.1.1-kotlin-1.6.10", + + val exposed: String = "0.38.2", + val kotlinxCoroutines: String = "1.6.1", + val kotlinxHtml: String = "0.7.5", + val kotlinxSerialization: String = "1.3.2", + val kotlinxDatetime: String = "0.4.0", + val ktor: String = "1.6.8", + + val arrow: String = "1.0.1", + val junitJupiter: String = "5.8.2", + val kotest: String = "5.2.3", + val postgreSql: String = "42.3.5", + val slf4j: String = "1.7.36", + val vertx: String = "4.2.7", // TODO: 4.3.0 +) \ No newline at end of file diff --git a/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/DefaultVersions.kt b/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/DefaultVersions.kt deleted file mode 100644 index e9ebaef..0000000 --- a/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/DefaultVersions.kt +++ /dev/null @@ -1,20 +0,0 @@ -package com.huanshankeji - -object DefaultVersions { - val kotlin = "1.6.21" - - val kotlinCommon = "0.1.0-SNAPSHOT" // TODO - - val exposed = "0.38.2" - val kotlinxCoroutines = "1.6.1" - val kotlinxHtml = "0.7.5" - val kotlinxSerialization = "1.3.3" - val ktor = "1.6.8" - - val arrow = "1.1.2" - val junitJupiter = "5.8.2" - val kotest = "5.2.3" - val postgreSql = "42.3.5" - val slf4j = "1.7.36" - val vertx = "4.2.7" // TODO: 4.3.0 -} \ No newline at end of file diff --git a/kotlin-common-gradle-plugins/build.gradle.kts b/kotlin-common-gradle-plugins/build.gradle.kts index 20c8d87..b6d265b 100644 --- a/kotlin-common-gradle-plugins/build.gradle.kts +++ b/kotlin-common-gradle-plugins/build.gradle.kts @@ -4,13 +4,14 @@ plugins { dependencies { //api(project(":common-gradle-dependencies")) + //implementation("io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.30.0") } gradlePlugin { plugins { val `package` = group as String - fun scriptConventionsPlugin(shortName: String, displayNameAndDescription: String) = - scriptPlugin(`package`, shortName, displayNameAndDescription) + fun scriptConventionsPlugin(shortName: String, displayName: String, description: String = displayName) = + scriptPlugin(`package`, shortName, displayName, description) scriptConventionsPlugin( "kotlin-jvm-common-conventions", @@ -38,5 +39,24 @@ 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" + ) + + scriptConventionsPlugin( + "jvm-integration-test", + "JVM integration test", + "Adds a JVM integration test source set." + ) + scriptConventionsPlugin( + "jvm-test-common-feature-variant", + "JVM test common feature variant", + "Adds a JVM test common feature variant with a source set that depends on `main`." + ) } } diff --git a/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/GenerateKotlinSources.kt b/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/GenerateKotlinSources.kt new file mode 100644 index 0000000..b1555a1 --- /dev/null +++ b/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/GenerateKotlinSources.kt @@ -0,0 +1,43 @@ +package com.huanshankeji + +import org.gradle.api.Project +import org.gradle.api.tasks.TaskContainer +import org.gradle.api.tasks.TaskProvider +import org.gradle.kotlin.dsl.get +import org.gradle.kotlin.dsl.invoke +import org.gradle.kotlin.dsl.named +import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +class SourceFile(val filePath: String, val content: String) + +fun Project.generateKotlinSources( + taskName: String = "generateSources", sourceDirectoryName: String = "main", sourceFiles: List +) { + val generatedSourcesDir = buildDir.resolve("gen/$sourceDirectoryName/kotlin") + + val task = tasks.register(taskName) { + generatedSourcesDir.mkdirs() + + for (sourceFile in sourceFiles) { + val generatedVersionsSourceFile = generatedSourcesDir.resolve(sourceFile.filePath) + generatedVersionsSourceFile.writeText(sourceFile.content) + } + } + + tasks.compileKotlin { + dependsOn(task) + } + + kotlin.sourceSets["main"].kotlin.srcDir(generatedSourcesDir) +} + + +// copied and adapted from generated sources +// made private to avoid conflicts with generated code + +private val TaskContainer.compileKotlin: TaskProvider + get() = named("compileKotlin") + +private val Project.kotlin: KotlinJvmProjectExtension + get() = extensions.getByName("kotlin") as KotlinJvmProjectExtension 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/jvm-integration-test.gradle.kts b/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/jvm-integration-test.gradle.kts new file mode 100644 index 0000000..6708d73 --- /dev/null +++ b/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/jvm-integration-test.gradle.kts @@ -0,0 +1,35 @@ +package com.huanshankeji + +plugins { + java +} + +// code copied and adapted from https://docs.gradle.org/current/userguide/java_testing.html#sec:configuring_java_integration_tests + +sourceSets { + create("intTest") { + compileClasspath += sourceSets.main.get().output + runtimeClasspath += sourceSets.main.get().output + } +} + +val intTestImplementation by configurations.getting { + extendsFrom(configurations.implementation.get()) + extendsFrom(configurations.testImplementation.get()) +} + +configurations["intTestRuntimeOnly"].extendsFrom(configurations.runtimeOnly.get()) + +val integrationTest = task("integrationTest") { + description = "Runs integration tests." + group = "verification" + + testClassesDirs = sourceSets["intTest"].output.classesDirs + classpath = sourceSets["intTest"].runtimeClasspath + shouldRunAfter("test") + + // copied from "kotlin-jvm-common-app-conventions" + useJUnitPlatform() +} + +tasks.check { dependsOn(integrationTest) } diff --git a/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/jvm-test-common-feature-variant.gradle.kts b/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/jvm-test-common-feature-variant.gradle.kts new file mode 100644 index 0000000..69261c9 --- /dev/null +++ b/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/jvm-test-common-feature-variant.gradle.kts @@ -0,0 +1,20 @@ +package com.huanshankeji + +plugins { + java +} + +val testCommon = "testCommon" + +sourceSets.register(testCommon) { + val mainSourceSet = sourceSets["main"] + compileClasspath += mainSourceSet.compileClasspath + mainSourceSet.output + //runtimeClasspath += + //runtimeClasspath += mainSourceSet.runtimeClasspath + mainSourceSet.output +} + +java.registerFeature(testCommon) { + usingSourceSet(sourceSets[testCommon]) + withJavadocJar() + withSourcesJar() +} 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..bbcde11 --- /dev/null +++ b/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/sonatype-ossrh-publish.gradle.kts @@ -0,0 +1,21 @@ +package com.huanshankeji + +plugins { + id("com.huanshankeji.default-maven-publish") + signing +} + +signing { + isRequired = false + 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 { + project.findProperty("ossrhUsername")?.let { username = it as String } + project.findProperty("ossrhPassword")?.let { password = it as String } + } +}