1
1
plugins {
2
2
id ' java'
3
- id ' maven'
4
3
id ' maven-publish'
5
4
id ' java-gradle-plugin'
6
- id ' com.gradle.plugin-publish' version ' 0.12 .0'
5
+ id ' com.gradle.plugin-publish' version ' 1.1 .0'
7
6
id ' io.codearte.nexus-staging' version ' 0.21.2'
8
7
id ' eclipse'
9
8
id ' de.undercouch.download' version ' 5.0.4'
9
+ id ' signing'
10
10
}
11
11
12
12
repositories {
@@ -18,22 +18,16 @@ repositories {
18
18
}
19
19
20
20
gradlePlugin {
21
- plugins {
22
- javaPackagerPlugin {
23
- id = ' io.github.fvarrui.javapackager.plugin'
24
- implementationClass = ' io.github.fvarrui.javapackager.gradle.PackagePlugin'
25
- }
26
- }
27
- }
28
-
29
- pluginBundle {
30
21
website = ' http://github.com/fvarrui/JavaPackager'
31
22
vcsUrl = ' http://github.com/fvarrui/JavaPackager.git'
32
23
description = ' Packages Java applications as native Windows, MacOS or GNU/Linux executables and creates installers for them'
33
- tags = [ ' java ' , ' packager ' , ' gradle-plugin ' , ' maven-plugin ' , ' native ' , ' installer ' , ' debian-packages ' , ' rpm-packages ' , ' dmg ' , ' maven ' , ' gradle ' , ' distribution ' , ' javapackager ' , ' linux-executables ' , ' deb ' , ' rpm ' , ' native-windows ' , ' java-applications ' , ' pkg ' , ' msi ' ]
24
+
34
25
plugins {
35
- javaPackagerPlugin {
26
+ create(" javaPackagerPlugin" ) {
27
+ id = ' io.github.fvarrui.javapackager.plugin'
36
28
displayName = ' JavaPackager'
29
+ implementationClass = ' io.github.fvarrui.javapackager.gradle.PackagePlugin'
30
+ tags. set([' java' , ' packager' , ' gradle-plugin' , ' maven-plugin' , ' native' , ' installer' , ' debian-packages' , ' rpm-packages' , ' dmg' , ' maven' , ' gradle' , ' distribution' , ' javapackager' , ' linux-executables' , ' deb' , ' rpm' , ' native-windows' , ' java-applications' , ' pkg' , ' msi' ])
37
31
}
38
32
}
39
33
}
@@ -78,150 +72,111 @@ targetCompatibility = JavaVersion.VERSION_1_8
78
72
79
73
compileJava. options. encoding = ' UTF-8'
80
74
75
+ java {
76
+ withSourcesJar()
77
+ withJavadocJar()
78
+ }
79
+
80
+ build. dependsOn ' :winrun4j-launcher:build'
81
+
82
+ // OSSRH publication
81
83
publishing {
82
- publications {
83
- mavenJava(MavenPublication ) {
84
- from(components. java)
84
+ repositories {
85
+ maven {
86
+ name = " OSSRH"
87
+ url = " https://oss.sonatype.org/service/local/staging/deploy/maven2/"
88
+
89
+ url = " https://oss.sonatype.org/service/local/staging/deploy/maven2/"
90
+
91
+ credentials {
92
+ username = project. findProperty(" ossrhUser" ) ?: ' '
93
+ password = project. findProperty(" ossrhPassword" ) ?: ' '
94
+ }
85
95
}
86
96
}
87
- }
97
+ publications {
98
+ pluginMaven(MavenPublication ) {
99
+ def directory = buildDir. canonicalPath
100
+ def outputDirectory = compileJava. destinationDirectory. asFile. get(). canonicalPath
101
+ pom. withXml {
102
+ asNode(). appendNode(' build' )
103
+ .with {
104
+ appendNode(' directory' , directory)
105
+ appendNode(' outputDirectory' , outputDirectory)
106
+ }
107
+ }
88
108
89
- java {
90
- withSourcesJar()
91
- // and/or analogously use "withJavadocJar()" to get a "javadocJar" task
92
- }
109
+ pom {
110
+ groupId = project. group
111
+ artifactId = project. name
112
+ version = project. version
113
+ description = project. description
93
114
94
- install. repositories. mavenInstaller. pom. with {
95
- groupId = project. group
96
- artifactId = project. name
97
- version = project. version
98
- description = project. description
99
- packaging = ' maven-plugin'
100
- }
115
+ packaging = ' maven-plugin'
116
+ url = ' https://github.com/fvarrui/JavaPackager'
101
117
102
- build. dependsOn ' :winrun4j-launcher:build'
118
+ scm {
119
+ connection = ' scm:git:git://github.com/fvarrui/JavaPackager.git'
120
+ developerConnection
= ' scm:git:[email protected] :fvarrui/fvarrui.git'
121
+ url = ' https://github.com/fvarrui/JavaPackager'
122
+ }
123
+
124
+ licenses {
125
+ license {
126
+ name = ' GPL-v3.0'
127
+ url = ' http://www.gnu.org/licenses/gpl-3.0.txt'
128
+ distribution = ' repo'
129
+ }
130
+ }
131
+
132
+ developers {
133
+ developer {
134
+ id = ' fvarrui'
135
+ name = ' Francisco Vargas Ruiz'
136
+ url = ' https://github.com/fvarrui'
137
+ }
138
+ }
139
+ }
140
+ }
141
+ }
142
+ }
103
143
104
144
// runs the plugin description generator
105
145
task generatePluginDescriptor (type : JavaExec , dependsOn : compileJava) {
106
-
107
- def pomFile = file(" $buildDir /pom.xml" )
108
- def pluginDescriptorFile = new File (project. compileJava. destinationDir, ' META-INF/maven/plugin.xml' )
109
- def directory = buildDir. canonicalPath
110
- def outputDirectory = compileJava. destinationDir. canonicalPath
146
+ def pluginDescriptorFile = new File (project. compileJava. destinationDirectory. asFile. get(), ' META-INF/maven/plugin.xml' )
111
147
112
148
// FIXME: this does not seem to be working
113
149
inputs. files project. compileJava. outputs. files
114
150
outputs. file pluginDescriptorFile
115
151
116
152
classpath = configurations. mavenEmbedder
117
- main = ' org.apache.maven.cli.MavenCli'
153
+ mainClass = ' org.apache.maven.cli.MavenCli'
118
154
systemProperties[' maven.multiModuleProjectDirectory' ] = projectDir
119
155
args = [
120
156
' --errors' ,
121
157
' --batch-mode' ,
122
- ' --file' , " ${ buildDir } /pom.xml " ,
158
+ ' --file' , generatePomFileForPluginMavenPublication . destination ,
123
159
' org.apache.maven.plugins:maven-plugin-plugin:3.6.0:descriptor' ,
124
160
' -Dproject.build.sourceEncoding=' + compileJava. options. encoding
125
161
]
126
-
127
- doFirst {
128
- install. repositories
129
- .mavenInstaller
130
- .pom
131
- .withXml {
132
- asNode(). appendNode(' repositories' ). appendNode(' repository' )
133
- .with {
134
- appendNode(' id' , ' gradle' )
135
- appendNode(' name' , ' Gradle Plugin Portal' )
136
- appendNode(' url' , ' https://plugins.gradle.org/m2/' )
137
- }
138
- asNode(). appendNode(' build' )
139
- .with {
140
- appendNode(' directory' , directory)
141
- appendNode(' outputDirectory' , outputDirectory)
142
- }
143
- }
144
- .writeTo(pomFile)
145
-
146
- assert pomFile. file, " ${ pomFile.canonicalPath} : was not generated"
147
- logger. info(" POM is generated in ${ pomFile.canonicalPath} " )
148
- }
149
-
150
162
doLast {
151
163
assert pluginDescriptorFile. file, " ${ pluginDescriptorFile.canonicalPath} : was not generated"
152
164
logger. info(" Plugin descriptor is generated in ${ pluginDescriptorFile.canonicalPath} " )
153
165
}
154
166
}
167
+ generatePluginDescriptor. dependsOn(generatePomFileForPluginMavenPublication)
155
168
156
- project. jar. dependsOn(generatePluginDescriptor)
169
+ project. classes. dependsOn(generatePluginDescriptor)
170
+ project. validatePlugins. dependsOn(generatePluginDescriptor)
157
171
publishToMavenLocal. dependsOn(build)
158
-
159
- if (project. hasProperty(' release' )) {
160
-
161
- apply plugin : ' signing'
162
- apply plugin : ' maven'
163
172
164
- task deployingJavadocJar(type : Jar ) {
165
- classifier = ' javadoc'
166
- from javadoc
167
- }
168
-
169
- task deployingSourcesJar(type : Jar ) {
170
- classifier = ' sources'
171
- from sourceSets. main. allSource
172
- }
173
-
174
- artifacts {
175
- archives deployingJavadocJar, deployingSourcesJar
176
- }
177
-
178
- // Signature of artifacts
179
- signing {
180
- sign configurations. archives
181
- }
182
-
183
- // OSSRH publication
184
- uploadArchives {
185
- repositories {
186
- mavenDeployer {
187
- // POM signature
188
- beforeDeployment { MavenDeployment deployment -> signing. signPom(deployment) }
189
- // Target repository
190
- repository(url : " https://oss.sonatype.org/service/local/staging/deploy/maven2/" ) {
191
- authentication(userName : ossrhUser, password : ossrhPassword)
192
- }
193
- pom. project {
194
- name project. name
195
- description project. description
196
- packaging = ' maven-plugin'
197
- url ' https://github.com/fvarrui/JavaPackager'
198
-
199
- scm {
200
- connection ' scm:git:git://github.com/fvarrui/JavaPackager.git'
201
- developerConnection
' scm:git:[email protected] :fvarrui/fvarrui.git'
202
- url ' https://github.com/fvarrui/JavaPackager'
203
- }
204
-
205
- licenses {
206
- license {
207
- name ' GPL-v3.0'
208
- url ' http://www.gnu.org/licenses/gpl-3.0.txt'
209
- distribution ' repo'
210
- }
211
- }
212
-
213
- developers {
214
- developer {
215
- id = ' fvarrui'
216
- name = ' Francisco Vargas Ruiz'
217
- url = ' https://github.com/fvarrui'
218
- }
219
- }
220
- }
221
- }
222
- }
173
+ // Signature of publication
174
+ signing {
175
+ setRequired {
176
+ // signing is only required if the artifacts are to be published
177
+ gradle. taskGraph. allTasks. any { it instanceof PublishToMavenRepository }
223
178
}
224
-
179
+ sign publishing . publications . pluginMaven
225
180
}
226
181
227
182
nexusStaging {
0 commit comments