Fix Gradle build so you don't have to have Git

This commit is contained in:
Telesphoreo 2021-10-09 19:42:11 -05:00
parent 22278822fe
commit 30fb1ebbd5
2 changed files with 23 additions and 12 deletions

View file

@ -12,4 +12,4 @@ jobs:
with:
java-version: 17
- name: Build with Gradle
run: chmod a+x gradlew && ./gradlew build -x buildProperties
run: chmod a+x gradlew && ./gradlew build

View file

@ -3,6 +3,7 @@ plugins {
id 'maven-publish'
id 'idea'
id 'checkstyle'
id "xyz.ronella.simple-git" version "1.3.0"
id 'com.github.johnrengelman.shadow' version '7.0.0'
id 'net.minecrell.plugin-yml.bukkit' version '0.5.0'
}
@ -99,7 +100,7 @@ dependencies {
implementation('io.papermc:paperlib:1.0.6')
implementation('org.bstats:bstats-base:2.2.1')
implementation('org.bstats:bstats-bukkit:2.2.1')
implementation('org.reflections:reflections:0.9.12')
implementation('org.reflections:reflections:0.10.1')
implementation('org.javassist:javassist:3.28.0-GA')
implementation('org.jetbrains:annotations:22.0.0')
implementation('com.mattmalec:Pterodactyl4J:2.BETA_80')
@ -139,22 +140,32 @@ static def getDate() {
return new Date().format('MM/dd/yyyy HH:mm')
}
def getGitHash() {
String getGitHash() {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-parse', '--short', 'HEAD'
standardOutput = stdout
try {
exec {
commandLine "git", "rev-parse", "--short", "HEAD"
standardOutput = stdout
ignoreExitValue = true
}
} catch (GradleException e) {
logger.error("Couldn't determine Git head because Git is not installed. " + e.getMessage())
}
return stdout.toString().trim()
return stdout.size() > 0 ? stdout.toString().trim() : "unknown"
}
def getBuildNumber() {
String getBuildNumber() {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-list', 'HEAD', '--count'
standardOutput = stdout
try {
exec {
commandLine "git", "rev-list", "HEAD", "--count"
standardOutput = stdout
ignoreExitValue = true
}
} catch (GradleException e) {
logger.error("Couldn't determine Git head because Git is not installed. " + e.getMessage())
}
return stdout.toString().trim()
return stdout.size() > 0 ? stdout.toString().trim() : "unknown"
}
tasks.withType(Checkstyle) {