|
1 | 1 | plugins { |
2 | 2 | id 'fabric-loom' version "0.7-SNAPSHOT" // To use chocoloom, change the version to a commit hash |
3 | 3 | id 'maven-publish' |
| 4 | + id 'org.ajoberstar.grgit' version '4.1.0' |
4 | 5 | } |
5 | 6 |
|
6 | 7 | sourceCompatibility = JavaVersion.VERSION_1_8 |
7 | 8 | targetCompatibility = JavaVersion.VERSION_1_8 |
8 | 9 |
|
9 | | -archivesBaseName = project.archives_base_name |
10 | | -version = "${project.mod_version}+${project.minecraft_version}" as Object |
| 10 | +def getVersionMetadata() { |
| 11 | + // CI builds version numbers |
| 12 | + def build_id = System.getenv("RELEASE_NUMBER") |
| 13 | + if (build_id != null) { |
| 14 | + return build_id + ".0.0" |
| 15 | + } |
| 16 | + |
| 17 | + // Development builds |
| 18 | + if (grgit == null) { |
| 19 | + return "dev" |
| 20 | + } |
| 21 | + |
| 22 | + // Named development builds |
| 23 | + def id = grgit.head().abbreviatedId |
| 24 | + if (!grgit.status().clean) { |
| 25 | + id += "-dirty" |
| 26 | + } |
| 27 | + |
| 28 | + return "rev.${id}" |
| 29 | +} |
| 30 | + |
| 31 | +archivesBaseName = "${project.mod_id}-${project.minecraft_version}" |
| 32 | +version = "${getVersionMetadata()}" |
11 | 33 | group = project.maven_group |
12 | 34 |
|
13 | 35 | repositories { |
@@ -58,10 +80,11 @@ if (System.getProperty("os.name").toLowerCase().contains("mac")) { |
58 | 80 | } |
59 | 81 |
|
60 | 82 | processResources { |
| 83 | + inputs.property "mod_id", project.mod_id |
61 | 84 | inputs.property "version", project.version |
62 | 85 |
|
63 | 86 | filesMatching("fabric.mod.json") { |
64 | | - expand "version": project.version |
| 87 | + expand "mod_id": project.mod_id, "version": project.version |
65 | 88 | } |
66 | 89 | } |
67 | 90 |
|
|
0 commit comments