mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-02-16 15:40:14 +00:00
Since we now use Gradle version 6 and up, and the GitHub issue attached to the bug was resolved in Gradle 5.6.3, we don't need this workaround code anymore.
203 lines
5.6 KiB
Groovy
203 lines
5.6 KiB
Groovy
/* ###
|
|
* 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.
|
|
*/
|
|
/*****************************************************************************************
|
|
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.
|
|
*********************************************************************************/
|
|
|
|
apply plugin: 'java-library'
|
|
|
|
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
|
|
}
|
|
|
|
processResources {
|
|
duplicatesStrategy = 'exclude'
|
|
}
|
|
|
|
processTestResources {
|
|
duplicatesStrategy = 'exclude'
|
|
}
|
|
|
|
plugins.withId('java') {
|
|
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'
|
|
|
|
// Screenshots are essentially tests, and depend on classes in several other
|
|
// test directories so they must be included here
|
|
compileClasspath += main.output + test.output + integrationTest.output
|
|
runtimeClasspath += main.output + test.output + integrationTest.output
|
|
}
|
|
}
|
|
pcodeTest {
|
|
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'
|
|
}
|
|
}
|
|
}
|
|
|
|
configurations {
|
|
integrationTestImplementation.extendsFrom testImplementation
|
|
integrationTestRuntimeOnly.extendsFrom testRuntimeOnly, integrationTestImplementation
|
|
pcodeTestImplementation.extendsFrom implementation
|
|
testArtifacts.extendsFrom testRuntimeOnly
|
|
integrationTestArtifacts.extendsFrom integrationTestRuntimeOnly
|
|
screenShotsImplementation.extendsFrom integrationTestImplemenation
|
|
}
|
|
|
|
task testJar(type: Jar) {
|
|
classifier "test" // value part of file name
|
|
from sourceSets.test.output
|
|
}
|
|
|
|
task integrationTestJar(type: Jar) {
|
|
classifier "integrationTest" // value part of file name
|
|
from sourceSets.integrationTest.output
|
|
}
|
|
artifacts {
|
|
testArtifacts testJar
|
|
integrationTestArtifacts integrationTestJar
|
|
|
|
}
|
|
|
|
/*
|
|
Provide test dependencies here so each build file does not have to.
|
|
*/
|
|
dependencies {
|
|
integrationTestImplementation "org.hamcrest:hamcrest-all:1.3"
|
|
integrationTestImplementation "org.jmockit:jmockit:1.44"
|
|
|
|
testImplementation "org.hamcrest:hamcrest-all:1.3"
|
|
testImplementation "org.jmockit:jmockit:1.44"
|
|
|
|
testImplementation "junit:junit:4.12"
|
|
pcodeTestImplementation "junit:junit:4.12"
|
|
}
|
|
|
|
// 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(':'));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Fixup generated Eclipse projects
|
|
apply plugin: 'eclipse'
|
|
eclipse.classpath.file.whenMerged { classpath ->
|
|
// Prevent Gradle 5.6 from setting the 'test' attribute on our test source folders and jars.
|
|
// If we don't do this, things that we have outside of test directories that depend on test
|
|
// libraries (like junit) will not compile in Eclipse.
|
|
// Also prevent Gradle 7.0 from adding jars to the modulepath instead of the classpath.
|
|
classpath.entries.findAll {
|
|
it.kind == 'src' || it.kind == 'lib'
|
|
}.each {
|
|
it.entryAttributes['test'] = 'false'
|
|
it.entryAttributes['module'] = 'false'
|
|
}
|
|
}
|
|
|