Skip to content

Commit 41dfbd1

Browse files
committed
Central Portal migration. #503
1 parent 809cc5f commit 41dfbd1

9 files changed

Lines changed: 101 additions & 150 deletions

File tree

.github/CONTRIBUTING.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,9 @@ Some useful Gradle tasks include:
6767
- `check` - runs all tests in all projects.
6868
- `clean` - removes the `build` directories, which forces rebuilds of the modules.
6969
- `distZip` - prepares a zip archive with all jars in `build/distributions` folder. Useful for releases.
70-
- `publish` - pushes the archives to _Maven Central_ or the snapshot repository, depending on the
71-
[version](../version.txt). Requires complete `gradle.properties` with archive signing and _Sonatype_ logging data.
72-
- `closeAndReleaseRepository` - closes and releases the Nexus repository. Should be run after `publish` in case of
73-
a non-snapshot upload to _Maven Central_. Might fail at times on the release task; running `releaseRepository`
74-
separately should fix the issue.
70+
- `publishToMavenCentral` - pushes the archives to _Maven Central Portal_ or the snapshot repository, depending on
71+
the [version](../version.txt). Requires complete `gradle.properties` with _Sonatype_ credentials as well as the archive
72+
signing properties for non-snapshot releases.
7573

7674
### Adding a new KTX module
7775

@@ -168,9 +166,7 @@ Apply `dev` label and milestone corresponding to the libGDX version. An example
168166
- Create a pull request from the `develop` branch to the `master` branch. Review and merge the changes to the `master`
169167
branch.
170168
- Checkout the `master` branch. Fetch the latest changes.
171-
- Run `gradle build publish closeAndReleaseRepository` to push artifacts to _Maven Central_. Note that the Maven plugin
172-
has its issues and might fail with an error, but usually the release will be successful. You can check if the staging
173-
repository was properly close, promoted and released at [Nexus Repository Manager](https://oss.sonatype.org/).
169+
- Run `gradle build publishToMavenCentral` to push artifacts to the _Maven Central Portal_.
174170
- Run `gradle distZip` to prepare an archive with **KTX** sources, compiled binary and documentation.
175171
- Upload the archive to [releases](https://github.com/libktx/ktx/releases) section. The tag should be made from the
176172
`master` branch and its name should match the released version. Name of the release should match `KTX $libVersion`.
@@ -193,8 +189,8 @@ that the library was compiled against.
193189
if the current [version](../version.txt) is not a snapshot to avoid accidentally pushing a stable release.
194190

195191
Note that snapshots are automatically uploaded to Maven Central (OSS Sonatype)
196-
[snapshots repository](https://oss.sonatype.org/content/repositories/snapshots/io/github/libktx/) after pushing
197-
to the `develop` branch.
192+
[snapshots repository](https://central.sonatype.com/repository/maven-snapshots/)
193+
after pushing to the `develop` branch.
198194

199195
#### Automated tasks
200196

.github/workflows/upload-snapshot.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ jobs:
2525
- name: Upload snapshot to Maven Central
2626
run: ./gradlew build uploadSnapshot -x dokkaHtml
2727
env:
28-
ORG_GRADLE_PROJECT_ossrhUsername: ${{ secrets.ossrhUsername }}
29-
ORG_GRADLE_PROJECT_ossrhPassword: ${{ secrets.ossrhPassword }}
28+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.CENTRAL_USERNAME }}
29+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.CENTRAL_PASSWORD }}

CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
_See also: [the official libGDX changelog](https://github.com/libgdx/libgdx/blob/master/CHANGES)._
22

33
#### 1.13.5-SNAPSHOT
4+
45
- **[UPDATE]** Updated to libGDX 1.13.5.
5-
- **[UPDATE]** Updated `shape` extension function for tiled to support the new `TextMapObject`.
6-
- **[FEATURE]** Add a new `forEachCell` extension function for `TiledMapTileLayer` objects.
6+
- **[UPDATE]** Updated to Gradle 8.14.2.
7+
- **[MISC]** Migrated publishing from OSSRH to Maven Central Portal.
8+
- **[CHANGE]** (`ktx-tiled`) Updated `shape` extension function to support the new `TextMapObject`.
9+
- **[FEATURE]** (`ktx-tiled`) Add a new `forEachCell` extension function for `TiledMapTileLayer` objects.
710

811
#### 1.13.1-rc1
912

build.gradle.kts

Lines changed: 44 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import ktx.*
22
import org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
33
import org.gradle.api.tasks.testing.logging.TestLogEvent.*
4+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
45
import org.jetbrains.kotlin.gradle.dsl.jvm.JvmTargetValidationMode
56
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
7+
import com.vanniktech.maven.publish.JavadocJar
8+
import com.vanniktech.maven.publish.KotlinJvm
69

710
buildscript {
811
repositories {
@@ -24,11 +27,12 @@ buildscript {
2427
val libGroup: String by project
2528
val ossrhUsername: String by project
2629
val ossrhPassword: String by project
30+
val mavenPublishingPluginVersion: String by project
2731

2832
plugins {
2933
java
3034
distribution
31-
id("io.codearte.nexus-staging") version "0.22.0"
35+
id("com.vanniktech.maven.publish") version "0.33.0"
3236
}
3337

3438
repositories {
@@ -48,11 +52,11 @@ allprojects {
4852
}
4953

5054
subprojects {
51-
apply(plugin = "maven-publish")
5255
apply(plugin = "java")
5356
apply(plugin = "kotlin")
5457
apply(plugin = "signing")
5558
apply(plugin = "jacoco")
59+
apply(plugin = "com.vanniktech.maven.publish.base")
5660

5761
val isReleaseVersion = !libVersion.endsWith("SNAPSHOT")
5862

@@ -77,14 +81,14 @@ subprojects {
7781
}
7882

7983
tasks.withType<KotlinCompile> {
80-
kotlinOptions {
81-
jvmTarget = JavaVersion.VERSION_1_8.toString()
82-
freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn"
84+
compilerOptions {
85+
jvmTarget.set(JvmTarget.JVM_1_8)
86+
freeCompilerArgs.add("-opt-in=kotlin.RequiresOptIn")
8387
}
8488
jvmTargetValidationMode.set(JvmTargetValidationMode.IGNORE)
8589
}
8690
val compileTestKotlin: KotlinCompile by tasks
87-
compileTestKotlin.kotlinOptions.jvmTarget = JavaVersion.VERSION_11.toString()
91+
compileTestKotlin.compilerOptions.jvmTarget.set(JvmTarget.JVM_11)
8892

8993
dependencies {
9094
val kotlinVersion: String by project
@@ -140,117 +144,54 @@ subprojects {
140144
}
141145

142146
val dokkaHtml by tasks.getting
143-
144147
tasks.register<Zip>("dokkaZip") {
145-
from("$buildDir/dokka/html")
146-
dependsOn(dokkaHtml)
147-
}
148-
149-
val javadocJar by tasks.registering(Jar::class) {
150-
archiveClassifier.set("javadoc")
151-
from("$buildDir/dokka/html")
148+
from("${layout.buildDirectory}/dokka/html")
152149
dependsOn(dokkaHtml)
153150
}
154151

155-
val sourcesJar by tasks.registering(Jar::class) {
156-
from(sourceSets.main.get().allSource)
157-
archiveClassifier.set("sources")
158-
}
159-
160-
artifacts {
161-
archives(javadocJar)
162-
archives(sourcesJar)
163-
}
164-
165-
afterEvaluate {
166-
rootProject.distributions {
167-
main {
168-
distributionBaseName.set(libVersion)
169-
contents {
170-
into("lib") {
171-
from(tasks.jar)
172-
}
173-
into("doc") {
174-
from(tasks["dokkaZip"])
175-
}
176-
into("src") {
177-
from(tasks["sourcesJar"])
178-
}
179-
}
180-
}
152+
mavenPublishing {
153+
publishToMavenCentral(automaticRelease = true)
154+
if (isReleaseVersion) {
155+
signAllPublications()
181156
}
182-
}
183-
184-
tasks.register("uploadSnapshot") {
185-
if (!isReleaseVersion) finalizedBy(tasks["publishAllPublicationsToMavenRepository"])
186-
}
187-
188-
configure<PublishingExtension> {
189-
repositories {
190-
maven {
191-
val releasesRepoUrl = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
192-
val snapshotsRepoUrl = uri("https://oss.sonatype.org/content/repositories/snapshots/")
193-
url = if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl
194-
195-
credentials {
196-
username = ossrhUsername
197-
password = ossrhPassword
157+
configure(KotlinJvm(
158+
javadocJar = if (isReleaseVersion) JavadocJar.Dokka("dokkaHtml") else JavadocJar.None(),
159+
sourcesJar = true
160+
))
161+
162+
coordinates(libGroup, projectName, libVersion)
163+
164+
pom {
165+
name.set(projectName)
166+
description.set(projectDesc)
167+
inceptionYear.set("2016")
168+
url.set("https://github.com/libktx/ktx")
169+
licenses {
170+
license {
171+
name.set("CC0-1.0")
172+
url.set("https://creativecommons.org/publicdomain/zero/1.0/")
198173
}
199174
}
200-
}
201-
202-
publications {
203-
create<MavenPublication>("mavenKtx") {
204-
pom {
205-
name.set(projectName)
206-
packaging = "jar"
207-
description.set(projectDesc)
208-
afterEvaluate {
209-
artifactId = tasks.jar.get().archiveBaseName.get()
210-
}
211-
212-
from(components["kotlin"])
213-
artifact(sourcesJar)
214-
artifact(javadocJar)
215-
216-
url.set("https://libktx.github.io/")
217-
218-
licenses {
219-
license {
220-
name.set("CC0-1.0")
221-
url.set("https://creativecommons.org/publicdomain/zero/1.0/")
222-
}
223-
}
224-
225-
scm {
226-
connection.set("scm:git:git@github.com:libktx/ktx.git")
227-
developerConnection.set("scm:git:git@github.com:libktx/ktx.git")
228-
url.set("https://github.com/libktx/ktx/")
229-
}
230-
231-
developers {
232-
developer {
233-
id.set("mj")
234-
name.set("MJ")
235-
}
236-
}
175+
developers {
176+
developer {
177+
id.set("mj")
178+
name.set("MJ")
179+
url.set("https://github.com/czyzby")
237180
}
238181
}
182+
scm {
183+
url.set("https://github.com/libktx/ktx")
184+
connection.set("scm:git:git://github.com/libktx/ktx.git")
185+
developerConnection.set("scm:git:ssh://git@github.com/libktx/ktx.git")
186+
}
239187
}
240188
}
241189

242-
tasks.withType<Sign> { onlyIf { isReleaseVersion } }
243-
244-
configure<SigningExtension> {
245-
setRequired { isReleaseVersion && gradle.taskGraph.hasTask("publish") }
246-
sign(extensions.getByType<PublishingExtension>().publications["mavenKtx"])
190+
tasks.register("uploadSnapshot") {
191+
if (!isReleaseVersion) finalizedBy(tasks["publishToMavenCentral"])
247192
}
248-
}
249193

250-
nexusStaging {
251-
packageGroup = libGroup
252-
username = ossrhUsername
253-
password = ossrhPassword
194+
tasks.withType<Sign> { onlyIf { isReleaseVersion } }
254195
}
255196

256197
tasks.register<JavaExec>("linterIdeSetup") {

gradle.properties

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ kotlinVersion=2.1.10
55
dokkaVersion=2.0.0
66
junitPlatformVersion=1.2.0
77
configurationsPluginVersion=3.0.3
8+
mavenPublishingPluginVersion=0.33.0
9+
10+
org.gradle.jvmargs=-Xmx1024m
811

912
# The following properties are mock-ups. To deploy the archives,
1013
# you need to fill these with proper data. To avoid accidental
@@ -16,8 +19,6 @@ configurationsPluginVersion=3.0.3
1619
#signing.password=
1720
#signing.secretKeyRingFile=
1821

19-
# Jira logging data:
20-
ossrhUsername=
21-
ossrhPassword=
22-
23-
org.gradle.jvmargs=-Xmx1024m
22+
# Maven Central logging data:
23+
mavenCentralUsername=
24+
mavenCentralPassword=

gradle/wrapper/gradle-wrapper.jar

-17.4 KB
Binary file not shown.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.4-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-all.zip
44
networkTimeout=10000
5+
validateDistributionUrl=true
56
zipStoreBase=GRADLE_USER_HOME
67
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)