Skip to content

Adding gradle build file #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jun 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# Linux start script should use lf
/gradlew text eol=lf

# These are Windows script files and should use crlf
*.bat text eol=crlf

# Binary files should be left untouched
*.jar binary

38 changes: 38 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Publish to Maven Central

on:
release:
types: [released]
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'

jobs:
build:
if: github
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: gradle
- name: Build with Gradle
# This just publishes to the local file system; jreleaser is responsible for uploading to maven central
run: gradlew publish
- name: Upload to Maven Central
env:
# Needs to have access to the io.github.ArchipelagoMW namespace in maven central
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.mavenCentralUsername }}
JRELEASER_MAVENCENTRAL_TOKEN: ${{ secrets.mavenCentralToken }}
# JRELEASER_DEPLOY_MAVEN_NEXUS2_USERNAME: ${{ secrets.mavenCentralUsername }}
# JRELEASER_DEPLOY_MAVEN_NEXUS2_TOKEN: ${{ secrets.mavenCentralToken }}
# The content uploaded to maven central needs to be signed. The public keys need to be published,
# see https://central.sonatype.org/publish/requirements/gpg/#distributing-your-public-key for accepted
# locations
JRELEASER_GPG_PASSPHRASE: ${{ secrets.gpgPassphrase }}
# The content here needs to be the values of the public and secret key pair
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.gpgPublicKey }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.gpgSecretKey }}
run: gradlew jreleaserDeploy
33 changes: 33 additions & 0 deletions .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Publish to Maven Central

on:
release:
types: [prereleased]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: gradle
- name: Build with Gradle
# This just publishes to the local file system; jreleaser is responsible for uploading to maven central
run: gradlew publish
- name: Upload to Maven Central Snapshots
env:
# Needs to have access to the io.github.ArchipelagoMW namespace in maven central
JRELEASER_DEPLOY_MAVEN_NEXUS2_USERNAME: ${{ secrets.mavenCentralUsername }}
JRELEASER_DEPLOY_MAVEN_NEXUS2_TOKEN: ${{ secrets.mavenCentralToken }}
# The content uploaded to maven central needs to be signed. The public keys need to be published,
# see https://central.sonatype.org/publish/requirements/gpg/#distributing-your-public-key for accepted
# locations
JRELEASER_GPG_PASSPHRASE: ${{ secrets.gpgPassphrase }}
# The content here needs to be the values of the public and secret key pair
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.gpgPublicKey }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.gpgSecretKey }}
run: gradlew jreleaserDeploy
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.gradle
build/

### IntelliJ IDEA ###
.idea/
Expand Down Expand Up @@ -40,4 +42,6 @@ build/
.vscode/

### Mac OS ###
.DS_Store
.DS_Store
# Ignore Gradle build output directory
build
173 changes: 173 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
import org.jreleaser.model.Active

plugins {
`java-library`
`maven-publish`
id("org.jreleaser") version "1.17.0"
}

group = "io.github.cjmang"
version = "0.1.20-rc1"

repositories {
mavenCentral()
}

dependencies {
testImplementation(libs.junit.jupiter)

testRuntimeOnly("org.junit.platform:junit-platform-launcher")

implementation(libs.java.websocket)
implementation(libs.gson)
implementation(libs.httpclient)
implementation(libs.httpcore)
}

// Apply a specific Java toolchain to ease working on different environments.
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

val sourcesJar: TaskProvider<Jar> by tasks.registering(Jar::class) {
->
archiveClassifier.set("sources")
from(sourceSets.main.get().allSource)
}

val javadocJar: TaskProvider<Jar> by tasks.registering(Jar::class) {
->
dependsOn.add(tasks.javadoc)
archiveClassifier.set("javadoc")
from(tasks.javadoc)
}

tasks {
artifacts {
archives(sourcesJar)
archives(javadocJar)
}
}

tasks.withType<JavaCompile>().configureEach {
options.release = 8
}

tasks.named<Test>("test") {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
}

tasks.named<Javadoc>("javadoc") {
options {
(this as CoreJavadocOptions).addBooleanOption("Xdoclint:none", true)
}
}

publishing {
publications {
create<MavenPublication>("javaClient") {
repositories {
// For the time being
mavenLocal()
maven {
url = uri(layout.buildDirectory.dir("staging-deploy"))
}
}
pom {
name = "Archipelago Java Library"
description = "Java library to connect to an Archipelago Server"
url = "https://github.com/ArchipelagoMW/Java-Client"
scm {
connection = "scm:git://github.com/ArchipelagoMW/Java-Client"
developerConnection = "scm:git:https://github.com/ArchipelagoMW/Java-Client.git"
url = "https://github.com/ArchipelagoMW/Java-Client"
}
inceptionYear = "2021"
licenses {
license {
name = "MIT License"
url = "https://github.com/ArchipelagoMW/Java-Client/blob/main/LICENSE"
distribution = "repo"
}
}
developers {
developer {
name = "PlatanoBailando"
email = "cjmang@gmail.com"
}
developer {
name = "digiholic"
}
}
contributors {
contributor {
name = "Kono Tyran"
roles.add("Author")
}
contributor {
name = "mattman107"
}
contributor {
name = "charlesfire"
}
}
}
artifacts {
artifact(tasks.jar)
artifact(sourcesJar)
artifact(javadocJar)
}
}
}
}

jreleaser {
project {
snapshot {
// https://regex101.com/r/TYV89b/1
pattern = "^[^-]*-(SNAPSHOT|rc.*)"
}
}
signing {
active = Active.ALWAYS
armored = true
}
release {
github {
enabled = true
repoOwner = "ArchipelagoMW"
overwrite = false
skipRelease = true
}
}
deploy {
maven {
mavenCentral {
register("release-deploy") {
// Turning off releases for testing purposes
active = Active.NEVER
applyMavenCentralRules = true
url = "https://central.sonatype.com/api/v1/publisher"
stagingRepository("build/staging-deploy")
}
}
nexus2 {
register("snapshot-deploy") {
active = Active.SNAPSHOT
applyMavenCentralRules = true
snapshotSupported = true
closeRepository = true
releaseRepository = true
url = "https://central.sonatype.com/api/v1/publisher"
snapshotUrl = "https://central.sonatype.com/repository/maven-snapshots/"
stagingRepository("build/staging-deploy")
}
}
}
}
}
6 changes: 6 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This file was generated by the Gradle 'init' task.
# https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties

# jreleaser breaks with this
org.gradle.configuration-cache=false

20 changes: 20 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This file was generated by the Gradle 'init' task.
# https://docs.gradle.org/current/userguide/platforms.html#sub::toml-dependencies-format

[versions]
commons-math3 = "3.6.1"
guava = "33.4.5-jre"
junit-jupiter = "5.12.1"
java-websocket = "1.5.7"
gson = "2.11.0"
httpclient = "5.2.1"
httpcore = "5.2.5"

[libraries]
commons-math3 = { module = "org.apache.commons:commons-math3", version.ref = "commons-math3" }
guava = { module = "com.google.guava:guava", version.ref = "guava" }
junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit-jupiter" }
java-websocket = { module = "org.java-websocket:Java-WebSocket", version.ref = "java-websocket" }
gson = { module = "com.google.code.gson:gson", version.ref = "gson" }
httpclient = { module = "org.apache.httpcomponents.client5:httpclient5", version.ref = "httpclient" }
httpcore = { module = "org.apache.httpcomponents.core5:httpcore5", version.ref = "httpcore" }
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading