ci(java): try to use publications

This commit is contained in:
zaaarf 2024-10-16 01:07:34 +02:00
parent 2e583028a6
commit 5dcfd341d3
No known key found for this signature in database
GPG key ID: C91CFF9E2262BBA1
2 changed files with 42 additions and 8 deletions

1
.gitignore vendored
View file

@ -28,6 +28,7 @@ dist/java/.gradle/
dist/java/.project dist/java/.project
dist/java/.settings/ dist/java/.settings/
dist/java/bin/ dist/java/bin/
dist/java/artifacts/
# intellij insists on creating the wrapper every time even if it's not strictly necessary # intellij insists on creating the wrapper every time even if it's not strictly necessary
dist/java/gradle/ dist/java/gradle/

View file

@ -52,6 +52,16 @@ tasks.register('linuxJar', Jar) {
} }
} }
tasks.register('multiplatformJar', Jar) {
outputs.upToDateWhen { false }
archiveClassifier = 'all'
from sourceSets.main.runtimeClasspath
from('artifacts') {
include('*')
into('natives/')
}
}
configurations { configurations {
windowsJar { windowsJar {
canBeConsumed = true canBeConsumed = true
@ -68,15 +78,27 @@ configurations {
canBeResolved = false canBeResolved = false
extendsFrom implementation, runtimeOnly extendsFrom implementation, runtimeOnly
} }
multiplatformJar {
canBeConsumed = true
canBeResolved = false
extendsFrom implementation, runtimeOnly
}
} }
java { java {
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_11 sourceCompatibility = targetCompatibility = JavaVersion.VERSION_11
withSourcesJar()
withJavadocJar()
}
artifacts { artifacts {
archives jar
archives sourcesJar
archives javadocJar
windowsJar(windowsJar) windowsJar(windowsJar)
macosJar(macosJar) macosJar(macosJar)
linuxJar(linuxJar) linuxJar(linuxJar)
} multiplatformJar(multiplatformJar)
} }
repositories { repositories {
@ -116,14 +138,25 @@ tasks.register('nativeBuild', Jar) {
} }
} }
publishing {
publications {
mavenJava(MavenPublication) {
artifact jar
artifact sourcesJar
artifact javadocJar
artifact windowsJar
artifact linuxJar
artifact macosJar
artifact multiplatformJar
}
}
}
import com.vanniktech.maven.publish.SonatypeHost import com.vanniktech.maven.publish.SonatypeHost
import com.vanniktech.maven.publish.JavaLibrary
import com.vanniktech.maven.publish.JavadocJar
mavenPublishing { mavenPublishing {
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) //, true) // TODO re-enable autopublish! publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) //, true) // TODO re-enable autopublish!
signAllPublications() signAllPublications()
coordinates(project.group, rootProject.name, project.version) coordinates(project.group, rootProject.name, project.version)
configure(new JavaLibrary(new JavadocJar.Javadoc(), true))
pom { pom {
name = rootProject.name name = rootProject.name