ghidra/gradleScripts/settingsUtil.gradle
2019-03-26 13:46:51 -04:00

51 lines
2.1 KiB
Groovy

/**************************************************************************************
* Method to add a single project to this gradle build.
*
* Param name: The name of the project.
* Param path: The path relative to the root project directory
* Param mustExist: True if the project directory must exist for the project to be included
* (ex: devtools exists pre-extraction but not post-extraction but still
* must be created for gradle to compile)
*
*
* Example: if name is 'Utility' and path is "Ghidra/Framework', then this is equal to
*
* include 'Utility'
* project(":Utility").projectDir = new File(rootProject.projectDir, "Ghidra/Framework/Utility")
*
* NOTE: if the project name is in the excludeProjects set, then that project will be skipped.
*
**************************************************************************************/
ext.includeProject = { name, path, mustExist ->
includeProjectNamed(name, name, path, mustExist);
}
ext.includeProjectNamed = { name, dirName, path, mustExist ->
File projectDir = new File(rootProject.projectDir, "$path/$dirName")
if (projectDir.exists() || mustExist) {
include name;
project(":$name").projectDir = projectDir;
}
}
/**************************************************************************************
* Method to add all projects in a single directory to this gradle build. It looks
* for all the directories (one leve down only) under the given path that contain a build.gradle file. Then
* for each of those, it call includeProject() to include that project.
*
* Param path: The path relative to the root project directory
*
* Example: if path is 'Ghidra/Framework', it will create projects for Utility, Generic, DB, etc.
*
**************************************************************************************/
ext.includeProjects = { path ->
FileTree fileTree = fileTree("../" + path) {
include '*/build.gradle'
}
fileTree.each { gradleBuildFile ->
String projectName = gradleBuildFile.parentFile.name
includeProject(projectName, path, true);
}
}