Skip to content

Commit

Permalink
Fix publish-plugin configuration (#34)
Browse files Browse the repository at this point in the history
- Fixed `publish-plugin` configuration. `group`/`version` had to be added to root `build.gradle` and this required some refactoring so that maven publishing configuration correctly references those fields from another build file.
- Replaced `jcenter()` documentation leftover with `mavenCentral()`
  • Loading branch information
vgaidarji authored Dec 2, 2022
1 parent e7495af commit 1ff661f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 19 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ Apply the plugin in your `build.gradle`:
```groovy
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.vgaidarji:dependencies-overview:1.0.0'
classpath 'com.vgaidarji:dependencies-overview:<VERSION>'
}
}
Expand Down Expand Up @@ -145,8 +145,8 @@ following environment variables should be added to Circle CI project environment
`publishToMavenLocal` task can be used to perform a dry run publishing to local maven repository.

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.
`./gradlew clean build publishToSonatype closeAndReleaseSonatypeStagingRepository` 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 newly published version.

Developed By
------------
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apply plugin: 'io.github.gradle-nexus.publish-plugin'
apply from: file('gradle/nexus-publishing.gradle')

buildscript {
ext.kotlin_version = '1.6.20'
Expand Down
15 changes: 1 addition & 14 deletions gradle/maven-publishing.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ task sourcesJar(type: Jar) {
}

ext {
publishedGroupId = 'com.vgaidarji'
// some fields in nexus-publishing.gradle as required by publish-plugin
libraryName = 'dependencies-overview'
artifact = 'dependencies-overview'
localVersionSuffix = 'local'
// :bulb: keep sample-android-app/app/build.gradle in sync
libraryVersion = "1.0.1"
libraryVersionString = Boolean.getBoolean("useLocalVersion") ? "$libraryVersion-$localVersionSuffix" : libraryVersion
libraryDescription = 'Generates project dependencies overview report (JSON, Markdown, etc.) from project dependencies'

Expand Down Expand Up @@ -73,18 +72,6 @@ publishing {
}
}

// io.github.gradle-nexus.publish-plugin
nexusPublishing {
repositories {
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')
}
}
}

signing {
// do no require signing on Circle CI
required { System.getenv("CIRCLECI") == "false" }
Expand Down
20 changes: 20 additions & 0 deletions gradle/nexus-publishing.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apply plugin: 'io.github.gradle-nexus.publish-plugin'

ext {
publishedGroupId = 'com.vgaidarji'
libraryVersion = '1.0.1'
}

group = publishedGroupId
version = libraryVersion

nexusPublishing {
repositories {
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')
}
}
}

0 comments on commit 1ff661f

Please sign in to comment.