Skip to content

Commit

Permalink
Use Nexus Publishing plugin for automatic publishing (#33)
Browse files Browse the repository at this point in the history
- Used [Nexus Publishing](https://github.com/gradle-nexus/publish-plugin/) plugin for automatic publishing of new versions from staging to release Sonatype Nexus repository.

When artifacts are being released they first land on staging repo https://oss.sonatype.org/\#stagingRepositories from where manual intervention is required to further push the new project version to release Sonatype repository. Nexus Publishing plugin allows for automatic propagation of new project version from staging repo to release.
More details on https://central.sonatype.org/publish/release/.
  • Loading branch information
vgaidarji authored Dec 1, 2022
1 parent 617be13 commit e7495af
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,11 @@ following environment variables should be added to Circle CI project environment
- `ORG_GRADLE_PROJECT_SONATYPE_USERNAME`
- `ORG_GRADLE_PROJECT_SONATYPE_PASSWORD`

`publishToMavenLocal` task can be used to perform a dry run publishing.
`publishToMavenLocal` task can be used to perform a dry run publishing to local maven repository.

`./gradlew clean build publish` command is used to upload signed plugin artifact to [Maven Central](https://search.maven.org/).
For automatic publishing from Sonatype Nexus staging repository to release https://github.com/gradle-nexus/publish-plugin/ plugin is used.
`./gradlew clean build publishToSonatype closeSonatypeStagingRepository` command is used to upload signed plugin artifact to [Maven Central](https://search.maven.org/).
Publishing may take some time, check https://oss.sonatype.org for new published version.

Developed By
------------
Expand Down
7 changes: 6 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
apply plugin: 'io.github.gradle-nexus.publish-plugin'

buildscript {
ext.kotlin_version = '1.6.20'

repositories {
google()
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "com.android.tools.build:gradle:7.2.2"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:1.6.0"
// classpath 'com.jfrog.maven-publishing.gradle:gradle-bintray-plugin:1.8.0'
classpath "io.github.gradle-nexus:publish-plugin:1.1.0"
}
}

Expand Down
15 changes: 9 additions & 6 deletions gradle/maven-publishing.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,16 @@ publishing {
}
}
}
}

// io.github.gradle-nexus.publish-plugin
nexusPublishing {
repositories {
maven {
url "https://oss.sonatype.org/service/local/staging/deploy/maven2"
credentials {
username findProperty('SONATYPE_USERNAME')
password findProperty('SONATYPE_PASSWORD')
}
sonatype {
// my acc is registered on https://oss.sonatype.org
// and for legacy accs repo url is not required by plugin
username = findProperty('SONATYPE_USERNAME')
password = findProperty('SONATYPE_PASSWORD')
}
}
}
Expand Down

0 comments on commit e7495af

Please sign in to comment.