From 21cadf739262e1ae0a310e14a1a4f20b16602e84 Mon Sep 17 00:00:00 2001 From: sanguine6660 Date: Fri, 15 Dec 2023 02:20:59 +0100 Subject: [PATCH] ADD publishing capabilities --- .github/workflows/gradle.yml | 5 ++-- build.gradle.kts | 50 +++++++++++++++++++++++++++++++++++- gradle.properties | 1 + 3 files changed, 52 insertions(+), 4 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 10a5082..6621aa1 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -20,9 +20,8 @@ jobs: java-version: 17 distribution: 'temurin' - # TODO: publishing to maven repo - - name: Build and Test - run: ./gradlew licenseFormat test build + - name: Build and Test and Publish + run: ./gradlew licenseFormat -DpublishName=upload -DpublishPassword=${{ secrets.PUBLISH_PASSWORD }} test build publish - name: Get Old Release Tag id: get_old_release diff --git a/build.gradle.kts b/build.gradle.kts index 0285682..ca0d7ec 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -20,6 +20,7 @@ description = "A Simple Message Translation and Placeholder replacement lib." repositories { mavenCentral() + mavenLocal() } dependencies { @@ -52,7 +53,54 @@ java { withJavadocJar() } -// TODO: publishing to maven repo +publishing { + (components["java"] as AdhocComponentWithVariants).withVariantsFromConfiguration(configurations["shadowRuntimeElements"]) { + skip() + } + + publications { + create(project.name) { + from(components["java"]) + + pom { + name.set(project.name) + url.set("https://github.com/IzanagiCraft/message-format") + properties.put("inceptionYear", "2023") + + licenses { + license { + name.set("General Public License (GPL v3.0)") + url.set("https://www.gnu.org/licenses/gpl-3.0.txt") + distribution.set("repo") + } + } + + developers { + developer { + id.set("sanguine6660") + name.set("Sanguine") + email.set("sanguine6660@gmail.com") + url.set("https://github.com/sanguine6660") + } + } + } + } + } + + repositories { + mavenLocal() + + if (System.getProperty("publishName") != null && System.getProperty("publishPassword") != null) { + maven("https://artifactory.izanagicraft.tech/repository/maven-snapshots/") { + this.name = "artifactory-izanagicraft-snapshots" + credentials { + this.password = System.getProperty("publishPassword") + this.username = System.getProperty("publishName") + } + } + } + } +} tasks { diff --git a/gradle.properties b/gradle.properties index 4fcdb02..22f41af 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,3 +2,4 @@ org.gradle.daemon=true org.gradle.jvmargs=-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 org.gradle.configureondemand=true org.gradle.parallel=true +org.gradle.caching=true