Skip to content

Commit 34b4395

Browse files
Changed nexus publish plugin with jreleaser plugin
1 parent a2d75a3 commit 34b4395

21 files changed

Lines changed: 175 additions & 155 deletions

File tree

build.gradle.kts

Lines changed: 153 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import org.jreleaser.model.Active
2+
import org.jreleaser.model.Stereotype
3+
14
/**
25
* To build Robocode, you need to run this command:
36
* ./gradlew build
@@ -16,23 +19,83 @@
1619

1720
plugins {
1821
`java-library`
22+
`maven-publish`
23+
signing
1924
idea
20-
alias(libs.plugins.nexus.publish)
25+
alias(libs.plugins.jreleaser)
2126
alias(libs.plugins.ben.manes.versions)
2227
}
2328

2429
description = "Robocode - Build the best - destroy the rest!"
2530

26-
val ossrhUsername: String by project
27-
val ossrhPassword: String by project
31+
// Environment variables for Maven Central Publisher API
32+
val mavenCentralUsername: String by project
33+
val mavenCentralPassword: String by project
2834

2935
subprojects {
3036
apply(plugin = "java")
37+
apply(plugin = "maven-publish")
38+
apply(plugin = "signing")
3139

3240
java {
3341
toolchain {
3442
languageVersion.set(JavaLanguageVersion.of(8))
3543
}
44+
withSourcesJar()
45+
withJavadocJar()
46+
}
47+
48+
publishing {
49+
publications {
50+
create<MavenPublication>("maven") {
51+
from(components["java"])
52+
53+
pom {
54+
name = project.name
55+
description = project.description ?: "Robocode module"
56+
url = "https://github.com/robocode-dev/robocode"
57+
58+
licenses {
59+
license {
60+
name = "EPL-v10"
61+
url = "http://www.eclipse.org/legal/epl-v10.html"
62+
}
63+
}
64+
65+
developers {
66+
developer {
67+
id = "robocode-dev"
68+
name = "Robocode Development Team"
69+
}
70+
}
71+
72+
scm {
73+
connection = "scm:git:git://github.com/robocode-dev/robocode.git"
74+
developerConnection = "scm:git:ssh://github.com:robocode-dev/robocode.git"
75+
url = "https://github.com/robocode-dev/robocode/tree/master"
76+
}
77+
}
78+
}
79+
}
80+
81+
repositories {
82+
maven {
83+
name = "staging"
84+
url = uri(layout.buildDirectory.dir("staging-deploy"))
85+
}
86+
}
87+
}
88+
89+
signing {
90+
val signingKey: String? by project
91+
val signingPassword: String? by project
92+
useInMemoryPgpKeys(signingKey, signingPassword)
93+
sign(publishing.publications["maven"])
94+
}
95+
96+
// Fix the task dependency issue
97+
tasks.withType<PublishToMavenRepository>().configureEach {
98+
dependsOn(tasks.withType<Sign>())
3699
}
37100
}
38101

@@ -42,21 +105,97 @@ tasks {
42105
}
43106
}
44107

45-
nexusPublishing {
46-
repositories {
47-
sonatype {
48-
nexusUrl.set(uri("https://oss.sonatype.org/service/local/"))
49-
snapshotRepositoryUrl.set(uri("https://oss.sonatype.org/content/repositories/snapshots/"))
50-
stagingProfileId.set("c7f511545ccf8")
51-
username.set(ossrhUsername)
52-
password.set(ossrhPassword)
108+
jreleaser {
109+
project {
110+
name = "robocode"
111+
description = "Robocode: Build the best - destroy the rest!"
112+
longDescription =
113+
"Robocode is a programming game, where the goal is to develop a robot battle tank to battle against other tanks in Java."
114+
website = "https://robocode.sourceforge.io/"
115+
authors = listOf("Robocode Development Team")
116+
license = "EPL-v10"
117+
copyright = "2001-2025 Robocode Development Team"
118+
}
119+
120+
release {
121+
github {
122+
skipRelease = true // Skip GitHub release creation for now
123+
}
124+
}
125+
126+
signing {
127+
active = Active.ALWAYS
128+
armored = true
129+
}
130+
131+
deploy {
132+
maven {
133+
// local staging repository
134+
artifactory {
135+
create("local") {
136+
enabled = true // Always enable local staging
137+
active = Active.ALWAYS // Always active regardless of version type
138+
139+
url = file("build/staging-deploy").toURI().toString()
140+
141+
stagingRepositories = listOf("build/staging-deploy")
142+
}
143+
}
144+
145+
mavenCentral {
146+
create("releases") {
147+
active = Active.ALWAYS
148+
url = "https://central.sonatype.com/api/v1/publisher"
149+
150+
stagingRepositories = listOf("build/staging-deploy")
151+
152+
username = mavenCentralUsername
153+
password = mavenCentralPassword
154+
155+
// Support for snapshot releases
156+
snapshotSupported = true
157+
}
158+
}
159+
}
160+
}
161+
162+
distributions {
163+
create("robocode.api") {
164+
enabled = true
165+
active = Active.ALWAYS
166+
distributionType = org.jreleaser.model.Distribution.DistributionType.JAVA_BINARY
167+
stereotype = Stereotype.CLI
168+
169+
artifact {
170+
path = file("robocode.api/build/libs/robocode.jar")
171+
}
172+
173+
java {
174+
enabled = true
175+
mainClass = "robocode.Robocode"
176+
}
53177
}
54178
}
55179
}
56180

57-
val initializeSonatypeStagingRepository by tasks.existing
181+
// Configure signing for subprojects
58182
subprojects {
59-
initializeSonatypeStagingRepository {
60-
shouldRunAfter(tasks.withType<Sign>())
183+
afterEvaluate {
184+
if (plugins.hasPlugin("maven-publish")) {
185+
configure<PublishingExtension> {
186+
repositories {
187+
maven {
188+
name = "staging"
189+
url = uri("${rootProject.buildDir}/staging-deploy")
190+
// Configure metadata sources explicitly
191+
isAllowInsecureProtocol = false
192+
metadataSources {
193+
mavenPom()
194+
artifact()
195+
}
196+
}
197+
}
198+
}
199+
}
61200
}
62201
}

buildSrc/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
plugins {
22
java
33
`kotlin-dsl`
4-
alias(libs.plugins.nexus.publish)
4+
alias(libs.plugins.jreleaser)
55
}
66

77
repositories {

buildSrc/src/main/kotlin/net.sf.robocode.java-conventions.gradle.kts

Lines changed: 5 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ group = "net.sf.robocode"
22

33
plugins {
44
java
5-
signing
6-
`maven-publish`
5+
`java-library`
76
}
87

98
repositories {
@@ -20,61 +19,16 @@ java {
2019
toolchain {
2120
languageVersion.set(JavaLanguageVersion.of(8))
2221
}
22+
withSourcesJar()
23+
withJavadocJar()
2324
}
2425

2526
tasks {
2627
withType<JavaCompile> {
2728
options.encoding = "UTF-8"
2829
}
29-
}
3030

31-
publishing {
32-
publications {
33-
create<MavenPublication>("mavenJava") {
34-
from(components["java"])
35-
versionMapping {
36-
usage("java-api") {
37-
fromResolutionOf("runtimeClasspath")
38-
}
39-
usage("java-runtime") {
40-
fromResolutionResult()
41-
}
42-
}
43-
pom {
44-
name.set("Robocode")
45-
description.set("Build the best - destroy the rest!")
46-
url.set("https://robocode.sourceforge.io/")
47-
licenses {
48-
license {
49-
name.set("Eclipse Public License v1.0 (EPL)")
50-
url.set("https://robocode.sourceforge.io/license/epl-v10.html")
51-
}
52-
}
53-
developers {
54-
developer {
55-
name.set("Mathew A. Nelson")
56-
}
57-
developer {
58-
id.set("flemming-n-larsen")
59-
name.set("Flemming N. Larsen")
60-
email.set("flemming.n.larsen@gmail.com")
61-
}
62-
developer {
63-
id.set("pavel.savara")
64-
name.set("Pavel Savara")
65-
email.set("pavel.savara@gmail.com")
66-
}
67-
}
68-
scm {
69-
connection.set("scm:git:git@github.com:robo-code/robocode.git")
70-
developerConnection.set("scm:git:ssh:git@github.com:robo-code/robocode.git")
71-
url.set("https://github.com/robo-code/robocode")
72-
}
73-
}
74-
}
31+
withType<Javadoc> {
32+
options.encoding = "UTF-8"
7533
}
7634
}
77-
78-
signing {
79-
sign(publishing.publications["mavenJava"])
80-
}

gradle.properties

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
# The version of Robocode
2-
version=1.9.5.5
3-
4-
# These are set to dummy values as they don't exist when run on GitHub actions
5-
ossrhUsername=dummy
6-
ossrhPassword=dummy
1+
# The version of Robocode
2+
version=1.9.5.6-SNAPSHOT
3+
group=net.sf.robocode
4+
# Disable unique timestamped versions for snapshots
5+
maven.repo.local.uniqueVersion=false
6+
# Build performance settings
7+
org.gradle.parallel=true
8+
org.gradle.caching=true
9+
org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError
10+
# These are set to dummy values as they don't exist when run on GitHub actions
11+
mavenCentralUsername=dummy
12+
mavenCentralPassword=dummy

gradle/libs.versions.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
picocontainer="2.15"
44
codesize="1.3.0"
5-
nexus-publish = "2.0.0"
5+
jreleaser = "1.18.0"
66
ben-manes-versions = "0.51.0"
77
eclipse-jdt = "3.39.0"
88
kotlin = "2.0.20"
@@ -20,7 +20,7 @@ bcel = { module = "org.apache.bcel:bcel", version.ref = "bcel" }
2020

2121
[plugins]
2222

23-
nexus-publish = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "nexus-publish" }
23+
jreleaser = { id = "org.jreleaser", version.ref = "jreleaser" }
2424

25-
# ./gradlew dependencyUpdates -Drevision=release
25+
# `./gradlew dependencyUpdates`
2626
ben-manes-versions = { id = "com.github.ben-manes.versions", version.ref = "ben-manes-versions" }

robocode.api/build.gradle.kts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
plugins {
22
id("net.sf.robocode.java-conventions")
33
java
4-
signing
5-
`maven-publish`
6-
}
7-
8-
java {
9-
withJavadocJar()
10-
withSourcesJar()
114
}
125

136
description = "Robocode API"

robocode.battle/build.gradle.kts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ dependencies {
1414

1515
description = "Robocode Battle"
1616

17-
java {
18-
withJavadocJar()
19-
withSourcesJar()
20-
}
21-
2217
tasks {
2318
javadoc {
2419
source = sourceSets["main"].java

robocode.content/build.gradle.kts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,4 @@ tasks {
148148
dependsOn(copyExternalLibs)
149149
dependsOn(copyCompilers)
150150
}
151-
152-
publishMavenJavaPublicationToSonatypeRepository {
153-
enabled = false
154-
}
155151
}

robocode.core/build.gradle.kts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ dependencies {
1212

1313
description = "Robocode Core"
1414

15-
java {
16-
withJavadocJar()
17-
withSourcesJar()
18-
}
19-
2015
tasks {
2116
val copyVersion by registering(Copy::class) {
2217
from("../") {

robocode.host/build.gradle.kts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ dependencies {
1313

1414
description = "Robocode Host"
1515

16-
java {
17-
withJavadocJar()
18-
withSourcesJar()
19-
}
20-
2116
tasks {
2217
javadoc {
2318
source = sourceSets["main"].java

0 commit comments

Comments
 (0)