|
2 | 2 | import groovy.xml.MarkupBuilder |
3 | 3 | import java.util.zip.ZipFile |
4 | 4 |
|
| 5 | +apply from: 'gradle/libs/digest.gradle' |
| 6 | + |
5 | 7 |
|
6 | 8 | if (!hasProperty('mainClass')) { |
7 | 9 | ext.mainClass = '' |
@@ -476,7 +478,51 @@ ant.properties['plugins.version'] = jmeVersion |
476 | 478 | ant.properties['app.version']= jmeFullVersion |
477 | 479 | ant.properties['nbm.revision']= jmeNbmRevision |
478 | 480 |
|
479 | | -task buildSdk(dependsOn: [copyBaseLibs, copyProjectLibs, createProjectXml, createBaseXml, copyTestSources]) <<{ |
| 481 | +task overrideHarness(dependsOn: checkPlatformConfig) << { |
| 482 | + def props = new Properties() |
| 483 | + props.load(new FileInputStream("harness-override/override.properties")) |
| 484 | + |
| 485 | + def patch_file = { f -> |
| 486 | + def g = file("harness-override/" + f.getName()) |
| 487 | + if (!f.exists()) { |
| 488 | + throw new GradleException('Cannot find targetFile: ' + f.getAbsolutePath()); |
| 489 | + } |
| 490 | + |
| 491 | + if (!g.exists()) { |
| 492 | + throw new GradleException('Cannot find sourceFile: ' + g.getAbsolutePath()); |
| 493 | + } |
| 494 | + |
| 495 | + if (getSHA256Hash(f) == props[f.getName() + ".hashAfter"]) { |
| 496 | + println "> Harness file \"" + f.getName() + "\" is already patched!" |
| 497 | + return; /* Already patched */ |
| 498 | + } |
| 499 | + if (getSHA256Hash(f) == props[f.getName() + ".hashBefore"]) { |
| 500 | + println "> Will patch harness file \"" + f.getName() + "\"!" |
| 501 | + |
| 502 | + if (getSHA256Hash(g) != props[g.getName() + ".hashAfter"]) { |
| 503 | + 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.") |
| 504 | + } |
| 505 | + |
| 506 | + copy { |
| 507 | + from g |
| 508 | + into f.getParent() |
| 509 | + } |
| 510 | + |
| 511 | + } else { |
| 512 | + throw new GradleException('Checksum Mismatch: targetFile ' + f.getName() + ' has invalid hash ' + getSHA256Hash(f) + '. Did you update Netbeans without changing harness-override/override.properties?'); |
| 513 | + } |
| 514 | + } |
| 515 | + |
| 516 | + patch_file(file("netbeans/harness/launchers/app.exe")); |
| 517 | + patch_file(file("netbeans/harness/launchers/app64.exe")); |
| 518 | + patch_file(file("netbeans/harness/launchers/pre7_app.exe")); |
| 519 | + |
| 520 | +} |
| 521 | +overrideHarness.outputs.files([ 'netbeans/harness/launchers/app.exe', 'netbeans/harness/launchers/app64.exe', 'netbeans/harness/launchers/pre7_app.exe']) |
| 522 | +overrideHarness.inputs.files([ 'netbeans/harness/launchers/app.exe', 'netbeans/harness/launchers/app64.exe', 'netbeans/harness/launchers/pre7_app.exe', 'harness-override/override.properties']) |
| 523 | + |
| 524 | + |
| 525 | +task buildSdk(dependsOn: [copyBaseLibs, copyProjectLibs, createProjectXml, createBaseXml, copyTestSources, overrideHarness]) <<{ |
480 | 526 | ant.propertyfile(file: "nbproject/project.properties") { |
481 | 527 | entry( key: "plugins.version", value: "${jmeVersion}") |
482 | 528 | entry( key: "app.version", value: "${jmeFullVersion}") |
|
0 commit comments