2021-03-17 22:22:43 +00:00
|
|
|
/* ###
|
|
|
|
* 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.
|
|
|
|
*/
|
2019-04-09 15:59:17 +00:00
|
|
|
/*****************************************************************************************
|
|
|
|
This file is a "mix-in" gradle script that individual gradle projects should include if they
|
|
|
|
have java code.
|
|
|
|
|
|
|
|
A gradle project can add java support by including the following to its build.gradle file:
|
|
|
|
|
|
|
|
apply from: "$rootProject.projectDir/gradle/support/distributableGhidraModule.gradle"
|
|
|
|
*****************************************************************************************/
|
|
|
|
|
|
|
|
import org.gradle.plugins.ide.eclipse.model.Container;
|
|
|
|
import org.gradle.plugins.ide.eclipse.model.Library;
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************************
|
|
|
|
* Subproject configuration
|
|
|
|
* - all subs will have access to these properties.
|
|
|
|
*********************************************************************************/
|
|
|
|
|
2021-04-12 15:07:06 +00:00
|
|
|
apply plugin: 'java-library'
|
2019-04-09 15:59:17 +00:00
|
|
|
|
|
|
|
compileJava {
|
|
|
|
options.compilerArgs << '-Xlint:none'
|
|
|
|
options.compilerArgs << '-XDignore.symbol.file'
|
|
|
|
options.fork = true
|
|
|
|
options.warnings = false
|
|
|
|
}
|
|
|
|
|
|
|
|
compileTestJava {
|
|
|
|
options.compilerArgs << '-Xlint:none'
|
|
|
|
options.compilerArgs << '-XDignore.symbol.file'
|
|
|
|
options.fork = true
|
|
|
|
options.warnings = false
|
|
|
|
}
|
2021-04-12 15:07:06 +00:00
|
|
|
|
|
|
|
processResources {
|
|
|
|
duplicatesStrategy = 'exclude'
|
|
|
|
}
|
|
|
|
|
|
|
|
processTestResources {
|
|
|
|
duplicatesStrategy = 'exclude'
|
|
|
|
}
|
2019-04-09 15:59:17 +00:00
|
|
|
|
2024-06-12 14:04:40 +00:00
|
|
|
java {
|
2019-04-09 15:59:17 +00:00
|
|
|
sourceCompatibility = "${rootProject.JAVA_COMPILER}"
|
|
|
|
targetCompatibility = "${rootProject.JAVA_COMPILER}"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
jar {
|
|
|
|
manifest {
|
|
|
|
attributes (
|
|
|
|
"Specification-Title": "${project.name}",
|
|
|
|
"Specification-Version": "${rootProject.RELEASE_VERSION}",
|
|
|
|
"Specification-Vendor": "Ghidra"
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sourceSets {
|
|
|
|
main {
|
|
|
|
java {
|
|
|
|
srcDir 'src/main/java'
|
|
|
|
}
|
|
|
|
resources {
|
|
|
|
srcDir 'src/main/resources'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
test {
|
|
|
|
java {
|
|
|
|
srcDir 'src/test/java'
|
|
|
|
}
|
|
|
|
resources {
|
|
|
|
srcDir 'src/test/resources'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
integrationTest {
|
|
|
|
java {
|
|
|
|
srcDirs = ['src/test.slow/java'] // overwrite srcDir with new path
|
|
|
|
compileClasspath += main.output + test.output
|
|
|
|
runtimeClasspath += main.output + test.output
|
|
|
|
}
|
|
|
|
resources {
|
|
|
|
srcDirs = ['src/test.slow/resources']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
screenShots {
|
|
|
|
java {
|
|
|
|
srcDir 'src/screen/java'
|
2019-08-06 20:45:18 +00:00
|
|
|
|
|
|
|
// Screenshots are essentially tests, and depend on classes in several other
|
|
|
|
// test directories so they must be included here
|
2019-08-05 17:31:31 +00:00
|
|
|
compileClasspath += main.output + test.output + integrationTest.output
|
|
|
|
runtimeClasspath += main.output + test.output + integrationTest.output
|
2019-04-09 15:59:17 +00:00
|
|
|
}
|
|
|
|
}
|
2019-06-25 13:37:15 +00:00
|
|
|
pcodeTest {
|
2019-04-09 15:59:17 +00:00
|
|
|
java {
|
|
|
|
srcDir 'src/test.processors/java'
|
|
|
|
compileClasspath += main.output
|
|
|
|
runtimeClasspath += main.output
|
|
|
|
}
|
|
|
|
resources {
|
|
|
|
srcDir 'src/test.processors/resources'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
scripts {
|
|
|
|
java {
|
|
|
|
srcDir 'developer_scripts'
|
|
|
|
srcDir 'ghidra_scripts'
|
2023-02-12 18:40:07 +00:00
|
|
|
compileClasspath += main.output
|
2019-04-09 15:59:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
configurations {
|
2021-04-12 15:07:06 +00:00
|
|
|
integrationTestImplementation.extendsFrom testImplementation
|
|
|
|
integrationTestRuntimeOnly.extendsFrom testRuntimeOnly, integrationTestImplementation
|
|
|
|
pcodeTestImplementation.extendsFrom implementation
|
2023-02-12 18:40:07 +00:00
|
|
|
scriptsImplementation.extendsFrom implementation
|
2021-04-12 15:07:06 +00:00
|
|
|
testArtifacts.extendsFrom testRuntimeOnly
|
|
|
|
integrationTestArtifacts.extendsFrom integrationTestRuntimeOnly
|
2023-02-06 18:25:11 +00:00
|
|
|
screenShotsImplementation.extendsFrom integrationTestImplementation
|
2019-04-09 15:59:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
task testJar(type: Jar) {
|
2023-02-17 18:01:37 +00:00
|
|
|
archiveClassifier.set("test") // value part of file name
|
2019-04-09 15:59:17 +00:00
|
|
|
from sourceSets.test.output
|
|
|
|
}
|
|
|
|
|
|
|
|
task integrationTestJar(type: Jar) {
|
2023-02-17 18:01:37 +00:00
|
|
|
archiveClassifier.set("integrationTest") // value part of file name
|
2019-04-09 15:59:17 +00:00
|
|
|
from sourceSets.integrationTest.output
|
|
|
|
}
|
|
|
|
artifacts {
|
|
|
|
testArtifacts testJar
|
|
|
|
integrationTestArtifacts integrationTestJar
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Provide test dependencies here so each build file does not have to.
|
|
|
|
*/
|
|
|
|
dependencies {
|
2022-05-04 17:00:33 +00:00
|
|
|
integrationTestImplementation "org.hamcrest:hamcrest:2.2"
|
2019-04-09 15:59:17 +00:00
|
|
|
|
2022-05-04 17:00:33 +00:00
|
|
|
testImplementation "org.hamcrest:hamcrest:2.2"
|
2019-04-09 15:59:17 +00:00
|
|
|
|
2021-04-12 15:07:06 +00:00
|
|
|
testImplementation "junit:junit:4.12"
|
|
|
|
pcodeTestImplementation "junit:junit:4.12"
|
2019-04-09 15:59:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// For Java 9, we must explicitly export references to the internal classes we are using.
|
|
|
|
// We export them to all "unnamed" modules, which are modules that don't define themselves
|
|
|
|
// as a new Java 9 style module. Ghidra is currently using unnamed modules everywhere.
|
|
|
|
ext.addExports = { List<String> exports ->
|
|
|
|
tasks.withType(JavaCompile) {
|
|
|
|
exports.each {
|
|
|
|
options.compilerArgs.addAll(['--add-exports', it])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
eclipse.classpath.file.whenMerged { classpath ->
|
|
|
|
classpath.entries.each { ent ->
|
|
|
|
if (ent instanceof Container && ent.path.contains('JRE_CONTAINER')) {
|
|
|
|
ent.entryAttributes.put('module', true);
|
|
|
|
ent.entryAttributes.put('add-exports', exports.join(':'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-09-03 17:51:30 +00:00
|
|
|
|
2023-02-23 15:08:17 +00:00
|
|
|
// Customize generated Eclipse projects
|
2019-09-03 17:51:30 +00:00
|
|
|
apply plugin: 'eclipse'
|
2023-02-23 15:08:17 +00:00
|
|
|
eclipse {
|
|
|
|
classpath {
|
|
|
|
|
|
|
|
// Expose test classes to dependent projects
|
|
|
|
containsTestFixtures = true
|
|
|
|
|
|
|
|
// Customizing which Eclipse source directories should be marked as test.
|
|
|
|
// Only screenShots must be added...test and integrationTest are automatically picked up.
|
|
|
|
// NOTE: When we upgrade to Gradle 7.5+, we can just set the "testSourceSets" property
|
|
|
|
file {
|
|
|
|
whenMerged { classpath ->
|
|
|
|
classpath.entries.findAll {
|
|
|
|
it.kind == 'src' && it.path.startsWith('src/screen/')
|
|
|
|
}.each {
|
|
|
|
it.entryAttributes['test'] = 'true'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-09-03 17:51:30 +00:00
|
|
|
}
|
|
|
|
}
|