-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gradle
52 lines (44 loc) · 2.03 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//version: 1707058017
plugins {
id 'com.gtnewhorizons.gtnhconvention'
id 'com.palantir.git-version'
}
// The planned name of the next release
def NEXT_VERSION = ext.modVersion
// Append to the version as needed. If the variables look a bit strange, that's because they are -
// git-version doesn't expose a ton of useful functions, we need to extract them indirectly.
// If we have a clean tag (or manually specified), this is a production release.
// No need for the commit hash!
def details = versionDetails()
def isPlainTag = details.getCommitDistance() == 0 && details.getLastTag().isEmpty()
boolean noCommitHash = providers.gradleProperty("noCommitHash").isPresent() || details.gitHash.isEmpty()
if (!isPlainTag && !noCommitHash) {
if(!NEXT_VERSION.isEmpty()) {
NEXT_VERSION += "-"
}
NEXT_VERSION += details.gitHash
}
// If we have uncommitted changes, say so.
def isDirty = gitVersion().endsWith(".dirty")
if (isDirty && !noCommitHash) {
NEXT_VERSION += "-dirty"
}
//Set the mod and jar version to the info we just collected.
version = NEXT_VERSION
minecraft {
//Creates a tag in Tags with the above generated mod version, instead of the "clean" one
injectedTags.put("RAW_VERSION", NEXT_VERSION)
injectedTags.put("MOD_ID", project.modId)
injectedTags.put("MOD_NAME", project.modName)
injectedTags.put("MOD_GROUP", project.modGroup)
//Returns true if this build is in a dev env or has a commit hash (typically used by CI), false if otherwise
injectedTags.put("CI_BUILD", !noCommitHash)
//Returns true if this build is the above or has key words in its name that indicate it may not be a release build
injectedTags.put("SNAPSHOT_BUILD", !noCommitHash
|| NEXT_VERSION.contains("snapshot")
|| NEXT_VERSION.contains("nightly")
|| NEXT_VERSION.contains("alpha")
|| NEXT_VERSION.contains("beta")
|| NEXT_VERSION.contains("rc")
|| (NEXT_VERSION.contains("release") && NEXT_VERSION.contains("candidate")))
}