1
1
// -----------------------------------------------------------------------------
2
2
// Collect publishing information
3
3
// -----------------------------------------------------------------------------
4
- ext. publishing = [:]
5
- ext. publishing. bintray = [:]
4
+ ext. publishingInfo = [:]
6
5
7
- ext. publishing . pomName = ext. publishing . artifactId
6
+ ext. publishingInfo . pomName = ext. publishingInfo . artifactId
8
7
9
8
apply from : " gradle/project-info.gradle"
9
+ apply plugin : ' signing'
10
10
11
11
// -----------------------------------------------------------------------------
12
12
// Performs publishing
13
13
// -----------------------------------------------------------------------------
14
14
15
15
task javadocJar (type : Jar , dependsOn : javadoc) {
16
- classifier = ' javadoc'
16
+ archiveClassifier = ' javadoc'
17
17
from javadoc. destinationDir
18
18
}
19
19
20
20
// create one jar for the source files
21
21
task sourcesJar (type : Jar , dependsOn : classes) {
22
- classifier = ' sources'
22
+ archiveClassifier = ' sources'
23
23
from sourceSets. main. allSource
24
24
}
25
25
26
- // create one jar for the plugin jar (no fat-jar)
27
- task publicationJar (type : Jar , dependsOn : classes) {
28
- // project class files compiled from source
29
- from files(sourceSets. main. output. classesDirs)
30
- }
31
-
32
26
artifacts {
33
- archives publicationJar
27
+ archives jar
34
28
archives javadocJar
35
29
archives sourcesJar
36
30
}
48
42
' Created-By' : System . properties[' java.version' ] + " (" + System . properties[' java.vendor' ] + " " + System . properties[' java.vm.version' ] + " )" ,
49
43
' Build-Date' : project. buildDate,
50
44
' Build-Time' : project. buildTime,
51
- // 'Build-Revision': versioning.info.commit,
45
+ ' Build-Revision' : versioning. info. commit,
52
46
' Specification-Title' : project. name,
53
47
' Specification-Version' : project. version,
54
48
' Implementation-Title' : project. name,
@@ -59,76 +53,121 @@ jar {
59
53
60
54
61
55
def pomConfig = {
62
- name ext. publishing . pomName
63
- description ext. publishing . desc
64
- url ext. publishing . websiteUrl
65
- inceptionYear ext. publishing . inceptionYear
56
+ name ext. publishingInfo . pomName
57
+ description ext. publishingInfo . desc
58
+ url ext. publishingInfo . websiteUrl
59
+ inceptionYear ext. publishingInfo . inceptionYear
66
60
licenses {
67
61
license([:]) {
68
- name ext. publishing . license
69
- url ext. publishing . licenseUrl
62
+ name ext. publishingInfo . license
63
+ url ext. publishingInfo . licenseUrl
70
64
distribution ' repo'
71
65
}
72
66
}
73
67
scm {
74
- url ext. publishing . vcsUrl
75
- connection ext. publishing . vcsUrl
76
- developerConnection ext. publishing . vcsUrl
68
+ url ext. publishingInfo . vcsUrl
69
+ connection ext. publishingInfo . vcsUrl
70
+ developerConnection ext. publishingInfo . vcsUrl
77
71
}
78
72
developers {
79
73
developer {
80
- id ext. publishing . developerNameAlias
81
- name ext. publishing . developerName
74
+ id ext. publishingInfo . developerNameAlias
75
+ name ext. publishingInfo . developerName
82
76
}
83
77
}
84
78
}
85
79
80
+
81
+
86
82
publishing {
83
+
84
+ repositories {
85
+ // --------------------------------------------------------------------------------
86
+ // Destination Repository 'GitHubPackages'
87
+ // -> call task 'publishMavenJavaPublicationToGitHubPackagesRepository' to publish
88
+ // --------------------------------------------------------------------------------
89
+ maven {
90
+ name = " GitHubPackages"
91
+ // see https://levelup.gitconnected.com/publish-a-maven-package-to-github-with-gradle-fabc6de24d6
92
+ // Replace OWNER and REPOSITORY with your GitHub username/repository
93
+ // (must be both lowercase according to the documenations)
94
+ // url = uri("https://maven.pkg.github.com/OWNER/REPOSITORY")
95
+ url = uri(project. findProperty(' publishingInfo' ). gitHubMavenRepo)
96
+ credentials {
97
+ // Make sure to generate a token with write-packages and read-packages permission:
98
+ // https://github.com/settings/tokens/new
99
+ // You can either store the username and token in
100
+ // ~/.gradle/gradle.properties (use the gpr.user and gpr.key keys)
101
+ // Or you can store them as environment variables e.g. in ~/.bash_profile or ~/.zsh
102
+ // depending on your shell (GITHUB_USERNAME and GITHUB_TOKEN keys)
103
+ // Or you pass them via CLI: gradle publish -Pgpr.user=username -Pgpr.key=token
104
+ // See at EOF for examples on how to store the credentials
105
+ username = project. findProperty(" gpr.user" ) ?: System . getenv(" GITHUB_USERNAME" )
106
+ password = project. findProperty(" gpr.key" ) ?: System . getenv(" GITHUB_TOKEN" )
107
+ }
108
+ }
109
+
110
+ // --------------------------------------------------------------------------------
111
+ // Destination Repository 'OSSRH'
112
+ // telling gradle to publish artifact to local directory
113
+ // -> call task 'publishMavenJavaPublicationToOSSRHRepository' to publish
114
+ // -> go to https://oss.sonatype.org/#stagingRepositories, click 'close', drink coffee and then click 'release'
115
+ // if closing was successful
116
+ // --------------------------------------------------------------------------------
117
+ maven {
118
+ name = " OSSRH"
119
+ url " https://oss.sonatype.org/service/local/staging/deploy/maven2"
120
+ credentials {
121
+ username = project. findProperty(" oss.user" ) ?: System . getenv(" OSS_USERNAME" )
122
+ password = project. findProperty(" oss.pwd" ) ?: System . getenv(" OSS_PWD" )
123
+ }
124
+ }
125
+
126
+ // --------------------------------------------------------------------------------
127
+ // Destination Repository 'BuildDir'
128
+ // telling gradle to publish artifact to local directory
129
+ // -> call task 'publishMavenJavaPublicationToBuildDirRepository' to publish
130
+ // --------------------------------------------------------------------------------
131
+ maven {
132
+ name = " BuildDir"
133
+ url " file:/${ buildDir} /artifacts"
134
+ }
135
+ }
136
+
137
+
87
138
publications {
88
- mavenCustom (MavenPublication ) {
89
- groupId publishing . groupId
90
- artifactId publishing . artifactId
91
- version publishing . versionId
139
+ mavenJava (MavenPublication ) {
140
+ groupId publishingInfo . groupId
141
+ artifactId publishingInfo . artifactId
142
+ version publishingInfo . versionId
92
143
from components. java
93
144
artifact sourcesJar
94
145
artifact javadocJar
95
146
96
147
pom. withXml {
97
148
def root = asNode()
98
- root. appendNode ' description' , publishing. desc
99
- root. dependencies. ' *' . findAll() {
100
- it. groupId. text() == ' org.openjfx'
101
- }. each {
102
- it. remove(it. classifier)
103
- }
149
+ root. appendNode ' description' , publishingInfo. desc
104
150
root. children(). last() + pomConfig
105
151
}
106
152
}
107
153
}
108
154
}
109
155
110
- if (! project. hasProperty(' bintrayUsername' )) ext. bintrayUsername = ' '
111
- if (! project. hasProperty(' bintrayApiKey' )) ext. bintrayApiKey = ' '
112
-
113
- bintray {
114
- user = project. bintrayUsername
115
- key = project. bintrayApiKey
116
- publications = [' mavenCustom' ]
117
- pkg {
118
- repo = publishing. bintray. repo
119
- userOrg = publishing. bintray. userOrg
120
- name = publishing. bintray. name
121
- desc = publishing. desc
122
- licenses = [publishing. license]
123
- labels = publishing. labels
124
- websiteUrl = publishing. websiteUrl
125
- issueTrackerUrl = publishing. issueTrackerUrl
126
- vcsUrl = publishing. vcsUrl
127
- publicDownloadNumbers = true
128
-
129
- version {
130
- name = publishing. versionId
131
- vcsTag = ' v' + publishing. versionId
132
- }
156
+
157
+ if (
158
+ project. findProperty(" signing.secretKeyRingFile" )
159
+ && project. findProperty(" signing.password" )
160
+ && project. findProperty(" signing.keyId" )
161
+ ) {
162
+
163
+ signing {
164
+ sign publishing. publications
133
165
}
166
+
167
+ } else {
168
+ println " > skipping signing, provide\n " +
169
+ " - 'signing.secretKeyRingFile'\n " +
170
+ " - 'signing.password'\n " +
171
+ " - 'signing.keyId'\n " +
172
+ " to activate it\n "
134
173
}
0 commit comments