import org.apache.tools.ant.filters.* task zipExtensions (type: Zip) { def p = this.project it.group 'private' it.description "Creates a zip file for an extension module. [gradle/support/distribution.gradle]" it.archiveName "${rootProject.ext.ZIP_NAME_PREFIX}_${p.name}.zip" it.destinationDir rootProject.ext.DISTRIBUTION_DIR // Make sure that we don't try to copy the same file with the same path into the // zip (this can happen!) duplicatesStrategy 'exclude' // Exclude any files that contain "delete.me" in the path; this is a convention we used // at one time that should be removed. exclude "**/delete.me" // This filtered property file copy must appear before the general // copy to ensure that it is prefered over the unmodified file File propFile = new File(p.projectDir, "extension.properties") from (propFile) { String version = "${rootProject.RELEASE_VERSION}" filter (ReplaceTokens, tokens: [extversion: version]) into { getBaseProjectName(p) } } from (p.projectDir) { f -> exclude 'build/**' exclude 'build.gradle' exclude 'certification.manifest' exclude "*.project" exclude "*.classpath" exclude 'dist/**' exclude '.gradle/**/*' exclude 'ghidra_scripts/bin/' exclude 'bin/**' exclude 'src/**' exclude 'test/**' exclude 'developer_scripts' exclude 'data/build.xml' exclude '**/.settings/**' // general place where extension modules can put files that won't get // included in standard zip exclude 'contribZipExclude/**' into { getBaseProjectName(p) } } ///////////////// // EXTERNAL LIBS ///////////////// gradle.taskGraph.whenReady { taskGraph -> List externalPaths = getExternalDependencies(p) externalPaths.each { path -> from (path) { into { getBaseProjectName(p) + "/lib" } } } } ///////////////// // GLOBALS ///////////////// // First get a list of all files that are under 'src/global'. FileTree fileTree = project.fileTree('src/global') { include '**/*' } // Now loop over each one, copying it into the zip we're creating. Each will be placed // at the root level, starting with the first folder AFTER 'src/global/'. // // eg: If the file is '/Ghidra/Configurations/Common/src/global/docs/hello.html', then // the file in the zip will be at /docs/hello.html // fileTree.each { File file -> String filePath = getGlobalFilePathSubDirName(file) from (file) { into filePath } } // handle special case where modules build data artifacts into the build dir from (p.projectDir.toString() + "/build/data") { into { getBaseProjectName(p) + "/data" } } ///////////////// // NATIVES ///////////////// project.OS_NAMES.each { platform -> from (p.projectDir.toString() + "/os/$platform") { into { getBaseProjectName(p) + "/os/$platform" } } } } plugins.withType(JavaPlugin) { zipExtensions { def p = this.project from (p.jar) { // use closures for getting zip path to delay evaluation. See note at top of file. into { getBaseProjectName(p) + "/lib" } } from (p.tasks["zipSourceSubproject"]) { into { getBaseProjectName(p) + "/lib" } } } }