Skip to content

Commit 0f0898f

Browse files
committed
Update feature: use publish-plugin gradle plugin to publish to Sonatype
1 parent bf2c678 commit 0f0898f

File tree

2 files changed

+56
-1
lines changed

2 files changed

+56
-1
lines changed

features/maven-publish/feature.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,8 @@ build:
33
repositories:
44
- "https://plugins.gradle.org/m2/"
55
plugins:
6-
- maven-publish
6+
- maven-publish
7+
- signing
8+
dependencies:
9+
- scope: build
10+
coords: 'io.github.gradle-nexus:publish-plugin:1.3.0'

features/maven-publish/skeleton/build.gradle

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,57 @@ publishing {
1111
}
1212
}
1313
from components.java
14+
15+
pom {
16+
name = "My Plugin"
17+
description = "My first plugin"
18+
url = 'https://github.com/grace-plugins/my-plugin'
19+
licenses {
20+
license {
21+
name = 'The Apache License, Version 2.0'
22+
url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
23+
}
24+
}
25+
developers {
26+
developer {
27+
id = 'yourname'
28+
name = 'Your Name'
29+
30+
}
31+
}
32+
scm {
33+
connection = 'scm:git:git://github.com/grace-plugins/my-plugin.git'
34+
developerConnection = 'scm:git:ssh://github.com:grace-plugins/my-plugin.git'
35+
url = 'https://github.com/grace-plugins/my-plugin'
36+
}
37+
}
1438
}
1539
}
1640
}
41+
42+
ext."signing.keyId" = project.hasProperty("signing.keyId") ? project.getProperty('signing.keyId') : System.getenv('SIGNING_KEY')
43+
ext."signing.password" = project.hasProperty("signing.password") ? project.getProperty('signing.password') : System.getenv('SIGNING_PASSPHRASE')
44+
ext."signing.secretKeyRingFile" = project.hasProperty("signing.secretKeyRingFile") ? project.getProperty('signing.secretKeyRingFile') : ("${System.properties['user.home']}${File.separator}.gnupg${File.separator}secring.gpg")
45+
ext.isReleaseVersion = !projectVersion.endsWith("SNAPSHOT")
46+
47+
nexusPublishing {
48+
repositories {
49+
sonatype {
50+
def ossUser = System.getenv("SONATYPE_USERNAME") ?: project.hasProperty("sonatypeOssUsername") ? project.sonatypeOssUsername : ''
51+
def ossPass = System.getenv("SONATYPE_PASSWORD") ?: project.hasProperty("sonatypeOssPassword") ? project.sonatypeOssPassword : ''
52+
def ossStagingProfileId = System.getenv("SONATYPE_STAGING_PROFILE_ID") ?: project.hasProperty("sonatypeOssStagingProfileId") ? project.sonatypeOssStagingProfileId : ''
53+
nexusUrl = uri("https://s01.oss.sonatype.org/service/local/")
54+
snapshotRepositoryUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
55+
username = ossUser
56+
password = ossPass
57+
stagingProfileId = ossStagingProfileId
58+
}
59+
}
60+
}
61+
62+
afterEvaluate {
63+
signing {
64+
required { isReleaseVersion && gradle.taskGraph.hasTask("publish") }
65+
sign publishing.publications.maven
66+
}
67+
}

0 commit comments

Comments
 (0)