diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 33e08dc..7a61900 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -42,5 +42,6 @@ jobs: if: github.repository == 'square/moshi' && github.ref == 'refs/heads/master' && matrix.kotlin-test-mode == 'reflect' run: ./gradlew publish env: - ORG_GRADLE_PROJECT_mavenCentralUsername: '${{ secrets.SONATYPE_NEXUS_USERNAME }}' - ORG_GRADLE_PROJECT_mavenCentralPassword: '${{ secrets.SONATYPE_NEXUS_PASSWORD }}' + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.ARTIFACT_SIGNING_PRIVATE_KEY }} diff --git a/adapters/build.gradle.kts b/adapters/build.gradle.kts index db4d92b..13c8ede 100644 --- a/adapters/build.gradle.kts +++ b/adapters/build.gradle.kts @@ -1,3 +1,8 @@ +import com.vanniktech.maven.publish.JavadocJar.Javadoc +import com.vanniktech.maven.publish.KotlinJvm +import com.vanniktech.maven.publish.MavenPublishBaseExtension +import org.gradle.jvm.tasks.Jar + /* * Copyright (C) 2020 Square, Inc. * @@ -16,7 +21,8 @@ plugins { kotlin("jvm") - id("com.vanniktech.maven.publish") + id("com.vanniktech.maven.publish.base") + id("org.jetbrains.dokka") } dependencies { @@ -27,3 +33,13 @@ dependencies { testImplementation(libs.junit) testImplementation(libs.truth) } + +tasks.withType().configureEach { + manifest { + attributes("Automatic-Module-Name" to "com.squareup.moshi.adapters") + } +} + +configure { + configure(KotlinJvm(javadocJar = Javadoc())) +} diff --git a/adapters/gradle.properties b/adapters/gradle.properties deleted file mode 100644 index 32c667b..0000000 --- a/adapters/gradle.properties +++ /dev/null @@ -1,20 +0,0 @@ -# -# Copyright (C) 2020 Square, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -POM_NAME=Moshi Adapters -POM_ARTIFACT_ID=moshi-adapters -POM_PACKAGING=jar -AUTOMATIC_MODULE_NAME=com.squareup.moshi.adapters diff --git a/adapters/japicmp/build.gradle.kts b/adapters/japicmp/build.gradle.kts index d163820..298ec39 100644 --- a/adapters/japicmp/build.gradle.kts +++ b/adapters/japicmp/build.gradle.kts @@ -29,7 +29,7 @@ dependencies { isTransitive = false isForce = true } - latest(project(":adapters")) + latest(project(":moshi-adapters")) } val japicmp = tasks.register("japicmp") { diff --git a/build.gradle.kts b/build.gradle.kts index d38f34e..e4d1300 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -15,7 +15,8 @@ */ import com.diffplug.gradle.spotless.JavaExtension -import org.gradle.jvm.tasks.Jar +import com.vanniktech.maven.publish.MavenPublishBaseExtension +import com.vanniktech.maven.publish.SonatypeHost import org.jetbrains.dokka.gradle.DokkaTask import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension import org.jetbrains.kotlin.gradle.tasks.KotlinCompile @@ -35,12 +36,21 @@ buildscript { } plugins { - alias(libs.plugins.mavenPublish) apply false + alias(libs.plugins.mavenPublish) alias(libs.plugins.dokka) apply false alias(libs.plugins.spotless) alias(libs.plugins.japicmp) apply false } +allprojects { + group = "com.squareup.moshi" + version = "1.14.0-SNAPSHOT" + + repositories { + mavenCentral() + } +} + spotless { format("misc") { target("*.md", ".gitignore") @@ -72,10 +82,6 @@ spotless { } subprojects { - repositories { - mavenCentral() - } - // Apply with "java" instead of just "java-library" so kotlin projects get it too pluginManager.withPlugin("java") { configure { @@ -106,30 +112,54 @@ subprojects { } } } +} - // Configure publishing - pluginManager.withPlugin("com.vanniktech.maven.publish") { - // Configure automatic-module-name, but only for published modules - @Suppress("UnstableApiUsage") - val automaticModuleName = providers.gradleProperty("AUTOMATIC_MODULE_NAME") - .forUseAtConfigurationTime() - if (automaticModuleName.isPresent) { - val name = automaticModuleName.get() - tasks.withType().configureEach { - manifest { - attributes("Automatic-Module-Name" to name) +allprojects { + tasks.withType().configureEach { + dokkaSourceSets.configureEach { + reportUndocumented.set(false) + skipDeprecated.set(true) + jdkVersion.set(8) + perPackageOption { + matchingRegex.set("com\\.squareup.moshi\\.internal.*") + suppress.set(true) + } + } + if (name == "dokkaHtml") { + outputDirectory.set(rootDir.resolve("docs/1.x")) + dokkaSourceSets.configureEach { + skipDeprecated.set(true) + externalDocumentationLink { + url.set(URL("https://square.github.io/okio/2.x/okio/")) } } } + } - if (name != "codegen" && pluginManager.hasPlugin("org.jetbrains.kotlin.jvm")) { - apply(plugin = "org.jetbrains.dokka") - tasks.named("dokkaHtml") { - outputDirectory.set(rootDir.resolve("docs/1.x")) - dokkaSourceSets.configureEach { - skipDeprecated.set(true) - externalDocumentationLink { - url.set(URL("https://square.github.io/okio/2.x/okio/")) + plugins.withId("com.vanniktech.maven.publish.base") { + configure { + publishToMavenCentral(SonatypeHost.DEFAULT) + signAllPublications() + pom { + description.set("A modern JSON API for Android and Java") + name.set(project.name) + url.set("https://github.com/square/moshi/") + licenses { + license { + name.set("The Apache Software License, Version 2.0") + url.set("https://www.apache.org/licenses/LICENSE-2.0.txt") + distribution.set("repo") + } + } + scm { + url.set("https://github.com/square/moshi/") + connection.set("scm:git:git://github.com/square/moshi.git") + developerConnection.set("scm:git:ssh://git@github.com/square/moshi.git") + } + developers { + developer { + id.set("square") + name.set("Square, Inc.") } } } diff --git a/examples/build.gradle.kts b/examples/build.gradle.kts index fb7c5e8..7fe832c 100644 --- a/examples/build.gradle.kts +++ b/examples/build.gradle.kts @@ -20,8 +20,8 @@ plugins { } dependencies { - kapt(project(":kotlin:codegen")) + kapt(project(":kotlin:moshi-kotlin-codegen")) compileOnly(libs.jsr305) implementation(project(":moshi")) - implementation(project(":adapters")) + implementation(project(":moshi-adapters")) } diff --git a/gradle.properties b/gradle.properties index ecef5fe..695df8a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -24,19 +24,3 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 \ --add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED kapt.include.compile.classpath=false - -GROUP=com.squareup.moshi -VERSION_NAME=1.14.0-SNAPSHOT -POM_DESCRIPTION=A modern JSON API for Android and Java -POM_URL=https://github.com/square/moshi/ -POM_SCM_URL=https://github.com/square/moshi/ -POM_SCM_CONNECTION=scm:git:git://github.com/square/moshi.git -POM_SCM_DEV_CONNECTION=scm:git:ssh://git@github.com/square/moshi.git -POM_LICENCE_NAME=The Apache Software License, Version 2.0 -POM_LICENCE_URL=https://www.apache.org/licenses/LICENSE-2.0.txt -POM_LICENCE_DIST=repo -POM_DEVELOPER_ID=square -POM_DEVELOPER_NAME=Square, Inc. -POM_DEVELOPER_URL=https://github.com/square/ -POM_INCEPTION_YEAR=2015 -SONATYPE_STAGING_PROFILE=com.squareup diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 798eb9f..2e248be 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -26,7 +26,7 @@ ktlint = "0.41.0" dokka = { id = "org.jetbrains.dokka", version = "1.5.31" } japicmp = { id = "me.champeau.gradle.japicmp", version = "0.2.9" } ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } -mavenPublish = { id = "com.vanniktech.maven.publish", version = "0.17.0" } +mavenPublish = { id = "com.vanniktech.maven.publish", version = "0.18.0" } mavenShadow = { id = "com.github.johnrengelman.shadow", version = "7.0.0" } spotless = { id = "com.diffplug.spotless", version = "5.14.2" } diff --git a/kotlin/codegen/build.gradle.kts b/kotlin/codegen/build.gradle.kts index c446af6..d0fc648 100644 --- a/kotlin/codegen/build.gradle.kts +++ b/kotlin/codegen/build.gradle.kts @@ -16,12 +16,15 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation import com.github.jengelman.gradle.plugins.shadow.transformers.ServiceFileTransformer +import com.vanniktech.maven.publish.JavadocJar.None +import com.vanniktech.maven.publish.KotlinJvm +import com.vanniktech.maven.publish.MavenPublishBaseExtension import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { kotlin("jvm") id("com.google.devtools.ksp") - id("com.vanniktech.maven.publish") + id("com.vanniktech.maven.publish.base") alias(libs.plugins.mavenShadow) } @@ -120,3 +123,7 @@ artifacts { runtimeOnly(shadowJar) archives(shadowJar) } + +configure { + configure(KotlinJvm(javadocJar = None())) +} diff --git a/kotlin/codegen/gradle.properties b/kotlin/codegen/gradle.properties deleted file mode 100644 index b534f6c..0000000 --- a/kotlin/codegen/gradle.properties +++ /dev/null @@ -1,19 +0,0 @@ -# -# Copyright (C) 2020 Square, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -POM_NAME=Moshi Kotlin Codegen -POM_ARTIFACT_ID=moshi-kotlin-codegen -POM_PACKAGING=jar diff --git a/kotlin/reflect/build.gradle.kts b/kotlin/reflect/build.gradle.kts index 70fa901..77c19cf 100644 --- a/kotlin/reflect/build.gradle.kts +++ b/kotlin/reflect/build.gradle.kts @@ -14,9 +14,15 @@ * limitations under the License. */ +import com.vanniktech.maven.publish.JavadocJar.Javadoc +import com.vanniktech.maven.publish.KotlinJvm +import com.vanniktech.maven.publish.MavenPublishBaseExtension +import org.gradle.jvm.tasks.Jar + plugins { kotlin("jvm") - id("com.vanniktech.maven.publish") + id("com.vanniktech.maven.publish.base") + id("org.jetbrains.dokka") } dependencies { @@ -27,3 +33,13 @@ dependencies { testImplementation(libs.junit) testImplementation(libs.truth) } + +tasks.withType().configureEach { + manifest { + attributes("Automatic-Module-Name" to "com.squareup.moshi.kotlin") + } +} + +configure { + configure(KotlinJvm(javadocJar = Javadoc())) +} diff --git a/kotlin/reflect/gradle.properties b/kotlin/reflect/gradle.properties deleted file mode 100644 index fca827a..0000000 --- a/kotlin/reflect/gradle.properties +++ /dev/null @@ -1,20 +0,0 @@ -# -# Copyright (C) 2020 Square, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -POM_NAME=Moshi Kotlin -POM_ARTIFACT_ID=moshi-kotlin -POM_PACKAGING=jar -AUTOMATIC_MODULE_NAME=com.squareup.moshi.kotlin diff --git a/kotlin/tests/build.gradle.kts b/kotlin/tests/build.gradle.kts index e4e9fba..d52844f 100644 --- a/kotlin/tests/build.gradle.kts +++ b/kotlin/tests/build.gradle.kts @@ -69,14 +69,14 @@ dependencies { // Do nothing } KAPT -> { - "kaptTest"(project(":kotlin:codegen")) + "kaptTest"(project(":kotlin:moshi-kotlin-codegen")) } KSP -> { - "kspTest"(project(":kotlin:codegen")) + "kspTest"(project(":kotlin:moshi-kotlin-codegen")) } } testImplementation(project(":moshi")) - testImplementation(project(":kotlin:reflect")) + testImplementation(project(":kotlin:moshi-kotlin")) testImplementation(project(":kotlin:tests:extra-moshi-test-module")) testImplementation(kotlin("reflect")) testImplementation(libs.junit) diff --git a/kotlin/tests/codegen-only/build.gradle.kts b/kotlin/tests/codegen-only/build.gradle.kts index 7c5acb2..940935e 100644 --- a/kotlin/tests/codegen-only/build.gradle.kts +++ b/kotlin/tests/codegen-only/build.gradle.kts @@ -68,17 +68,17 @@ dependencies { when (testMode) { REFLECT -> { // Default to KSP in this case, this is a CI-only thing - "kspTest"(project(":kotlin:codegen")) + "kspTest"(project(":kotlin:moshi-kotlin-codegen")) } KAPT -> { - "kaptTest"(project(":kotlin:codegen")) + "kaptTest"(project(":kotlin:moshi-kotlin-codegen")) } KSP -> { - "kspTest"(project(":kotlin:codegen")) + "kspTest"(project(":kotlin:moshi-kotlin-codegen")) } } testImplementation(project(":moshi")) - testImplementation(project(":kotlin:reflect")) + testImplementation(project(":kotlin:moshi-kotlin")) testImplementation(project(":kotlin:tests:extra-moshi-test-module")) testImplementation(kotlin("reflect")) testImplementation(libs.junit) diff --git a/moshi/build.gradle.kts b/moshi/build.gradle.kts index a89e79b..75a3e3a 100644 --- a/moshi/build.gradle.kts +++ b/moshi/build.gradle.kts @@ -14,11 +14,16 @@ * limitations under the License. */ +import com.vanniktech.maven.publish.JavadocJar.Javadoc +import com.vanniktech.maven.publish.KotlinJvm +import com.vanniktech.maven.publish.MavenPublishBaseExtension +import org.gradle.jvm.tasks.Jar import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { kotlin("jvm") - id("com.vanniktech.maven.publish") + id("com.vanniktech.maven.publish.base") + id("org.jetbrains.dokka") } val mainSourceSet by sourceSets.named("main") @@ -80,3 +85,13 @@ dependencies { testImplementation(libs.junit) testImplementation(libs.truth) } + +tasks.withType().configureEach { + manifest { + attributes("Automatic-Module-Name" to "com.squareup.moshi") + } +} + +configure { + configure(KotlinJvm(javadocJar = Javadoc())) +} diff --git a/moshi/gradle.properties b/moshi/gradle.properties deleted file mode 100644 index 4938af0..0000000 --- a/moshi/gradle.properties +++ /dev/null @@ -1,20 +0,0 @@ -# -# Copyright (C) 2020 Square, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -POM_NAME=Moshi -POM_ARTIFACT_ID=moshi -POM_PACKAGING=jar -AUTOMATIC_MODULE_NAME=com.squareup.moshi diff --git a/releasing.md b/releasing.md new file mode 100644 index 0000000..28878f4 --- /dev/null +++ b/releasing.md @@ -0,0 +1,61 @@ +Releasing +========= + +### Prerequisite: Sonatype (Maven Central) Account + +Create an account on the [Sonatype issues site][sonatype_issues]. Ask an existing publisher to open +an issue requesting publishing permissions for `com.squareup` projects. + + +Cutting a Release +----------------- + +1. Update `CHANGELOG.md`. + +2. Set versions: + + ``` + export RELEASE_VERSION=X.Y.Z + export NEXT_VERSION=X.Y.Z-SNAPSHOT + ``` + +3. Update versions: + + ``` + sed -i "" \ + "s/VERSION_NAME=.*/VERSION_NAME=$RELEASE_VERSION/g" \ + gradle.properties + sed -i "" \ + "s/\"com.squareup.moshi:\([^\:]*\):[^\"]*\"/\"com.squareup.moshi:\1:$RELEASE_VERSION\"/g" \ + `find . -name "README.md"` + ``` + +4. Tag the release and push to GitHub. + + ``` + git commit -am "Prepare for release $RELEASE_VERSION." + git tag -a parent-$RELEASE_VERSION -m "Version $RELEASE_VERSION" + git push && git push --tags + ``` + +5. Wait for [GitHub Actions][github_actions] to start building the release. + +6. Prepare for ongoing development and push to GitHub. + + ``` + sed -i "" \ + "s/VERSION_NAME=.*/VERSION_NAME=$NEXT_VERSION/g" \ + gradle.properties + git commit -am "Prepare next development version." + git push + ``` + +7. Wait for [GitHub Actions][github_actions] to build and publish releases for both Windows and + Non-Windows. + +8. Visit [Sonatype Nexus][sonatype_nexus] to promote (close then release) the releases. Or drop it + if there is a problem! + + [github_actions]: https://github.com/square/moshi/actions + [sonatype_issues]: https://issues.sonatype.org/ + [sonatype_nexus]: https://oss.sonatype.org/ diff --git a/settings.gradle.kts b/settings.gradle.kts index d3ff693..64d43d3 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -26,10 +26,13 @@ include(":moshi") include(":moshi:japicmp") include(":moshi:records-tests") include(":adapters") +project(":adapters").name = "moshi-adapters" include(":adapters:japicmp") include(":examples") include(":kotlin:reflect") +project(":kotlin:reflect").name = "moshi-kotlin" include(":kotlin:codegen") +project(":kotlin:codegen").name = "moshi-kotlin-codegen" include(":kotlin:tests") include(":kotlin:tests:codegen-only") include(":kotlin:tests:extra-moshi-test-module")