117 lines
2.6 KiB
Groovy
117 lines
2.6 KiB
Groovy
/* This extension is different from the others. It produces a zip containing
|
|
* directories of source bundles and jar bundles.
|
|
* - Each source directory is added as a sourceset so that the eclipse plugin
|
|
* can add them to the generated project.
|
|
* - the source destined to be included as jars are compiled.
|
|
*/
|
|
|
|
apply from: "$rootProject.projectDir/gradle/javaProject.gradle"
|
|
apply plugin: 'eclipse'
|
|
|
|
// there is no main jar
|
|
jar.enabled=false
|
|
|
|
eclipse.project.name = 'Xtra Bundle Examples'
|
|
|
|
|
|
dependencies {
|
|
compile project(':Base')
|
|
}
|
|
|
|
|
|
def srcDirs = []
|
|
file(project.projectDir).eachDirMatch(~/.*scripts_.*/) { srcDirs << it.name }
|
|
|
|
srcDirs.each {dirName ->
|
|
sourceSets.create(dirName) {
|
|
java {
|
|
srcDir {
|
|
dirName
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// create and return a jar task for the given source directory
|
|
def makeJarTask(dirName) {
|
|
return tasks.create("build${dirName}", Jar) {
|
|
baseName dirName
|
|
archiveName "${dirName}.jar"
|
|
ext.dirName=dirName
|
|
|
|
|
|
from(sourceSets[dirName].output) {
|
|
include "**"
|
|
}
|
|
manifest {
|
|
def manifestFile=file("${dirName}/META-INF/MANIFEST.MF")
|
|
// if there is a source manifest, use it
|
|
if(manifestFile.exists())
|
|
from manifestFile
|
|
else // otherwise, use a default manifest
|
|
attributes \
|
|
"Bundle-Name": dirName,
|
|
"Bundle-SymbolicName": dirName
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
def jarTasks=[
|
|
makeJarTask("scripts_jar1"),
|
|
makeJarTask("scripts_jar2")
|
|
]
|
|
|
|
eclipse {
|
|
classpath {
|
|
// jar1 and jar2 implement the same classes (with different OSGi package versions)
|
|
// adding both as source directories would cause errors in eclipse, so remove jar2.
|
|
sourceSets-=[sourceSets.scripts_jar2]
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// we need a alternative to the zipExtensions task from
|
|
// "$rootProject.projectDir/gradle/support/extensionCommon.gradle"
|
|
task zipExtensions(type: Zip, dependsOn:jarTasks) {
|
|
def p = this.project
|
|
archiveName "${rootProject.ext.ZIP_NAME_PREFIX}_${p.name}.zip"
|
|
destinationDir rootProject.ext.DISTRIBUTION_DIR
|
|
|
|
duplicatesStrategy 'exclude'
|
|
|
|
from '.'
|
|
|
|
srcDirs.each { f ->
|
|
include f + '/**'
|
|
}
|
|
|
|
include "scripts_*.jar"
|
|
|
|
for(jarTask in jarTasks) {
|
|
from relativePath(jarTask.archivePath)
|
|
exclude jarTask.dirName
|
|
}
|
|
|
|
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 {
|
|
ZIP_DIR_PREFIX + "/Extensions/Ghidra"
|
|
}
|
|
}
|
|
doLast {
|
|
this.project.zipExtensions.outputs.each {
|
|
delete it
|
|
}
|
|
}
|
|
}
|
|
|