Skip to content

Commit 4bb2648

Browse files
authored
Merge pull request #650 from Multiverse/gradle-update
Implement gradle build and GHA release
2 parents 9f94029 + 92502d7 commit 4bb2648

File tree

14 files changed

+725
-236
lines changed

14 files changed

+725
-236
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Create Release Version & Publish Package
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
jobs:
8+
release_on_push:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
13+
- uses: actions/setup-java@v3
14+
with:
15+
java-version: '11'
16+
distribution: 'adopt'
17+
cache: gradle
18+
19+
- name: Validate Gradle wrapper
20+
uses: gradle/wrapper-validation-action@v1
21+
22+
- name: Test & Build
23+
uses: gradle/gradle-build-action@v2
24+
with:
25+
arguments: clean build -x assemble -x shadowJar
26+
env:
27+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
29+
- name: Create release
30+
id: release
31+
uses: rymndhng/release-on-push-action@v0.27.0
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
with:
35+
bump_version_scheme: norelease
36+
tag_prefix: ''
37+
release_name: "Release <RELEASE_VERSION>"
38+
use_github_release_notes: true
39+
40+
- name: Publish package
41+
uses: gradle/gradle-build-action@v2
42+
with:
43+
arguments: publish
44+
env:
45+
GITHUB_VERSION: ${{ steps.release.outputs.tag_name }}
46+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
48+
- name: Upload release artifact
49+
uses: svenstaro/upload-release-action@v2
50+
with:
51+
repo_token: ${{ secrets.GITHUB_TOKEN }}
52+
file: build/libs/multiverse-portals-${{ steps.release.outputs.tag_name }}.jar
53+
asset_name: multiverse-portals-${{ steps.release.outputs.tag_name }}.jar
54+
tag: ${{ steps.release.outputs.tag_name }}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Require PR Labels
2+
3+
on:
4+
pull_request:
5+
types: [opened, labeled, unlabeled, synchronize]
6+
branches: [main]
7+
8+
jobs:
9+
require_label:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: mheap/github-action-required-labels@v2
13+
env:
14+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15+
with:
16+
mode: exactly
17+
count: 1
18+
labels: "release:major, release:minor, release:patch, no release"

.github/workflows/test.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Run unit tests against all PRs
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize]
6+
7+
jobs:
8+
test:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
12+
steps:
13+
- uses: actions/checkout@v3
14+
15+
- uses: actions/setup-java@v3
16+
with:
17+
java-version: '11'
18+
distribution: 'adopt'
19+
cache: gradle
20+
21+
- name: Validate Gradle wrapper
22+
uses: gradle/wrapper-validation-action@v1
23+
24+
- name: Run unit tests
25+
uses: gradle/gradle-build-action@v2
26+
with:
27+
arguments: build
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,6 @@ debug.log
4343
# Doxygen
4444
/docs/html
4545
debug.txt
46+
47+
# Gradle
48+
.gradle

build.gradle

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
plugins {
2+
id 'java-library'
3+
id 'maven-publish'
4+
id 'checkstyle'
5+
id 'com.github.johnrengelman.shadow' version '7.1.2'
6+
}
7+
8+
version = System.getenv('GITHUB_VERSION') ?: 'local'
9+
group = 'com.onarandombox.multiverseportals'
10+
description = 'Multiverse-Portals'
11+
12+
java.sourceCompatibility = JavaVersion.VERSION_11
13+
14+
repositories {
15+
mavenLocal()
16+
mavenCentral()
17+
18+
maven {
19+
name = 'spigotmc'
20+
url = uri('https://hub.spigotmc.org/nexus/content/repositories/snapshots/')
21+
}
22+
23+
maven {
24+
name = 'onarandombox'
25+
url = uri('https://repo.onarandombox.com/content/groups/public')
26+
}
27+
28+
maven {
29+
name = 'enginehub'
30+
url = uri('https://maven.enginehub.org/repo/')
31+
}
32+
}
33+
34+
dependencies {
35+
// Spigot
36+
implementation 'org.bukkit:bukkit:1.13.2-R0.1-SNAPSHOT'
37+
38+
// Core
39+
implementation 'com.onarandombox.multiversecore:Multiverse-Core:4.2.2'
40+
41+
//WorldEdit
42+
implementation('com.sk89q.worldedit:worldedit-bukkit:7.2.9') {
43+
exclude group: 'org.bukkit', module: 'bukkit'
44+
}
45+
46+
// Utils
47+
api('com.dumptruckman.minecraft:Logging:1.1.1') {
48+
exclude group: 'org.bukkit', module: 'bukkit'
49+
}
50+
}
51+
52+
53+
java {
54+
withSourcesJar()
55+
withJavadocJar()
56+
}
57+
58+
tasks.withType(JavaCompile).configureEach {
59+
options.encoding = 'UTF-8'
60+
}
61+
62+
tasks.withType(Javadoc).configureEach {
63+
options.encoding = 'UTF-8'
64+
}
65+
66+
67+
configurations {
68+
[apiElements, runtimeElements].each {
69+
it.outgoing.artifacts.removeIf { it.buildDependencies.getDependencies(null).contains(jar) }
70+
it.outgoing.artifact(shadowJar)
71+
}
72+
}
73+
74+
publishing {
75+
publications {
76+
maven(MavenPublication) {
77+
from components.java
78+
}
79+
}
80+
repositories {
81+
maven {
82+
name = "GitHubPackages"
83+
url = "https://maven.pkg.github.com/Multiverse/Multiverse-Portals"
84+
credentials {
85+
username = System.getenv("GITHUB_ACTOR")
86+
password = System.getenv("GITHUB_TOKEN")
87+
}
88+
}
89+
}
90+
}
91+
92+
93+
processResources {
94+
def props = [version: "${project.version}"]
95+
inputs.properties props
96+
filteringCharset 'UTF-8'
97+
filesMatching('plugin.yml') {
98+
expand props
99+
}
100+
101+
// This task should never be skipped. The tests depend on this having been run but we want the new version number
102+
// that is created after tests are run and before we run again to publish.
103+
outputs.upToDateWhen { false }
104+
}
105+
106+
107+
checkstyle {
108+
toolVersion = '6.1.1'
109+
configFile file('config/mv_checks.xml')
110+
ignoreFailures = true
111+
}
112+
113+
114+
javadoc {
115+
source = sourceSets.main.allJava
116+
classpath = configurations.compileClasspath
117+
}
118+
119+
120+
project.configurations.api.canBeResolved = true
121+
122+
shadowJar {
123+
relocate 'com.dumptruckman.minecraft.util.Logging', 'com.onarandombox.multiverseportals.util.MVPLogging'
124+
relocate 'com.dumptruckman.minecraft.util.DebugLog', 'com.onarandombox.multiverseportals.util.DebugFileLogger'
125+
126+
configurations = [project.configurations.api]
127+
128+
archiveFileName = "$baseName-$version.$extension"
129+
}
130+
131+
build.dependsOn shadowJar
132+
jar.enabled = false

0 commit comments

Comments
 (0)