Skip to content

Commit ab980f8

Browse files
committed
Switch to Gradle
1 parent 7d03f13 commit ab980f8

13 files changed

Lines changed: 462 additions & 251 deletions

.github/workflows/ci.yml

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,5 @@ on:
77

88
jobs:
99
build:
10-
runs-on: ubuntu-latest
11-
steps:
12-
- uses: actions/checkout@v4
13-
14-
- name: Set up JDK
15-
uses: actions/setup-java@v4
16-
with:
17-
distribution: 'temurin'
18-
java-version: '21'
19-
cache: 'maven'
20-
21-
- name: Cache SonarCloud packages
22-
uses: actions/cache@v4
23-
with:
24-
path: ~/.sonar/cache
25-
key: ${{ runner.os }}-sonar
26-
restore-keys: |
27-
${{ runner.os }}-sonar
28-
29-
- name: Build and analyze
30-
env:
31-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
33-
run: mvn -B verify org.jacoco:jacoco-maven-plugin:report org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -P sonarcloud
10+
uses: Jikoo/PlanarActions/.github/workflows/ci_gradle_sonar.yml@master
11+
secrets: inherit

.github/workflows/pull_request.yml

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,12 @@ on:
55

66
jobs:
77
run-ci:
8-
uses: Jikoo/PlanarActions/.github/workflows/ci_maven.yml@master
8+
uses: Jikoo/PlanarActions/.github/workflows/ci_gradle_sonar.yml@master
9+
secrets: inherit
910
approve-and-merge-dependabot:
1011
if: "github.event_name == 'pull_request' && github.event.pull_request.user.login == 'dependabot[bot]'"
1112
needs: [ "run-ci" ]
12-
runs-on: "ubuntu-latest"
13+
uses: Jikoo/PlanarActions/.github/workflows/dependabot_automerge.yml@master
1314
permissions:
1415
contents: write
1516
pull-requests: write
16-
steps:
17-
# Always approve PRs from Dependabot.
18-
- name: Approve
19-
run: gh pr review --approve "$PR_URL"
20-
env:
21-
PR_URL: ${{github.event.pull_request.html_url}}
22-
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
23-
24-
# Fetch Dependabot metadata for finer decisionmaking later.
25-
- name: Fetch Dependabot metadata
26-
id: metadata
27-
uses: dependabot/fetch-metadata@21025c705c08248db411dc16f3619e6b5f9ea21a
28-
with:
29-
github-token: "${{ secrets.GITHUB_TOKEN }}"
30-
31-
# Enable auto-merge for the PR.
32-
# Auto-merge is used rather than a direct merge so that any other required checks can pass.
33-
- name: Enable auto-merge for minor/patch updates
34-
if: steps.metadata.outputs.update-type == 'version-update:semver-patch' || steps.metadata.outputs.update-type == 'version-update:semver-minor'
35-
run: gh pr merge --auto --squash "$PR_URL"
36-
env:
37-
PR_URL: ${{github.event.pull_request.html_url}}
38-
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
target/
1010
dependency-reduced-pom.xml
1111

12+
# Gradle
13+
.gradle/
14+
**/build/
15+
1216
# Eclipse
1317
.settings/
1418
.classpath
@@ -69,3 +73,4 @@ $RECYCLE.BIN/
6973

7074
# Windows shortcuts
7175
*.lnk
76+
/.gradle/

build.gradle.kts

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import java.lang.Runtime
2+
3+
plugins {
4+
`java-library`
5+
jacoco
6+
alias(libs.plugins.org.sonarqube)
7+
}
8+
9+
repositories {
10+
mavenCentral()
11+
maven("https://repo.papermc.io/repository/maven-public/")
12+
maven("https://jitpack.io/")
13+
}
14+
15+
val mockitoAgent = configurations.create("mockitoAgent")
16+
17+
dependencies {
18+
implementation(libs.org.jetbrains.annotations)
19+
implementation(libs.io.papermc.paper.paper.api)
20+
implementation(libs.com.github.jikoo.planarwrappers)
21+
22+
testImplementation(libs.org.hamcrest.hamcrest)
23+
testImplementation(libs.org.mockito.mockito.core)
24+
mockitoAgent(libs.org.mockito.mockito.core) { isTransitive = false }
25+
testImplementation(libs.com.jparams.to.string.verifier)
26+
}
27+
28+
group = "com.github.jikoo"
29+
version = "3.0.0-SNAPSHOT"
30+
description = "A customizable system mimicking vanilla Minecraft's enchanting functionality."
31+
32+
tasks.withType<JavaCompile>() {
33+
options.release = 21
34+
options.encoding = "UTF-8"
35+
}
36+
37+
tasks.withType<Javadoc>() {
38+
options.encoding = "UTF-8"
39+
}
40+
41+
testing {
42+
suites {
43+
named<JvmTestSuite>("test") {
44+
useJUnitJupiter("6.0.2")
45+
}
46+
}
47+
}
48+
49+
tasks.test {
50+
useJUnitPlatform()
51+
52+
// Use as many cores as possible to run tests.
53+
maxParallelForks = Runtime.getRuntime().availableProcessors()
54+
// As Bukkit is very heavily statically initialized, don't reuse forks.
55+
forkEvery = 1
56+
jvmArgs("-Xshare:off", "-javaagent:${mockitoAgent.asPath}")
57+
58+
// Generate coverage reports
59+
finalizedBy(tasks.jacocoTestReport)
60+
}
61+
62+
tasks.jacocoTestReport {
63+
reports {
64+
// Produce XML report for Sonar
65+
xml.required = true
66+
}
67+
}
68+
69+
sonar {
70+
properties {
71+
property("sonar.projectKey", "Jikoo_PlanarEnchanting")
72+
property("sonar.organization", "jikoo")
73+
property("sonar.host.url", "https://sonarcloud.io")
74+
property("sonar.language", "java")
75+
property("sonar.java.coveragePlugin", "jacoco")
76+
property("sonar.coverage.jacoco.xmlReportPaths", "build/reports/jacoco/test/jacocoTestReport.xml")
77+
}
78+
}

gradle.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
org.gradle.configuration-cache=true
2+
org.gradle.parallel=true
3+
org.gradle.caching=true
4+

gradle/libs.versions.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# https://docs.gradle.org/current/userguide/version_catalogs.html#sec::toml-dependencies-format
2+
3+
[versions]
4+
com-github-jikoo-planarwrappers = "4.0.0"
5+
com-jparams-to-string-verifier = "1.4.8"
6+
io-papermc-paper-paper-api = "1.21.11-R0.1-SNAPSHOT"
7+
org-hamcrest-hamcrest = "3.0"
8+
org-jetbrains-annotations = "26.0.2-1"
9+
org-mockito-mockito-core = "5.21.0"
10+
org-sonarqube = "7.1.0.6387"
11+
12+
[libraries]
13+
com-github-jikoo-planarwrappers = { module = "com.github.jikoo:planarwrappers", version.ref = "com-github-jikoo-planarwrappers" }
14+
com-jparams-to-string-verifier = { module = "com.jparams:to-string-verifier", version.ref = "com-jparams-to-string-verifier" }
15+
io-papermc-paper-paper-api = { module = "io.papermc.paper:paper-api", version.ref = "io-papermc-paper-paper-api" }
16+
org-hamcrest-hamcrest = { module = "org.hamcrest:hamcrest", version.ref = "org-hamcrest-hamcrest" }
17+
org-jetbrains-annotations = { module = "org.jetbrains:annotations", version.ref = "org-jetbrains-annotations" }
18+
org-mockito-mockito-core = { module = "org.mockito:mockito-core", version.ref = "org-mockito-mockito-core" }
19+
20+
[plugins]
21+
org-sonarqube = { id = "org.sonarqube", version.ref = "org-sonarqube" }

gradle/wrapper/gradle-wrapper.jar

45.1 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-9.3.1-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
6+
zipStoreBase=GRADLE_USER_HOME
7+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)