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
1619
1720plugins {
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
2429description = " 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
2935subprojects {
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
58182subprojects {
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}
0 commit comments