Skip to content

Commit

Permalink
chore: publish API on reposilite maven repository
Browse files Browse the repository at this point in the history
  • Loading branch information
diogotcorreia committed Jan 25, 2025
1 parent f98275d commit bfde332
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 4 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/publish-api.yml
Original file line number Diff line number Diff line change
@@ -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 }}

63 changes: 59 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<details>
<summary>Gradle (Groovy) Instructions</summary>

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"
}
```
</details>

<details>
<summary>Maven Instructions</summary>

Firstly, add the following repository to your project:

```xml
<repository>
<id>diogotc-repository-releases</id>
<name>Diogo Correia's Releases Repository</name>
<url>https://repo.diogotc.com/releases</url>
</repository>
```

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
<dependency>
<groupId>com.rexcantor64.triton</groupId>
<artifactId>triton-api</artifactId>
<!-- change the version to whatever the latest one is -->
<version>3.11.2</version>
<scope>provided</scope>
</dependency>
```
</details>

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

Expand Down
54 changes: 54 additions & 0 deletions api/build.gradle
Original file line number Diff line number Diff line change
@@ -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')
}
}
}
}
}
13 changes: 13 additions & 0 deletions gradle/publish.gradle
Original file line number Diff line number Diff line change
@@ -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
}
}
}

0 comments on commit bfde332

Please sign in to comment.