mirror of
https://github.com/fankes/moshi.git
synced 2025-10-18 23:49:21 +08:00
Switch to the Vanniktech base plugin for publishing (#1450)
* Switch to the Vanniktech base plugin for publishing Move configuration out of build.gradle files and into build.gradle.kts files. Sign published builds. Support publishing release builds from GitHub actions. * Update build.gradle.kts Co-authored-by: Zac Sweers <zac.sweers@gmail.com> Co-authored-by: Zac Sweers <zac.sweers@gmail.com>
This commit is contained in:
5
.github/workflows/build.yml
vendored
5
.github/workflows/build.yml
vendored
@@ -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 }}
|
||||
|
@@ -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<Jar>().configureEach {
|
||||
manifest {
|
||||
attributes("Automatic-Module-Name" to "com.squareup.moshi.adapters")
|
||||
}
|
||||
}
|
||||
|
||||
configure<MavenPublishBaseExtension> {
|
||||
configure(KotlinJvm(javadocJar = Javadoc()))
|
||||
}
|
||||
|
@@ -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
|
@@ -29,7 +29,7 @@ dependencies {
|
||||
isTransitive = false
|
||||
isForce = true
|
||||
}
|
||||
latest(project(":adapters"))
|
||||
latest(project(":moshi-adapters"))
|
||||
}
|
||||
|
||||
val japicmp = tasks.register<JapicmpTask>("japicmp") {
|
||||
|
@@ -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<JavaPluginExtension> {
|
||||
@@ -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<Jar>().configureEach {
|
||||
manifest {
|
||||
attributes("Automatic-Module-Name" to name)
|
||||
allprojects {
|
||||
tasks.withType<DokkaTask>().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<DokkaTask>("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<MavenPublishBaseExtension> {
|
||||
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.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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"))
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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" }
|
||||
|
||||
|
@@ -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<MavenPublishBaseExtension> {
|
||||
configure(KotlinJvm(javadocJar = None()))
|
||||
}
|
||||
|
@@ -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
|
@@ -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<Jar>().configureEach {
|
||||
manifest {
|
||||
attributes("Automatic-Module-Name" to "com.squareup.moshi.kotlin")
|
||||
}
|
||||
}
|
||||
|
||||
configure<MavenPublishBaseExtension> {
|
||||
configure(KotlinJvm(javadocJar = Javadoc()))
|
||||
}
|
||||
|
@@ -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
|
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -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<Jar>().configureEach {
|
||||
manifest {
|
||||
attributes("Automatic-Module-Name" to "com.squareup.moshi")
|
||||
}
|
||||
}
|
||||
|
||||
configure<MavenPublishBaseExtension> {
|
||||
configure(KotlinJvm(javadocJar = Javadoc()))
|
||||
}
|
||||
|
@@ -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
|
61
releasing.md
Normal file
61
releasing.md
Normal file
@@ -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/
|
@@ -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")
|
||||
|
Reference in New Issue
Block a user