1+ /**
2+ * Define project extension values in the project gradle file before including this file:
3+ *
4+ * publishName = 'Name of Package'
5+ * publishDescription = 'description' (optional)
6+ * githubSlug = Github slug e.g. 'rundeck/rundeck-cli'
7+ * developers = [ [id:'id', name:'name', email: 'email' ] ] list of developers
8+ *
9+ * Define project properties to sign and publish when invoking publish task:
10+ *
11+ * ./gradlew \
12+ * -PsigningKey="base64 encoded gpg key" \
13+ * -PsigningPassword="password for key" \
14+ * -PsonatypeUsername="sonatype token user" \
15+ * -PsonatypePassword="sonatype token password" \
16+ * publishToSonatype closeAndReleaseSonatypeStagingRepository
17+ */
18+ apply plugin : ' maven-publish'
19+ apply plugin : ' signing'
20+
21+ publishing {
22+ publications {
23+ " ${ project.name} " (MavenPublication ) { publication ->
24+ from components. java
25+
26+ pom {
27+ name = publishName
28+ description = project. ext. hasProperty(' publishDescription' ) ? project. ext. publishDescription :
29+ project. description ?: publishName
30+ url = " https://github.com/${ githubSlug} "
31+ licenses {
32+ license {
33+ name = ' The Apache Software License, Version 2.0'
34+ url = ' http://www.apache.org/licenses/LICENSE-2.0.txt'
35+ distribution = ' repo'
36+ }
37+ }
38+ scm {
39+ url = " https://github.com/${ githubSlug} "
40+ connection = " scm:git:git@github.com/${ githubSlug} .git"
41+ developerConnection = " scm:git:git@github.com:${ githubSlug} .git"
42+ }
43+ if (project. ext. developers) {
44+ developers {
45+ project. ext. developers. each { dev ->
46+ developer {
47+ id = dev. id
48+ name = dev. name
49+ email = dev. email
50+ }
51+ }
52+ }
53+ }
54+ }
55+
56+ }
57+ }
58+ repositories {
59+ def pkgcldWriteToken = System . getenv(" PKGCLD_WRITE_TOKEN" ) ?: project. findProperty(" pkgcldWriteToken" )
60+ if (pkgcldWriteToken) {
61+ maven {
62+ name = " PackageCloudTest"
63+ url = uri(" https://packagecloud.io/pagerduty/rundeckpro-test/maven2" )
64+ authentication {
65+ header(HttpHeaderAuthentication )
66+ }
67+ credentials(HttpHeaderCredentials ) {
68+ name = " Authorization"
69+ value = " Bearer " + pkgcldWriteToken
70+ }
71+ }
72+ }
73+ }
74+ }
75+ def base64Decode = { String prop ->
76+ project. findProperty(prop) ?
77+ new String (Base64 . getDecoder(). decode(project. findProperty(prop). toString())). trim() :
78+ null
79+ }
80+
81+ if (project. hasProperty(' signingKey' ) && project. hasProperty(' signingPassword' )) {
82+ signing {
83+ useInMemoryPgpKeys(base64Decode(" signingKey" ), project. signingPassword)
84+ sign(publishing. publications)
85+ }
86+ }
0 commit comments