From bfde332bc4af826c0713be148050029940b1f116 Mon Sep 17 00:00:00 2001 From: Diogo Correia Date: Sat, 25 Jan 2025 16:49:04 +0100 Subject: [PATCH] chore: publish API on reposilite maven repository --- .github/workflows/publish-api.yml | 25 ++++++++++++ README.md | 63 +++++++++++++++++++++++++++++-- api/build.gradle | 54 ++++++++++++++++++++++++++ gradle/publish.gradle | 13 +++++++ 4 files changed, 151 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/publish-api.yml create mode 100644 gradle/publish.gradle diff --git a/.github/workflows/publish-api.yml b/.github/workflows/publish-api.yml new file mode 100644 index 00000000..2cfd2c75 --- /dev/null +++ b/.github/workflows/publish-api.yml @@ -0,0 +1,25 @@ +name: Publish package to the Maven Central Repository and GitHub Packages +on: + release: + types: [created] +jobs: + publish: + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - name: Set up Java + uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0 + with: + java-version: '17' + distribution: 'adopt' + - name: Setup Gradle + uses: gradle/actions/setup-gradle@0bdd871935719febd78681f197cd39af5b6e16a6 # v4.2.2 + + - name: Publish package + run: ./gradlew publish + env: + ORG_GRADLE_PROJECT_diogotcRepositoryUsername: github-ci-triton + ORG_GRADLE_PROJECT_diogotcRepositoryPassword: ${{ secrets.MAVEN_REPO_SECRET }} + diff --git a/README.md b/README.md index cd0b753c..b6d74a1f 100644 --- a/README.md +++ b/README.md @@ -14,14 +14,69 @@ or [Polymart](https://polymart.org/resource/triton.38)! ## Using the API -[Download the latest API from the releases tab](https://github.com/tritonmc/Triton/releases/latest) -or [add it to your project using Gradle/Maven](https://jitpack.io/#tritonmc/Triton). +The recommended way to use Triton's API is through the Gradle/Maven artifact. +Note that the Maven repository mentioned below is only available since +Triton v3.11.2. -Need help developing? Take a look at the [JavaDocs](https://triton.rexcantor64.com/javadocs) or join +
+Gradle (Groovy) Instructions + +Firstly, add the following repository to your project: + +```groovy +repositories { + maven { + url "https://repo.diogotc.com/releases" + } +} +``` + +Then, you should be able to add the Triton API dependency. +Make sure to NOT shade it into your plugin by using `compileOnly`. + +```groovy +dependencies { + // change the version to whatever the latest one is + compileOnly "com.rexcantor64.triton:triton-api:3.11.2" +} +``` +
+ +
+Maven Instructions + +Firstly, add the following repository to your project: + +```xml + + diogotc-repository-releases + Diogo Correia's Releases Repository + https://repo.diogotc.com/releases + +``` + +Then, you should be able to add the Triton API dependency. +Make sure to NOT shade it into your plugin by setting the appropriate `scope`. + +```xml + + com.rexcantor64.triton + triton-api + + 3.11.2 + provided + +``` +
+ +Need help developing? Take a look at the +[wiki](https://github.com/tritonmc/Triton/wiki), +[JavaDocs](https://triton.rexcantor64.com/javadocs) or join our [Discord](https://triton.rexcantor64.com/discord)! Looking for older API versions? Take a look at -the [download page](https://github.com/diogotcorreia/Triton/wiki/Downloads)! +the [download page](https://github.com/diogotcorreia/Triton/wiki/Downloads) +or [JitPack](https://jitpack.io/#tritonmc/triton/). ## Compiling from Source diff --git a/api/build.gradle b/api/build.gradle index 58a7d603..46ba2177 100644 --- a/api/build.gradle +++ b/api/build.gradle @@ -1,10 +1,64 @@ plugins { id 'java' + id 'maven-publish' } group 'com.rexcantor64.triton' +apply from: '../gradle/publish.gradle' + dependencies { compileOnly 'org.spigotmc:spigot-api:1.17-R0.1-SNAPSHOT' compileOnly 'net.md-5:bungeecord-api:1.17-R0.1-SNAPSHOT' } + +java { + withJavadocJar() + withSourcesJar() +} + +tasks { + jar { + manifest { + attributes 'Automatic-Module-Name': 'com.rexcantor64.triton.api' + } + } + + javadoc { + options.encoding = 'UTF-8' + options.charSet = 'UTF-8' + options.source = '8' + options.links( + 'https://hub.spigotmc.org/javadocs/spigot/', + 'https://jd.papermc.io/waterfall/1.20/', // Use Waterfall's JavaDocs instead of Bungee's since those are broken + 'https://docs.oracle.com/en/java/javase/21/docs/api/', + ) + + // Disable the crazy super-strict doclint tool in Java 8 + options.addStringOption('Xdoclint:none', '-quiet') + + // Mark sources as Java 8 source compatible + options.source = '8' + } +} + +publishing { + publications { + tritonApi(MavenPublication) { + from components.java + + artifactId = 'triton-api' + + pom { + name.set('Triton API') + description.set('Translate your server! Sends the same message in different languages... Hooks into all plugins!') + url.set('https://triton.rexcantor64.com') + scm { + url.set('https://github.com/tritonmc/Triton') + connection.set('scm:git:https://github.com/tritonmc/Triton.git') + developerConnection.set('scm:git:https://github.com/tritonmc/Triton.git') + } + } + } + } +} diff --git a/gradle/publish.gradle b/gradle/publish.gradle new file mode 100644 index 00000000..bdd5ad6c --- /dev/null +++ b/gradle/publish.gradle @@ -0,0 +1,13 @@ +publishing { + repositories { + maven { + credentials(PasswordCredentials.class) + + name = "diogotcRepository" + def base = 'https://repo.diogotc.com' + def releasesRepoUrl = "$base/releases/" + def snapshotsRepoUrl = "$base/snapshots/" + url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl + } + } +}