Make gradle take build number from env vars and add git build info (#5890)

* Make gradle take build number from env vars

* Add git information to manifest and version command/log

* trim

* Fix tests by adding NotNull annotations

* rebase

* Apply suggestions from kashike

Co-authored-by: Riley Park <riley.park@meino.net>

* Not always show branch

* Why can't everything be NotNull by default?

* Rebase

Co-authored-by: Riley Park <riley.park@meino.net>
This commit is contained in:
Prof-Bloodstone 2021-06-23 19:19:44 +02:00 committed by GitHub
parent 4e2f0be270
commit d50cc01b08
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 193 additions and 8 deletions

View file

@ -20,10 +20,10 @@ index 67fb370cad6924895a6b27052dbd5c1767e3f0c9..3e05459f27c4c5697ae65da504d67a6a
/.project
diff --git a/build.gradle.kts b/build.gradle.kts
new file mode 100644
index 0000000000000000000000000000000000000000..596b4f52bc57eca8cc7a0138a1e36d71c1d73ca6
index 0000000000000000000000000000000000000000..9b738b8561f75a2531d64abb36f4cd9d9561cbfc
--- /dev/null
+++ b/build.gradle.kts
@@ -0,0 +1,134 @@
@@ -0,0 +1,135 @@
+import com.github.jengelman.gradle.plugins.shadow.transformers.Log4j2PluginsCacheFileTransformer
+import com.github.jengelman.gradle.plugins.shadow.transformers.Transformer
+import io.papermc.paperweight.util.Git
@ -71,10 +71,11 @@ index 0000000000000000000000000000000000000000..596b4f52bc57eca8cc7a0138a1e36d71
+ manifest {
+ val git = Git(rootProject.layout.projectDirectory.path)
+ val gitHash = git("rev-parse", "HEAD").getText().substring(0, 7)
+ val implementationVersion = System.getenv("BUILD_NUMBER") ?: "\"$gitHash\""
+ attributes(
+ "Main-Class" to "org.bukkit.craftbukkit.Main",
+ "Implementation-Title" to "CraftBukkit",
+ "Implementation-Version" to "git-Paper-\"$gitHash\"",
+ "Implementation-Version" to "git-Paper-$implementationVersion",
+ "Implementation-Vendor" to SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(Date()), // Paper
+ "Specification-Title" to "Bukkit",
+ "Specification-Version" to project.version,