mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2024-12-28 11:04:21 +00:00
Update Gradle to 7.0.2; misc build improvements (#4148)
Co-authored-by: MD <1917406+mdcfe@users.noreply.github.com> * Bumped Gradle to 7.0.2 * Now uses Java 16 for compiling to prepare for MC 1.17 * Release target is still set to 8 however * Bumped Actions versions * Bumped indra version(s) * Switched from grgit to indra-git * Fix PR GitHub Actions jars having invalid branch names
This commit is contained in:
parent
d00b90cd61
commit
23a497abf6
4 changed files with 67 additions and 21 deletions
13
.github/workflows/build-master.yml
vendored
13
.github/workflows/build-master.yml
vendored
|
@ -15,6 +15,7 @@ jobs:
|
|||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Restore Gradle cache
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
|
@ -22,15 +23,21 @@ jobs:
|
|||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-gradle-
|
||||
- name: Set up JDK 1.8
|
||||
uses: actions/setup-java@v1
|
||||
|
||||
- name: Set up JDK 16
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
java-version: 1.8
|
||||
distribution: 'adopt'
|
||||
java-version: 16
|
||||
|
||||
- name: Validate Gradle Wrapper
|
||||
uses: gradle/wrapper-validation-action@v1
|
||||
|
||||
- name: Build with Gradle
|
||||
run: |
|
||||
chmod +x gradlew
|
||||
./gradlew build --stacktrace
|
||||
|
||||
- name: Archive plugin jars on GitHub
|
||||
uses: actions/upload-artifact@master
|
||||
with:
|
||||
|
|
13
.github/workflows/build-pr.yml
vendored
13
.github/workflows/build-pr.yml
vendored
|
@ -20,6 +20,7 @@ jobs:
|
|||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Restore Gradle cache
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
|
@ -27,15 +28,21 @@ jobs:
|
|||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-gradle-
|
||||
- name: Set up JDK 1.8
|
||||
uses: actions/setup-java@v1
|
||||
|
||||
- name: Set up JDK 16
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
java-version: 1.8
|
||||
distribution: 'adopt'
|
||||
java-version: 16
|
||||
|
||||
- name: Validate Gradle Wrapper
|
||||
uses: gradle/wrapper-validation-action@v1
|
||||
|
||||
- name: Build with Gradle
|
||||
run: |
|
||||
chmod +x gradlew
|
||||
./gradlew build --stacktrace
|
||||
|
||||
- name: Archive plugin jars on GitHub
|
||||
uses: actions/upload-artifact@master
|
||||
with:
|
||||
|
|
60
build.gradle
60
build.gradle
|
@ -1,43 +1,71 @@
|
|||
buildscript {
|
||||
ext {
|
||||
indraVersion = '1.2.1'
|
||||
indraVersion = '2.0.4'
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'org.ajoberstar.grgit' version '4.1.0'
|
||||
id 'net.kyori.indra' version "$indraVersion" apply false
|
||||
id 'net.kyori.indra.git' version "$indraVersion"
|
||||
id 'net.kyori.indra.checkstyle' version "$indraVersion" apply false
|
||||
id 'net.kyori.indra.publishing' version "$indraVersion" apply false
|
||||
id 'com.github.johnrengelman.shadow' version '6.1.0' apply false
|
||||
id 'com.github.johnrengelman.shadow' version '7.0.0' apply false
|
||||
}
|
||||
|
||||
import org.apache.tools.ant.filters.ReplaceTokens
|
||||
import org.eclipse.jgit.lib.Ref
|
||||
import org.eclipse.jgit.lib.Repository
|
||||
import org.eclipse.jgit.revwalk.RevWalk
|
||||
|
||||
allprojects {
|
||||
group = 'net.essentialsx'
|
||||
version = '2.19.0-SNAPSHOT'
|
||||
}
|
||||
|
||||
@SuppressWarnings('GrMethodMayBeStatic')
|
||||
def commitsSinceLastTag() {
|
||||
if (grgit == null) {
|
||||
return 0
|
||||
if (indraGit == null || !indraGit.isPresent() || indraGit.tags().isEmpty()) {
|
||||
return -1
|
||||
}
|
||||
def tags = grgit.tag.list().stream().map({it.commit}).toList()
|
||||
def commit = grgit.head()
|
||||
def tags = indraGit.tags()
|
||||
def depth = 0
|
||||
def walk = new RevWalk(indraGit.git().getRepository())
|
||||
def commit = walk.parseCommit(indraGit.commit())
|
||||
while (true) {
|
||||
if (tags.contains(commit))
|
||||
return depth
|
||||
for (tag in tags) {
|
||||
if (walk.parseCommit(tag.getLeaf().getObjectId()) == commit) {
|
||||
walk.dispose()
|
||||
indraGit.git().close()
|
||||
return depth
|
||||
}
|
||||
}
|
||||
depth++
|
||||
commit = grgit.resolve.toCommit(commit.parentIds.get(0))
|
||||
commit = walk.parseCommit(commit.getParents()[0])
|
||||
}
|
||||
}
|
||||
|
||||
ext {
|
||||
GIT_COMMIT = grgit == null ? "unknown" : grgit.head().abbreviatedId
|
||||
GIT_BRANCH = grgit == null ? "detached-head" : grgit.branch.current().name
|
||||
@SuppressWarnings('GrMethodMayBeStatic')
|
||||
def headBranchName() {
|
||||
if (System.getenv("GITHUB_HEAD_REF") != null) {
|
||||
return System.getenv("GITHUB_HEAD_REF")
|
||||
}
|
||||
|
||||
if (!indraGit.isPresent()) {
|
||||
return "detached-head"
|
||||
}
|
||||
|
||||
Ref ref = indraGit.git().getRepository().exactRef('HEAD')?.target
|
||||
if (ref == null) {
|
||||
return "detached-head"
|
||||
}
|
||||
|
||||
return Repository.shortenRefName(ref.name)
|
||||
}
|
||||
|
||||
project.ext {
|
||||
GIT_COMMIT = !indraGit.isPresent() ? "unknown" : indraGit.commit().abbreviate(7).name()
|
||||
GIT_DEPTH = commitsSinceLastTag()
|
||||
GIT_BRANCH = headBranchName()
|
||||
|
||||
fullVersion = "${version}".replace("-SNAPSHOT", "-dev+${GIT_DEPTH}-${GIT_COMMIT}")
|
||||
|
||||
|
@ -102,7 +130,7 @@ subprojects {
|
|||
}
|
||||
|
||||
indra {
|
||||
checkstyle = "$checkstyleVersion"
|
||||
checkstyle "$checkstyleVersion"
|
||||
|
||||
github('EssentialsX', 'Essentials')
|
||||
gpl3OnlyLicense()
|
||||
|
@ -134,6 +162,10 @@ subprojects {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
javaVersions {
|
||||
target 8
|
||||
}
|
||||
}
|
||||
|
||||
compileJava {
|
||||
|
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,5 +1,5 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
Loading…
Reference in a new issue