Skip to content

Commit 87d6c9c

Browse files
committed
feat(gradle): Gradle project
1 parent 27c0430 commit 87d6c9c

14 files changed

+643
-24
lines changed

.github/workflows/gradle.yml

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Build
2+
on: [push]
3+
jobs:
4+
build:
5+
6+
runs-on: ubuntu-latest
7+
# We want to run on external PRs, but not on our own internal PRs as they'll be run
8+
# by the push to the branch.
9+
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
10+
11+
12+
steps:
13+
- name: Set up JDK 17
14+
uses: actions/setup-java@v1
15+
with:
16+
java-version: 17
17+
18+
- name: Cache Gradle
19+
id: cache-gradle
20+
uses: actions/cache@v1
21+
with:
22+
path: ~/.gradle
23+
key: ${{ runner.os }}-gradle
24+
25+
- uses: actions/checkout@v1
26+
27+
- name: Grant execute permission to gradlew
28+
run: chmod +x gradlew
29+
30+
- name: Build
31+
run: ./gradlew build shadowJar -x test
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
35+
- name: Upload build artifacts
36+
uses: actions/upload-artifact@v2
37+
with:
38+
path: "**/build/libs"
39+
40+
release:
41+
needs: [build]
42+
if: github.ref == 'refs/heads/master' || 'refs/heads/beta' || github.ref == 'refs/heads/alpha'
43+
44+
runs-on: ubuntu-latest
45+
46+
steps:
47+
- name: Set up JDK 17
48+
uses: actions/setup-java@v1
49+
with:
50+
java-version: 17
51+
52+
- name: Set up Node.js v18.x
53+
uses: actions/setup-node@v1
54+
with:
55+
node-version: "18.x"
56+
57+
- name: Cache Gradle
58+
id: cache-gradle
59+
uses: actions/cache@v1
60+
with:
61+
path: ~/.gradle
62+
key: ${{ runner.os }}-gradle
63+
64+
- uses: actions/checkout@v1
65+
66+
- name: Grant execute permission for gradlew
67+
run: chmod +x gradlew
68+
69+
- name: Grant execute permission for update-versions.sh
70+
run: chmod +x update-versions.sh
71+
72+
- name: Release
73+
env:
74+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75+
GH_URL: "https://api.github.com/"
76+
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
77+
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
78+
run: npx --legacy-peer-deps -p @semantic-release/changelog -p @semantic-release/git -p @semantic-release/exec -p gradle-semantic-release-plugin -p semantic-release semantic-release

.github/workflows/maven.yml

-24
This file was deleted.

.releaserc.json

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"branches": [
3+
"master",
4+
{
5+
"name": "beta",
6+
"prerelease": true
7+
},
8+
{
9+
"name": "alpha",
10+
"prerelease": true
11+
}
12+
],
13+
"plugins": [
14+
"@semantic-release/commit-analyzer",
15+
[
16+
"@semantic-release/exec",
17+
{
18+
"prepareCmd": "./update-versions.sh ${nextRelease.version}"
19+
}
20+
],
21+
"@semantic-release/release-notes-generator",
22+
"@semantic-release/changelog",
23+
"gradle-semantic-release-plugin",
24+
[
25+
"@semantic-release/github",
26+
{
27+
"assets": [
28+
{
29+
"path": "**/build/libs/*.jar"
30+
}
31+
]
32+
}
33+
],
34+
[
35+
"@semantic-release/git",
36+
{
37+
"assets": [
38+
"gradle.properties",
39+
"CHANGELOG.md",
40+
"README.md"
41+
]
42+
}
43+
]
44+
]
45+
}

CHANGELOG.md

Whitespace-only changes.

build.gradle

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
buildscript {
2+
repositories {
3+
mavenCentral()
4+
}
5+
}
6+
7+
plugins {
8+
id 'com.github.johnrengelman.shadow' version '8.1.1'
9+
id 'io.freefair.lombok' version '8.0.1'
10+
id "net.kyori.blossom" version "1.3.1"
11+
id 'java'
12+
id 'jacoco'
13+
id 'idea'
14+
}
15+
16+
apply from: "$rootDir/gradle/jacoco.gradle"
17+
apply from: "$rootDir/gradle/publish.gradle"
18+
19+
if (project.hasProperty("local_script")) {
20+
apply from: file(local_script + "/build.local.gradle")
21+
}
22+
23+
ext {
24+
mcVersion = project.property("mcVersion")
25+
}
26+
27+
group project.property("group")
28+
description project.property("description") as String
29+
version project.property("version")
30+
31+
repositories {
32+
mavenLocal()
33+
maven {
34+
url = uri('https://hub.spigotmc.org/nexus/content/repositories/snapshots/')
35+
}
36+
37+
maven {
38+
url = uri('https://repo.maven.apache.org/maven2/')
39+
}
40+
}
41+
42+
dependencies {
43+
compileOnly "org.spigotmc:spigot-api:${mcVersion}-R0.1-SNAPSHOT"
44+
}
45+
46+
47+
java.sourceCompatibility = JavaVersion.VERSION_1_8
48+
49+
java {
50+
withSourcesJar()
51+
withJavadocJar()
52+
}
53+
54+
shadowJar {
55+
archiveClassifier.set('')
56+
}

gradle.properties

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
group = com.georgev22
2+
artifact = particle
3+
description = ParticleLib
4+
author = GeorgeV22
5+
version = 1.0.0
6+
mcVersion = 1.20

gradle/jacoco.gradle

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
jacoco { toolVersion = "0.8.7" }
2+
3+
jacocoTestReport {
4+
reports {
5+
xml.required = true
6+
html.required = true
7+
}
8+
}
9+
10+
tasks.check.dependsOn 'jacocoTestReport'

gradle/publish.gradle

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
apply plugin: 'maven-publish'
2+
3+
static def getBranch() {
4+
def process = 'git branch --show-current'.execute()
5+
process.waitFor()
6+
return process.text.trim()
7+
}
8+
9+
static def getHash() {
10+
def process = 'git rev-parse HEAD'.execute()
11+
process.waitFor()
12+
return process.text.trim()
13+
}
14+
15+
java {
16+
withJavadocJar()
17+
withSourcesJar()
18+
}
19+
20+
jar {
21+
manifest {
22+
attributes(
23+
'Build-Jdk': "${System.properties['java.vendor']} ${System.properties['java.vm.version']}",
24+
'Created-By': "Gradle ${gradle.gradleVersion}",
25+
'Git-Branch': getBranch(),
26+
'Git-Hash': getHash()
27+
)
28+
}
29+
}
30+
31+
publishing {
32+
publications {
33+
shadow(MavenPublication) { publication ->
34+
project.shadow.component(publication)
35+
artifactId = project.getName().toLowerCase()
36+
groupId = ((String) project.getGroup()).toLowerCase()
37+
artifact sourcesJar
38+
artifact javadocJar
39+
}
40+
}
41+
repositories {
42+
def isGitHub = System.getenv("GITHUB_REPOSITORY") ? true : false
43+
if (isGitHub) {
44+
maven {
45+
name = "GitHubPackages"
46+
url = uri("https://maven.pkg.github.com/${project.findProperty("GITHUB_REPOSITORY") ?: System.getenv("GITHUB_REPOSITORY")}")
47+
credentials {
48+
username = project.findProperty("gpr.user") ?: System.getenv("GITHUB_ACTOR")
49+
password = project.findProperty("gpr.key") ?: System.getenv("GITHUB_TOKEN")
50+
}
51+
}
52+
maven {
53+
name = "GeorgeV22"
54+
55+
url = uri("https://repo.georgev22.com/releases")
56+
57+
def mavenUsername = System.getenv("MAVEN_USERNAME") ? System.getenv("MAVEN_USERNAME") :
58+
System.getProperty("MAVEN_USERNAME") ? System.getProperty("MAVEN_USERNAME") : null
59+
def mavenPassword = System.getenv("MAVEN_PASSWORD") ? System.getenv("MAVEN_PASSWORD") :
60+
System.getProperty("MAVEN_PASSWORD") ? System.getProperty("MAVEN_PASSWORD") : null
61+
62+
if (mavenUsername != null && mavenPassword != null) {
63+
credentials {
64+
username = mavenUsername
65+
password = mavenPassword
66+
}
67+
authentication {
68+
basic(BasicAuthentication)
69+
}
70+
}
71+
}
72+
}
73+
if (!isGitHub) {
74+
maven {
75+
name = "GeorgeV22"
76+
77+
url = uri("https://repo.georgev22.com/snapshots")
78+
79+
def mavenUsername = System.getenv("MAVEN_USERNAME") ? System.getenv("MAVEN_USERNAME") :
80+
System.getProperty("MAVEN_USERNAME") ? System.getProperty("MAVEN_USERNAME") : null
81+
def mavenPassword = System.getenv("MAVEN_PASSWORD") ? System.getenv("MAVEN_PASSWORD") :
82+
System.getProperty("MAVEN_PASSWORD") ? System.getProperty("MAVEN_PASSWORD") : null
83+
84+
if (mavenUsername != null && mavenPassword != null) {
85+
credentials {
86+
username = mavenUsername
87+
password = mavenPassword
88+
}
89+
authentication {
90+
basic(BasicAuthentication)
91+
}
92+
}
93+
}
94+
}
95+
}
96+
}
97+
98+
javadoc {
99+
if (JavaVersion.current().isJava9Compatible()) {
100+
options.addBooleanOption('html5', true)
101+
options.addStringOption('Xdoclint:none', '-quiet')
102+
}
103+
}

gradle/wrapper/gradle-wrapper.jar

60.6 KB
Binary file not shown.
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
4+
networkTimeout=10000
5+
zipStoreBase=GRADLE_USER_HOME
6+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)