Skip to content

Commit c6ad398

Browse files
authored
Merge pull request #28 from cjmang/pr-update
Adding gradle build file
2 parents cfe649b + 7c1d532 commit c6ad398

File tree

20 files changed

+718
-14
lines changed

20 files changed

+718
-14
lines changed

.gitattributes

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#
2+
# https://help.github.com/articles/dealing-with-line-endings/
3+
#
4+
# Linux start script should use lf
5+
/gradlew text eol=lf
6+
7+
# These are Windows script files and should use crlf
8+
*.bat text eol=crlf
9+
10+
# Binary files should be left untouched
11+
*.jar binary
12+

.github/workflows/release.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Publish to Maven Central
2+
3+
on:
4+
release:
5+
types: [released]
6+
tags:
7+
- 'v[0-9]+.[0-9]+.[0-9]+'
8+
9+
jobs:
10+
build:
11+
if: github
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Set up JDK 17
16+
uses: actions/setup-java@v4
17+
with:
18+
java-version: '17'
19+
distribution: 'temurin'
20+
cache: gradle
21+
- name: Build with Gradle
22+
# This just publishes to the local file system; jreleaser is responsible for uploading to maven central
23+
run: gradlew publish
24+
- name: Upload to Maven Central
25+
env:
26+
# Needs to have access to the io.github.ArchipelagoMW namespace in maven central
27+
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.mavenCentralUsername }}
28+
JRELEASER_MAVENCENTRAL_TOKEN: ${{ secrets.mavenCentralToken }}
29+
# JRELEASER_DEPLOY_MAVEN_NEXUS2_USERNAME: ${{ secrets.mavenCentralUsername }}
30+
# JRELEASER_DEPLOY_MAVEN_NEXUS2_TOKEN: ${{ secrets.mavenCentralToken }}
31+
# The content uploaded to maven central needs to be signed. The public keys need to be published,
32+
# see https://central.sonatype.org/publish/requirements/gpg/#distributing-your-public-key for accepted
33+
# locations
34+
JRELEASER_GPG_PASSPHRASE: ${{ secrets.gpgPassphrase }}
35+
# The content here needs to be the values of the public and secret key pair
36+
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.gpgPublicKey }}
37+
JRELEASER_GPG_SECRET_KEY: ${{ secrets.gpgSecretKey }}
38+
run: gradlew jreleaserDeploy

.github/workflows/snapshot.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Publish to Maven Central
2+
3+
on:
4+
release:
5+
types: [prereleased]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- name: Set up JDK 17
13+
uses: actions/setup-java@v4
14+
with:
15+
java-version: '17'
16+
distribution: 'temurin'
17+
cache: gradle
18+
- name: Build with Gradle
19+
# This just publishes to the local file system; jreleaser is responsible for uploading to maven central
20+
run: gradlew publish
21+
- name: Upload to Maven Central Snapshots
22+
env:
23+
# Needs to have access to the io.github.ArchipelagoMW namespace in maven central
24+
JRELEASER_DEPLOY_MAVEN_NEXUS2_USERNAME: ${{ secrets.mavenCentralUsername }}
25+
JRELEASER_DEPLOY_MAVEN_NEXUS2_TOKEN: ${{ secrets.mavenCentralToken }}
26+
# The content uploaded to maven central needs to be signed. The public keys need to be published,
27+
# see https://central.sonatype.org/publish/requirements/gpg/#distributing-your-public-key for accepted
28+
# locations
29+
JRELEASER_GPG_PASSPHRASE: ${{ secrets.gpgPassphrase }}
30+
# The content here needs to be the values of the public and secret key pair
31+
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.gpgPublicKey }}
32+
JRELEASER_GPG_SECRET_KEY: ${{ secrets.gpgSecretKey }}
33+
run: gradlew jreleaserDeploy

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ release.properties
1010
dependency-reduced-pom.xml
1111
buildNumber.properties
1212
.mvn/timing.properties
13+
.gradle
14+
build/
1315

1416
### IntelliJ IDEA ###
1517
.idea/
@@ -40,4 +42,6 @@ build/
4042
.vscode/
4143

4244
### Mac OS ###
43-
.DS_Store
45+
.DS_Store
46+
# Ignore Gradle build output directory
47+
build

build.gradle.kts

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
import org.jreleaser.model.Active
2+
3+
plugins {
4+
`java-library`
5+
`maven-publish`
6+
id("org.jreleaser") version "1.17.0"
7+
}
8+
9+
group = "io.github.cjmang"
10+
version = "0.1.20-rc1"
11+
12+
repositories {
13+
mavenCentral()
14+
}
15+
16+
dependencies {
17+
testImplementation(libs.junit.jupiter)
18+
19+
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
20+
21+
implementation(libs.java.websocket)
22+
implementation(libs.gson)
23+
implementation(libs.httpclient)
24+
implementation(libs.httpcore)
25+
}
26+
27+
// Apply a specific Java toolchain to ease working on different environments.
28+
java {
29+
sourceCompatibility = JavaVersion.VERSION_1_8
30+
targetCompatibility = JavaVersion.VERSION_1_8
31+
toolchain {
32+
languageVersion = JavaLanguageVersion.of(17)
33+
}
34+
}
35+
36+
val sourcesJar: TaskProvider<Jar> by tasks.registering(Jar::class) {
37+
->
38+
archiveClassifier.set("sources")
39+
from(sourceSets.main.get().allSource)
40+
}
41+
42+
val javadocJar: TaskProvider<Jar> by tasks.registering(Jar::class) {
43+
->
44+
dependsOn.add(tasks.javadoc)
45+
archiveClassifier.set("javadoc")
46+
from(tasks.javadoc)
47+
}
48+
49+
tasks {
50+
artifacts {
51+
archives(sourcesJar)
52+
archives(javadocJar)
53+
}
54+
}
55+
56+
tasks.withType<JavaCompile>().configureEach {
57+
options.release = 8
58+
}
59+
60+
tasks.named<Test>("test") {
61+
// Use JUnit Platform for unit tests.
62+
useJUnitPlatform()
63+
}
64+
65+
tasks.named<Javadoc>("javadoc") {
66+
options {
67+
(this as CoreJavadocOptions).addBooleanOption("Xdoclint:none", true)
68+
}
69+
}
70+
71+
publishing {
72+
publications {
73+
create<MavenPublication>("javaClient") {
74+
repositories {
75+
// For the time being
76+
mavenLocal()
77+
maven {
78+
url = uri(layout.buildDirectory.dir("staging-deploy"))
79+
}
80+
}
81+
pom {
82+
name = "Archipelago Java Library"
83+
description = "Java library to connect to an Archipelago Server"
84+
url = "https://github.com/ArchipelagoMW/Java-Client"
85+
scm {
86+
connection = "scm:git://github.com/ArchipelagoMW/Java-Client"
87+
developerConnection = "scm:git:https://github.com/ArchipelagoMW/Java-Client.git"
88+
url = "https://github.com/ArchipelagoMW/Java-Client"
89+
}
90+
inceptionYear = "2021"
91+
licenses {
92+
license {
93+
name = "MIT License"
94+
url = "https://github.com/ArchipelagoMW/Java-Client/blob/main/LICENSE"
95+
distribution = "repo"
96+
}
97+
}
98+
developers {
99+
developer {
100+
name = "PlatanoBailando"
101+
102+
}
103+
developer {
104+
name = "digiholic"
105+
}
106+
}
107+
contributors {
108+
contributor {
109+
name = "Kono Tyran"
110+
roles.add("Author")
111+
}
112+
contributor {
113+
name = "mattman107"
114+
}
115+
contributor {
116+
name = "charlesfire"
117+
}
118+
}
119+
}
120+
artifacts {
121+
artifact(tasks.jar)
122+
artifact(sourcesJar)
123+
artifact(javadocJar)
124+
}
125+
}
126+
}
127+
}
128+
129+
jreleaser {
130+
project {
131+
snapshot {
132+
// https://regex101.com/r/TYV89b/1
133+
pattern = "^[^-]*-(SNAPSHOT|rc.*)"
134+
}
135+
}
136+
signing {
137+
active = Active.ALWAYS
138+
armored = true
139+
}
140+
release {
141+
github {
142+
enabled = true
143+
repoOwner = "ArchipelagoMW"
144+
overwrite = false
145+
skipRelease = true
146+
}
147+
}
148+
deploy {
149+
maven {
150+
mavenCentral {
151+
register("release-deploy") {
152+
// Turning off releases for testing purposes
153+
active = Active.NEVER
154+
applyMavenCentralRules = true
155+
url = "https://central.sonatype.com/api/v1/publisher"
156+
stagingRepository("build/staging-deploy")
157+
}
158+
}
159+
nexus2 {
160+
register("snapshot-deploy") {
161+
active = Active.SNAPSHOT
162+
applyMavenCentralRules = true
163+
snapshotSupported = true
164+
closeRepository = true
165+
releaseRepository = true
166+
url = "https://central.sonatype.com/api/v1/publisher"
167+
snapshotUrl = "https://central.sonatype.com/repository/maven-snapshots/"
168+
stagingRepository("build/staging-deploy")
169+
}
170+
}
171+
}
172+
}
173+
}

gradle.properties

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# This file was generated by the Gradle 'init' task.
2+
# https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties
3+
4+
# jreleaser breaks with this
5+
org.gradle.configuration-cache=false
6+

gradle/libs.versions.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# This file was generated by the Gradle 'init' task.
2+
# https://docs.gradle.org/current/userguide/platforms.html#sub::toml-dependencies-format
3+
4+
[versions]
5+
commons-math3 = "3.6.1"
6+
guava = "33.4.5-jre"
7+
junit-jupiter = "5.12.1"
8+
java-websocket = "1.5.7"
9+
gson = "2.11.0"
10+
httpclient = "5.2.1"
11+
httpcore = "5.2.5"
12+
13+
[libraries]
14+
commons-math3 = { module = "org.apache.commons:commons-math3", version.ref = "commons-math3" }
15+
guava = { module = "com.google.guava:guava", version.ref = "guava" }
16+
junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit-jupiter" }
17+
java-websocket = { module = "org.java-websocket:Java-WebSocket", version.ref = "java-websocket" }
18+
gson = { module = "com.google.code.gson:gson", version.ref = "gson" }
19+
httpclient = { module = "org.apache.httpcomponents.client5:httpclient5", version.ref = "httpclient" }
20+
httpcore = { module = "org.apache.httpcomponents.core5:httpcore5", version.ref = "httpcore" }

gradle/wrapper/gradle-wrapper.jar

42.7 KB
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
6+
zipStoreBase=GRADLE_USER_HOME
7+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)