Browse Source

Added an Harness-Override System allowing us to patch netbeans harness files at compile time (they are downloaded from the official netbeans sources and thus manual edits weren't possible).

This allows us to change the launcher's Icon and finally get rid of that stupid orange box :)
MeFisto94 9 years ago
parent
commit
dfe6cbb498

+ 47 - 1
build.gradle

@@ -2,6 +2,8 @@
 import groovy.xml.MarkupBuilder
 import groovy.xml.MarkupBuilder
 import java.util.zip.ZipFile
 import java.util.zip.ZipFile
 
 
+apply from: 'gradle/libs/digest.gradle'
+
 
 
 if (!hasProperty('mainClass')) {
 if (!hasProperty('mainClass')) {
     ext.mainClass = ''
     ext.mainClass = ''
@@ -476,7 +478,51 @@ ant.properties['plugins.version'] = jmeVersion
 ant.properties['app.version']= jmeFullVersion
 ant.properties['app.version']= jmeFullVersion
 ant.properties['nbm.revision']= jmeNbmRevision
 ant.properties['nbm.revision']= jmeNbmRevision
 
 
-task buildSdk(dependsOn: [copyBaseLibs, copyProjectLibs, createProjectXml, createBaseXml, copyTestSources]) <<{
+task overrideHarness(dependsOn: checkPlatformConfig) << {
+    def props = new Properties()
+    props.load(new FileInputStream("harness-override/override.properties"))
+
+    def patch_file = { f ->
+        def g = file("harness-override/" + f.getName())
+        if (!f.exists()) {
+            throw new GradleException('Cannot find targetFile: ' +  f.getAbsolutePath());
+        }
+
+        if (!g.exists()) {
+            throw new GradleException('Cannot find sourceFile: ' +  g.getAbsolutePath());
+        }
+
+        if (getSHA256Hash(f) == props[f.getName() + ".hashAfter"]) {
+            println "> Harness file \"" + f.getName() + "\" is already patched!"
+            return; /* Already patched */
+        }
+        if (getSHA256Hash(f) == props[f.getName() + ".hashBefore"]) {
+            println "> Will patch harness file \"" + f.getName() + "\"!"
+
+            if (getSHA256Hash(g) != props[g.getName() + ".hashAfter"]) {
+                throw new GradleException("Dangerous Checksum Mismatch: sourceFile \"" + g.getName() + "\" doesn't equal to its hashAfter hash. This probably means someone changed this file but forgot to update said hash or someone tried to invade the SDK by spreading his exe.")
+            }
+
+            copy {
+                from g
+                into f.getParent()
+            }
+
+        } else {
+            throw new GradleException('Checksum Mismatch: targetFile ' + f.getName() + ' has invalid hash ' + getSHA256Hash(f) +  '. Did you update Netbeans without changing harness-override/override.properties?');
+        }
+    }
+
+    patch_file(file("netbeans/harness/launchers/app.exe"));
+    patch_file(file("netbeans/harness/launchers/app64.exe"));
+    patch_file(file("netbeans/harness/launchers/pre7_app.exe"));
+
+}
+overrideHarness.outputs.files([ 'netbeans/harness/launchers/app.exe', 'netbeans/harness/launchers/app64.exe', 'netbeans/harness/launchers/pre7_app.exe'])
+overrideHarness.inputs.files([ 'netbeans/harness/launchers/app.exe', 'netbeans/harness/launchers/app64.exe', 'netbeans/harness/launchers/pre7_app.exe', 'harness-override/override.properties'])
+
+
+task buildSdk(dependsOn: [copyBaseLibs, copyProjectLibs, createProjectXml, createBaseXml, copyTestSources, overrideHarness]) <<{
     ant.propertyfile(file: "nbproject/project.properties") {
     ant.propertyfile(file: "nbproject/project.properties") {
         entry( key: "plugins.version", value: "${jmeVersion}")
         entry( key: "plugins.version", value: "${jmeVersion}")
         entry( key: "app.version", value: "${jmeFullVersion}")
         entry( key: "app.version", value: "${jmeFullVersion}")

+ 17 - 0
harness-override/README.md

@@ -0,0 +1,17 @@
+## What does this folder do?
+This is pretty simple:  
+Since our SDK is based on Netbeans we download the so-called Netbeans Harness from official sources.  
+This Harness is basicaly the Skeleton of our SDK.  
+
+In order to change the Icon on Windows Systems we need to change files of said Harness.  
+Since this harness could be re-downloaded any time we needed the `overrideHarness` build functionality.  
+  
+It overwrites harness files *each build* (When necessary).  
+In this folder are our patched .exe files which will replace the harness files.  
+The downside is that you have to manually change the icon (or whatever manual editing is required) each time a new netbeans version is used as sdk base. See the `resources/` folder for more information on that.  
+> Note: Fortunately it must not be that the .exe files are changed aswell, but look into it.
+
+To prevent patching an older version onto a newer netbeans we have the override.properties,  
+They define an `beforeHash`and an `afterHash` for each file. Before is the official netbeans source and after is our own patch file (we use this to detect an already patched file/unauthorized changes to *THIS* folder.)
+
+How do I generate such a hash? Those are SHA-256 hashes and either you make the build fail and see what gradle outputs or you issue `shasum -a 256 harness-override/*.exe` to print them out.

BIN
harness-override/app.exe


BIN
harness-override/app64.exe


+ 6 - 0
harness-override/override.properties

@@ -0,0 +1,6 @@
+app.exe.hashBefore=5d3921091a11880c143db8a6f5c55b6fec76f24d4d8bec56a8fc37e0b43b8be2
+app.exe.hashAfter=a55b5f690eb278666c3c55e169d6db2910a929e445bd44ccd0f996af3c44bac8
+app64.exe.hashBefore=909c523f0657650471caa7baa2751525604375d8b82688aad47472fdce1abe3b
+app64.exe.hashAfter=1aef0dd20c88ef4a5566ec2679a8bceda5ad4a11806f78ea5ccf4a30d7c40fa9
+pre7_app.exe.hashBefore=f4ea42a1ec2572b2a65a6d9baef0dd1f7293980c44c5d031c5b2ea5752352e49
+pre7_app.exe.hashAfter=fa8ae6457dad70a65cecb623ef0f60a86c92e856705eaeb2f22e43310fa9226f

BIN
harness-override/pre7_app.exe