Skip to content

Commit

Permalink
Proper publishing setup (#17)
Browse files Browse the repository at this point in the history
* Attempt at fixing published artifact

* wohoo it works

* attempt at excluding bootstrap's shadow jar from publishing

* Update gradle, fix publishing (aka, dont publish shadowed bootstrap build to maven)

* Don't apply shadow plugin for the converter

* why are we publishing the lib as an artifact...?

* make these implementation

* Shade bedrock-pack-schema into pack-schema-api
  • Loading branch information
onebeastchris authored Mar 13, 2024
1 parent 0a1114b commit 7a2caf6
Show file tree
Hide file tree
Showing 11 changed files with 108 additions and 79 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,6 @@ jobs:
path: bootstrap/build/libs/PackConverter.jar
if-no-files-found: error

- name: Archive artifacts (Converter)
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32
if: success()
with:
name: PackConverter Library
path: converter/build/libs/PackConverter-lib.jar
if-no-files-found: error

- name: Publish to Maven Repository
if: ${{ success() && github.repository == 'GeyserMC/PackConverter' && github.ref_name == 'master' }}
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5
Expand Down
17 changes: 11 additions & 6 deletions bootstrap/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
plugins {
id("application")
`java-library`
application
id("com.github.johnrengelman.shadow") apply true
}

sourceSets {
main {
resources {
srcDir("src/main/java/resources")
}
}
}

dependencies {
Expand All @@ -11,10 +21,5 @@ application {
}

tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> {
from("src/main/java/resources") {
include("*")
}

archiveFileName.set("PackConverter.jar")
archiveClassifier.set("")
}
12 changes: 12 additions & 0 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
plugins {
`kotlin-dsl`
}

dependencies {
implementation("com.github.johnrengelman:shadow:8.1.1")
}

repositories {
gradlePluginPortal()
mavenCentral()
}
1 change: 1 addition & 0 deletions build-logic/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = "build-logic"
5 changes: 5 additions & 0 deletions build-logic/src/main/kotlin/pack.base-conventions.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import org.gradle.kotlin.dsl.`java-library`

plugins {
`java-library`
}
25 changes: 25 additions & 0 deletions build-logic/src/main/kotlin/pack.publish-conventions.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
plugins {
`maven-publish` apply true
id("com.github.johnrengelman.shadow") apply false
}

publishing {
repositories {
val repoName = if (version.toString().endsWith("SNAPSHOT")) "maven-snapshots" else "maven-releases"
maven("https://repo.opencollab.dev/${repoName}/") {
credentials.username = System.getenv("OPENCOLLAB_USERNAME")
credentials.password = System.getenv("OPENCOLLAB_PASSWORD")
name = "opencollab"
}
}

publications {
register("publish", MavenPublication::class) {
from(project.components["java"])

// skip shadow jar from publishing. Workaround for https://github.com/johnrengelman/shadow/issues/651
val javaComponent = project.components["java"] as AdhocComponentWithVariants
javaComponent.withVariantsFromConfiguration(configurations["shadowRuntimeElements"]) { skip() }
}
}
}
54 changes: 5 additions & 49 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,57 +1,13 @@
plugins {
id("java")
id("java-library")
id("maven-publish")
id("com.github.johnrengelman.shadow") version "7.1.0"
id("io.freefair.lombok") version "6.3.0" apply false
id("pack.base-conventions")
}

allprojects {
apply(plugin = "java")
apply(plugin = "java-library")
apply(plugin = "maven-publish")
apply(plugin = "com.github.johnrengelman.shadow")
apply(plugin = "io.freefair.lombok")

repositories {
mavenLocal()
mavenCentral()

gradlePluginPortal()

// Geyser, Floodgate, Cumulus etc.
maven("https://repo.opencollab.dev/main")
maven("https://repo.opencollab.dev/maven-snapshots")

// Java pack library
maven("https://repo.unnamed.team/repository/unnamed-public/")
}

subprojects{
plugins.apply("pack.base-conventions")
plugins.apply("pack.publish-conventions")
group = "org.geysermc.pack"
version = "3.0-SNAPSHOT"
version = "3.1-SNAPSHOT"

java.sourceCompatibility = JavaVersion.VERSION_17
java.targetCompatibility = JavaVersion.VERSION_17

tasks.jar {
archiveClassifier.set("unshaded")
}

tasks.named("build") {
dependsOn(tasks.shadowJar)
}

publishing {
publications.create<MavenPublication>("library") {
artifact(tasks.shadowJar)
}
val repoName = if (version.toString().endsWith("SNAPSHOT")) "maven-snapshots" else "maven-releases"
repositories {
maven("https://repo.opencollab.dev/${repoName}/") {
credentials.username = System.getenv("OPENCOLLAB_USERNAME")
credentials.password = System.getenv("OPENCOLLAB_PASSWORD")
name = "opencollab"
}
}
}
}
31 changes: 19 additions & 12 deletions converter/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
plugins {
id("io.freefair.lombok") version "8.6"
}

sourceSets {
main {
resources {
srcDir("src/main/java/resources")
}
}
}

dependencies {
api(project(":pack-schema-api"))
implementation("com.google.code.gson:gson:2.10.1")
implementation("commons-io:commons-io:2.11.0")
implementation("com.twelvemonkeys.imageio:imageio-tga:3.9.4")
implementation("com.nukkitx.fastutil:fastutil-int-object-maps:8.5.3")
implementation("net.kyori:adventure-api:4.14.0")
implementation("net.kyori:adventure-text-serializer-gson:4.14.0")
implementation("net.kyori:adventure-text-serializer-legacy:4.14.0")
implementation("team.unnamed:creative-api:1.7.0")
implementation("team.unnamed:creative-serializer-minecraft:1.7.0")
api("net.kyori:adventure-api:4.14.0")
api("net.kyori:adventure-text-serializer-gson:4.14.0")
api("net.kyori:adventure-text-serializer-legacy:4.14.0")
api("team.unnamed:creative-api:1.7.0")
api("team.unnamed:creative-serializer-minecraft:1.7.0")

compileOnly("com.google.auto.service:auto-service:1.0.1")
annotationProcessor("com.google.auto.service:auto-service:1.0.1")
}

tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> {
from("src/main/java/resources") {
include("*")
}

archiveFileName.set("PackConverter-lib.jar")
archiveClassifier.set("")
java {
withSourcesJar()
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
11 changes: 9 additions & 2 deletions pack-schema/api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
dependencies {
api(project(":bedrock-pack-schema"))
compileOnlyApi(project(":bedrock-pack-schema")) // Available on compile, but not runtime classpath - we shade it in task below
implementation("com.google.code.gson:gson:2.10.1")
implementation("org.jetbrains:annotations:24.0.1")
}
}

val bedrockPackSchemaSourceSet = project(":bedrock-pack-schema").sourceSets.getByName("main")

tasks.jar {
from(bedrockPackSchemaSourceSet.output)
duplicatesStrategy = DuplicatesStrategy.WARN
}
21 changes: 20 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:Suppress("UnstableApiUsage")

rootProject.name = "packconverter-parent"

include(":bootstrap")
Expand All @@ -9,4 +11,21 @@ include(":schema-generator")

project(":pack-schema-api").projectDir = file("pack-schema/api")
project(":bedrock-pack-schema").projectDir = file("pack-schema/bedrock")
project(":schema-generator").projectDir = file("pack-schema/generator")
project(":schema-generator").projectDir = file("pack-schema/generator")

pluginManagement {
includeBuild("build-logic")
}

dependencyResolutionManagement {
repositories {
mavenCentral()

// Geyser, Floodgate, Cumulus etc.
maven("https://repo.opencollab.dev/main")
maven("https://repo.opencollab.dev/maven-snapshots")

// Java pack library
maven("https://repo.unnamed.team/repository/unnamed-public/")
}
}

0 comments on commit 7a2caf6

Please sign in to comment.