Skip to content

Commit 9243f3c

Browse files
committed
Upgrade to gradle 8
1 parent 326df53 commit 9243f3c

File tree

4 files changed

+86
-132
lines changed

4 files changed

+86
-132
lines changed

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ cd JavaPackager
309309
Run next command (ommit `./` on Windows):
310310

311311
```bash
312-
./gradlew -Prelease uploadArchives closeAndReleaseRepository
312+
./gradlew publish closeAndReleaseRepository
313313
```
314314

315315
> Related [guide](https://nemerosa.ghost.io/2015/07/01/publishing-to-the-maven-central-using-gradle/).

Diff for: build.gradle

+81-126
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
plugins {
22
id 'java'
3-
id 'maven'
43
id 'maven-publish'
54
id 'java-gradle-plugin'
6-
id 'com.gradle.plugin-publish' version '0.12.0'
5+
id 'com.gradle.plugin-publish' version '1.1.0'
76
id 'io.codearte.nexus-staging' version '0.21.2'
87
id 'eclipse'
98
id 'de.undercouch.download' version '5.0.4'
9+
id 'signing'
1010
}
1111

1212
repositories {
@@ -18,22 +18,16 @@ repositories {
1818
}
1919

2020
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 {
3021
website = 'http://github.com/fvarrui/JavaPackager'
3122
vcsUrl = 'http://github.com/fvarrui/JavaPackager.git'
3223
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+
3425
plugins {
35-
javaPackagerPlugin {
26+
create("javaPackagerPlugin") {
27+
id = 'io.github.fvarrui.javapackager.plugin'
3628
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'])
3731
}
3832
}
3933
}
@@ -78,150 +72,111 @@ targetCompatibility = JavaVersion.VERSION_1_8
7872

7973
compileJava.options.encoding = 'UTF-8'
8074

75+
java {
76+
withSourcesJar()
77+
withJavadocJar()
78+
}
79+
80+
build.dependsOn ':winrun4j-launcher:build'
81+
82+
// OSSRH publication
8183
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+
}
8595
}
8696
}
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+
}
88108

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
93114

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'
101117

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+
}
103143

104144
// runs the plugin description generator
105145
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')
111147

112148
// FIXME: this does not seem to be working
113149
inputs.files project.compileJava.outputs.files
114150
outputs.file pluginDescriptorFile
115151

116152
classpath = configurations.mavenEmbedder
117-
main = 'org.apache.maven.cli.MavenCli'
153+
mainClass = 'org.apache.maven.cli.MavenCli'
118154
systemProperties['maven.multiModuleProjectDirectory'] = projectDir
119155
args = [
120156
'--errors',
121157
'--batch-mode',
122-
'--file', "${buildDir}/pom.xml",
158+
'--file', generatePomFileForPluginMavenPublication.destination,
123159
'org.apache.maven.plugins:maven-plugin-plugin:3.6.0:descriptor',
124160
'-Dproject.build.sourceEncoding=' + compileJava.options.encoding
125161
]
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-
150162
doLast {
151163
assert pluginDescriptorFile.file, "${pluginDescriptorFile.canonicalPath}: was not generated"
152164
logger.info("Plugin descriptor is generated in ${pluginDescriptorFile.canonicalPath}")
153165
}
154166
}
167+
generatePluginDescriptor.dependsOn(generatePomFileForPluginMavenPublication)
155168

156-
project.jar.dependsOn(generatePluginDescriptor)
169+
project.classes.dependsOn(generatePluginDescriptor)
170+
project.validatePlugins.dependsOn(generatePluginDescriptor)
157171
publishToMavenLocal.dependsOn(build)
158-
159-
if (project.hasProperty('release')) {
160-
161-
apply plugin: 'signing'
162-
apply plugin: 'maven'
163172

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 }
223178
}
224-
179+
sign publishing.publications.pluginMaven
225180
}
226181

227182
nexusStaging {

Diff for: gradle/wrapper/gradle-wrapper.properties

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionSha256Sum=7faa7198769f872826c8ef4f1450f839ec27f0b4d5d1e51bade63667cbccd205
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
54
zipStoreBase=GRADLE_USER_HOME
6-
zipStorePath=wrapper/dists
5+
zipStorePath=wrapper/dists

Diff for: winrun4j-launcher/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ ext {
1616
}
1717

1818
jar {
19-
archiveBaseName = baseName
20-
archiveVersion = version
19+
archiveBaseName = project.baseName
20+
archiveVersion = project.version
2121
}
2222

2323
task copyArtifact {

0 commit comments

Comments
 (0)