/* ### * IP: GHIDRA * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ 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/extensionCommon.gradle]" it.archiveFileName = "${rootProject.ext.ZIP_NAME_PREFIX}_${p.name}.zip" it.destinationDirectory = 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 "*.pydevproject" 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) } } from (p.file('build/os')) { into { getBaseProjectName(p) + "/os" } exclude "**/*.exp" exclude "**/*.lib" } ///////////////// // EXTERNAL LIBS ///////////////// gradle.taskGraph.whenReady { taskGraph -> if (project.plugins.withType(JavaPlugin)) { List externalPaths = getExternalRuntimeDependencies(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" } } from (p.projectDir.toString() + "/build/LICENSE.txt") { into { getBaseProjectName(p) } } ///////////////// // NATIVES ///////////////// project.PLATFORMS.each { platform -> from (p.projectDir.toString() + "/os/${platform.name}") { into { getBaseProjectName(p) + "/os/${platform.name}" } } } } 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" } } } }