opentelemetry-java-instrume.../instrumentation/rmi/javaagent/rmi-javaagent.gradle

46 lines
1.2 KiB
Groovy

apply plugin: "otel.javaagent-instrumentation"
muzzle {
pass {
coreJdk()
}
}
def rmic = tasks.register('rmic') {
dependsOn(testClasses)
def clazz = 'rmi.app.ServerLegacy'
// Try one level up too in case java.home refers to jre directory inside jdk directory
def rmicBinaryPath = ['/bin/rmic', '/../bin/rmic'].findResult {
def path = new File(System.getProperty("java.home"), it).getAbsoluteFile()
path.isFile() ? path.toString() : null
} ?: "rmic"
String command = """$rmicBinaryPath -g -keep -classpath ${sourceSets.test.output.classesDirs.asPath} -d ${buildDir}/classes/java/test ${clazz}"""
command.execute().text
}
test.dependsOn rmic
// We cannot use "--release" javac option here because that will forbid importing "sun.rmi" package.
// We also can't seem to use the toolchain without the "--release" option. So disable everything.
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
toolchain {
languageVersion = null
}
}
tasks.withType(JavaCompile).configureEach {
options.release = null
}
tasks.withType(GroovyCompile).configureEach {
options.release = null
}
tasks.withType(Test).configureEach {
jvmArgs "-Djava.rmi.server.hostname=127.0.0.1"
}