mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2026-05-24 09:54:43 -04:00
fix: version files for components now reproducable
Hash the jar (which is now reproducable) and use that for version file Also made it so it is no longer dependent on `pwd` being the root project. Should fix part of the issues this has on compiling in android (termux / Android Code Studio)
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
|
||||
276e966873587ef19ddad2f320052b8c10ff7a77
|
||||
5aeae791eead9c6c47670c0886d77b1b185947fd
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
f090d130b1b02def937f26cc62c38ef429ed7b52
|
||||
@@ -8,13 +8,19 @@ java {
|
||||
}
|
||||
|
||||
jar {
|
||||
destinationDirectory.set(file("../app_pojavlauncher/src/main/assets/components/arc_dns_injector/"))
|
||||
manifest {
|
||||
attributes("Manifest-Version": "1.0",
|
||||
"PreMain-Class": "git.artdeell.arcdns.ArcDNSInjectorAgent")
|
||||
}
|
||||
if (gitUsed()){
|
||||
File versionFile = file("../app_pojavlauncher/src/main/assets/components/arc_dns_injector/version")
|
||||
versionFile.write(getGitHash(project.projectDir))
|
||||
// Makes the jar reproducible so the version file actually is a version file
|
||||
preserveFileTimestamps = false
|
||||
reproducibleFileOrder = true
|
||||
// Write version file
|
||||
def versionFile = new File(project(":app_pojavlauncher").projectDir, "src/main/assets/components/arc_dns_injector/version")
|
||||
def jarFile = archiveFile.get().asFile
|
||||
doLast {
|
||||
writeVersionFile(jarFile, versionFile)
|
||||
}
|
||||
destinationDirectory.set(file("../app_pojavlauncher/src/main/assets/components/arc_dns_injector/"))
|
||||
outputs.file(versionFile) // Adds the versionFile to outputs
|
||||
}
|
||||
38
build.gradle
38
build.gradle
@@ -1,33 +1,19 @@
|
||||
import java.io.IOException
|
||||
import java.security.MessageDigest
|
||||
|
||||
plugins{
|
||||
id 'com.android.application' version '8.7.2' apply false
|
||||
id 'com.android.library' version '8.7.2' apply false
|
||||
}
|
||||
|
||||
String getGitHash(File project) {
|
||||
def command = Runtime.getRuntime().exec("git rev-list -1 HEAD " + project + "/src")
|
||||
def returnCode = command.waitFor()
|
||||
if (returnCode != 0) {
|
||||
throw new IOException("Command 'getGitHash()' exited with " + returnCode)
|
||||
static void writeVersionFile(File jarFile, File versionFile){
|
||||
def sha256 = MessageDigest.getInstance("SHA-1")
|
||||
jarFile.withInputStream { is ->
|
||||
byte[] buffer = new byte[8192]
|
||||
int read
|
||||
while ((read = is.read(buffer)) != -1) {
|
||||
sha256.update(buffer, 0, read)
|
||||
}
|
||||
}
|
||||
String gitCommitHash = command.inputStream.text.trim()
|
||||
return gitCommitHash
|
||||
}
|
||||
|
||||
Boolean gitUsed() {
|
||||
def returnCode = Runtime.getRuntime().exec("git rev-parse --is-inside-work-tree").waitFor()
|
||||
switch(returnCode){
|
||||
case 127:
|
||||
println("git not found");
|
||||
return false;
|
||||
break;
|
||||
case 128:
|
||||
println("not inside a git repository");
|
||||
return false;
|
||||
break;
|
||||
case 0:
|
||||
return true;
|
||||
default:
|
||||
throw new IOException("Command 'gitUsed()' exited with " + returnCode)
|
||||
}
|
||||
def hash = sha256.digest().collect { String.format("%02x", it) }.join()
|
||||
versionFile.write(hash)
|
||||
}
|
||||
|
||||
@@ -12,16 +12,22 @@ dependencies {
|
||||
}
|
||||
|
||||
jar {
|
||||
from {
|
||||
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
|
||||
}
|
||||
if (gitUsed()){
|
||||
File versionFile = file("../app_pojavlauncher/src/main/assets/components/forge_installer/version")
|
||||
versionFile.write(getGitHash(project.projectDir))
|
||||
}
|
||||
destinationDirectory.set(file("../app_pojavlauncher/src/main/assets/components/forge_installer/"))
|
||||
manifest {
|
||||
attributes("Manifest-Version": "1.0",
|
||||
"PreMain-Class": "git.artdeell.installer_agent.Agent")
|
||||
}
|
||||
destinationDirectory.set(file("../app_pojavlauncher/src/main/assets/components/forge_installer/"))
|
||||
from {
|
||||
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
|
||||
}
|
||||
// Makes the jar reproducible so the version file actually is a version file
|
||||
preserveFileTimestamps = false
|
||||
reproducibleFileOrder = true
|
||||
// Write version file
|
||||
def versionFile = new File(project(":app_pojavlauncher").projectDir, "src/main/assets/components/forge_installer/version")
|
||||
def jarFile = archiveFile.get().asFile
|
||||
doLast {
|
||||
writeVersionFile(jarFile, versionFile)
|
||||
}
|
||||
outputs.file(versionFile) // Adds the versionFile to outputs
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import java.security.MessageDigest
|
||||
|
||||
plugins {
|
||||
id 'java'
|
||||
}
|
||||
@@ -8,25 +10,31 @@ configurations.default.setCanBeResolved(true)
|
||||
|
||||
jar {
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
archiveBaseName = "lwjgl-glfw-classes"
|
||||
archiveBaseName.set("lwjgl-glfw-classes")
|
||||
destinationDirectory.set(file("../app_pojavlauncher/src/main/assets/components/lwjgl3/"))
|
||||
if (gitUsed()){
|
||||
File versionFile = file("../app_pojavlauncher/src/main/assets/components/lwjgl3/version")
|
||||
versionFile.write(getGitHash(project.projectDir))
|
||||
}
|
||||
from {
|
||||
configurations.default.collect {
|
||||
println(it.getName())
|
||||
it.isDirectory() ? it : zipTree(it)
|
||||
}
|
||||
}
|
||||
// Makes the jar reproducible so the version file actually is a version file
|
||||
preserveFileTimestamps = false
|
||||
reproducibleFileOrder = true
|
||||
// Write version file
|
||||
def versionFile = new File(project(":app_pojavlauncher").projectDir, "src/main/assets/components/lwjgl3/version")
|
||||
def jarFile = archiveFile.get().asFile
|
||||
doLast {
|
||||
writeVersionFile(jarFile, versionFile)
|
||||
}
|
||||
outputs.file(versionFile) // Adds the versionFile to outputs
|
||||
|
||||
exclude 'net/java/openjdk/cacio/ctc/**'
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion = JavaLanguageVersion.of(8)
|
||||
}
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -9,17 +9,23 @@ java {
|
||||
}
|
||||
|
||||
jar {
|
||||
destinationDirectory.set(file("../app_pojavlauncher/src/main/assets/components/methods_injector_agent/"))
|
||||
archiveBaseName.set("methods_injector_agent")
|
||||
manifest {
|
||||
attributes("Manifest-Version": "1.0",
|
||||
"PreMain-Class": "org.angelauramc.methodsInjectorAgent.startInjectors",
|
||||
"Can-Redefine-Classes": "true")
|
||||
}
|
||||
if (gitUsed()){
|
||||
File versionFile = file("../app_pojavlauncher/src/main/assets/components/methods_injector_agent/version")
|
||||
versionFile.write(getGitHash(project.projectDir))
|
||||
// Makes the jar reproducible so the version file actually is a version file
|
||||
preserveFileTimestamps = false
|
||||
reproducibleFileOrder = true
|
||||
// Write version file
|
||||
def versionFile = new File(project(":app_pojavlauncher").projectDir, "src/main/assets/components/methods_injector_agent/version")
|
||||
def jarFile = archiveFile.get().asFile
|
||||
doLast {
|
||||
writeVersionFile(jarFile, versionFile)
|
||||
}
|
||||
destinationDirectory.set(file("../app_pojavlauncher/src/main/assets/components/methods_injector_agent/"))
|
||||
outputs.file(versionFile) // Adds the versionFile to outputs
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
Reference in New Issue
Block a user