Skip to content

Ghidra is a software reverse engineering (SRE) framework

9763: Gradle: Make distributableGhidraExtensions available at assembleAll

Johannes Obermayr5d08c7947f4f
diff --git a/Ghidra/Extensions/bundle_examples/build.gradle b/Ghidra/Extensions/bundle_examples/build.gradle
index f33e4d3e01..fb97476a3b 100644
--- a/Ghidra/Extensions/bundle_examples/build.gradle
+++ b/Ghidra/Extensions/bundle_examples/build.gradle
@@ -110,7 +110,16 @@ eclipse {
task zipExtensions(type: Zip, dependsOn:jarTasks) {
def p = this.project
archiveFileName = "${rootProject.ext.ZIP_NAME_PREFIX}_${p.name}.zip"
- destinationDirectory = rootProject.ext.DISTRIBUTION_DIR
+ destinationDirectory = file("${rootProject.ext.DISTRIBUTION_DIR}/${rootProject.ZIP_DIR_PREFIX}/Extensions/Ghidra")
+
+ doFirst {
+ destinationDirectory.get().asFile.eachFile { file ->
+ if (file.isFile() && file.name.endsWith("_${p.name}.zip")) {
+ file.delete()
+ }
+ }
+ }
+
duplicatesStrategy = 'exclude'
@@ -129,21 +138,3 @@ task zipExtensions(type: Zip, dependsOn:jarTasks) {
into p.name
}
-
-// Registratino with rootProject.createInstallationZip is ususally done in
-// "$rootProject.projectDir/gradle/distributableGhidraExtension.gradle", but
-// since we define a custom zipExtensions task (and can't overwrite it), we do
-// the registration here.
-rootProject.createInstallationZip {
- from (this.project.zipExtensions) {
- into {
- rootProject.ZIP_DIR_PREFIX + "/Extensions/Ghidra"
- }
- }
- doLast {
- this.project.zipExtensions.outputs.each {
- delete it
- }
- }
-}
-
diff --git a/gradle/distributableGhidraExtension.gradle b/gradle/distributableGhidraExtension.gradle
index 0e7eea409a..c0db58db92 100644
--- a/gradle/distributableGhidraExtension.gradle
+++ b/gradle/distributableGhidraExtension.gradle
@@ -27,15 +27,6 @@
apply from: "$rootProject.projectDir/gradle/support/distributionCommon.gradle"
apply from: "$rootProject.projectDir/gradle/support/extensionCommon.gradle"
-rootProject.createInstallationZip {
- from (this.project.zipExtensions) {
- into {
- rootProject.ZIP_DIR_PREFIX + "/Extensions/Ghidra"
- }
- }
- doLast {
- this.project.zipExtensions.outputs.each {
- delete it
- }
- }
+this.project.tasks.named('zipExtensions', Zip) {
+ destinationDirectory = rootProject.file("${rootProject.ext.DISTRIBUTION_DIR}/${rootProject.ZIP_DIR_PREFIX}/Extensions/Ghidra")
}
diff --git a/gradle/root/distribution.gradle b/gradle/root/distribution.gradle
index b816420510..84b0867aaa 100644
--- a/gradle/root/distribution.gradle
+++ b/gradle/root/distribution.gradle
@@ -672,6 +672,14 @@ task assembleAll() {
}
}
+gradle.projectsEvaluated {
+ rootProject.tasks.named('assembleAll') {
+ dependsOn rootProject.subprojects.collect { p ->
+ p.tasks.matching { it.name == 'zipExtensions' }
+ }
+ }
+}
+
/*********************************************************************************
*
* Creates the local installation zip.
diff --git a/gradle/support/extensionCommon.gradle b/gradle/support/extensionCommon.gradle
index 94e1d0d4d3..50e9f8c153 100644
--- a/gradle/support/extensionCommon.gradle
+++ b/gradle/support/extensionCommon.gradle
@@ -24,6 +24,14 @@ task zipExtensions (type: Zip) {
it.description = "Creates a zip file for an extension module. [gradle/support/extensionCommon.gradle]"
it.archiveFileName = "${rootProject.ext.ZIP_NAME_PREFIX}_${p.name}.zip"
it.destinationDirectory = rootProject.ext.DISTRIBUTION_DIR
+
+ doFirst {
+ destinationDirectory.get().asFile.eachFile { file ->
+ if (file.isFile() && file.name.endsWith("_${p.name}.zip")) {
+ file.delete()
+ }
+ }
+ }
// Make sure that we don't try to copy the same file with the same path into the
// zip (this can happen!)