Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 22 additions & 29 deletions dd-java-agent/instrumentation/datanucleus-4.0.5/build.gradle
Original file line number Diff line number Diff line change
@@ -1,24 +1,3 @@
import org.datanucleus.enhancer.DataNucleusEnhancer

buildscript {
repositories {
mavenLocal()
if (project.rootProject.hasProperty("mavenRepositoryProxy")) {
maven {
url project.rootProject.property("mavenRepositoryProxy")
allowInsecureProtocol = true
}
}
mavenCentral()
}

dependencies {
classpath group: 'org.datanucleus', name: 'datanucleus-core', version: '4.0.5'
classpath group: 'org.datanucleus', name: 'datanucleus-api-jdo', version: '4.0.5'
classpath group: 'org.datanucleus', name: 'javax.jdo', version: '3.2.0-m1'
}
}

muzzle {
// 2 libraries are instrumented.
// Muzzle is tested by keeping one version fixed and modifying the other
Expand All @@ -44,24 +23,34 @@ apply from: "${rootDir}/gradle/java.gradle"

def datanucleusVersion = '4.0.5'

def datanucleusEnhancer = configurations.register("datanucleusEnhancer") {
canBeConsumed = false
canBeResolved = true
}

// Datanucleus modifies persistable objects with bytecode manipulation
// The unofficial plugin (org.rm3l.datanucleus-gradle-plugin) doesn't work with our build
// The enhancement is done manually here for the test classes
// LatestDepTest can't be used because the enhancer class generates incompatible code
// Specifically, org.datanucleus.enhancer.Persistable changes package
// Only one version can be set as the script classpath in the 'buildScript' block
tasks.register('enhance') {
doLast {
def outputUrls = (sourceSets.test.output.classesDirs.files + sourceSets.test.output.resourcesDir)
def outputUrls = (datanucleusEnhancer.get().files + sourceSets.test.output.classesDirs.files + sourceSets.test.output.resourcesDir)
.findAll { it != null }
.collect { it.toURI().toURL() } as URL[]

def testClassloader = new URLClassLoader(outputUrls, Thread.currentThread().getContextClassLoader())

DataNucleusEnhancer enhancer = new DataNucleusEnhancer("JDO", null)
enhancer.setVerbose(true).addPersistenceUnit("testPersistenceUnit")
enhancer.setSystemOut(true)
enhancer.setClassLoader(testClassloader)
enhancer.enhance()
try {
def enhancerClass = testClassloader.loadClass("org.datanucleus.enhancer.DataNucleusEnhancer")
enhancerClass.getConstructor(String, Properties).newInstance("JDO", null).with {
setVerbose(true).addPersistenceUnit("testPersistenceUnit")
setSystemOut(true)
setClassLoader(testClassloader)
enhance()
}
} finally {
testClassloader.close()
}
}

dependsOn "testClasses"
Expand All @@ -82,4 +71,8 @@ dependencies {
testImplementation group: 'org.datanucleus', name: 'datanucleus-rdbms', version: datanucleusVersion
testImplementation group: 'org.datanucleus', name: 'javax.jdo', version: '3.2.0-m1'
testImplementation group: 'com.h2database', name: 'h2', version: '1.3.169'

add(datanucleusEnhancer.name, "org.datanucleus:datanucleus-core:$datanucleusVersion")
add(datanucleusEnhancer.name, "org.datanucleus:datanucleus-api-jdo:$datanucleusVersion")
add(datanucleusEnhancer.name, "org.datanucleus:javax.jdo:3.2.0-m1")
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ de.thetaphi:forbiddenapis:3.10=compileClasspath,testCompileClasspath,testRuntime
io.leangen.geantyref:geantyref:1.3.16=testRuntimeClasspath
io.sqreen:libsqreen:17.3.0=testRuntimeClasspath
javax.servlet:javax.servlet-api:3.1.0=testCompileClasspath,testRuntimeClasspath
javax.transaction:transaction-api:1.1=compileClasspath,testCompileClasspath,testRuntimeClasspath
javax.transaction:transaction-api:1.1=compileClasspath,datanucleusEnhancer,testCompileClasspath,testRuntimeClasspath
jaxen:jaxen:2.0.0=spotbugs
junit:junit:4.13.2=testRuntimeClasspath
net.bytebuddy:byte-buddy-agent:1.18.10=buildTimeInstrumentationPlugin,compileClasspath,muzzleTooling,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
Expand All @@ -81,10 +81,10 @@ org.codehaus.groovy:groovy-xml:3.0.23=codenarc
org.codehaus.groovy:groovy:3.0.23=codenarc
org.codehaus.groovy:groovy:3.0.25=testCompileClasspath,testRuntimeClasspath
org.codenarc:CodeNarc:3.7.0=codenarc
org.datanucleus:datanucleus-api-jdo:4.0.5=compileClasspath,testCompileClasspath,testRuntimeClasspath
org.datanucleus:datanucleus-core:4.0.5=compileClasspath,testCompileClasspath,testRuntimeClasspath
org.datanucleus:datanucleus-api-jdo:4.0.5=compileClasspath,datanucleusEnhancer,testCompileClasspath,testRuntimeClasspath
org.datanucleus:datanucleus-core:4.0.5=compileClasspath,datanucleusEnhancer,testCompileClasspath,testRuntimeClasspath
org.datanucleus:datanucleus-rdbms:4.0.5=testCompileClasspath,testRuntimeClasspath
org.datanucleus:javax.jdo:3.2.0-m1=compileClasspath,testCompileClasspath,testRuntimeClasspath
org.datanucleus:javax.jdo:3.2.0-m1=compileClasspath,datanucleusEnhancer,testCompileClasspath,testRuntimeClasspath
org.dom4j:dom4j:2.2.0=spotbugs
org.gmetrics:GMetrics:2.1.0=codenarc
org.hamcrest:hamcrest-core:1.3=testRuntimeClasspath
Expand Down
24 changes: 0 additions & 24 deletions gradle/forbiddenapis.gradle
Original file line number Diff line number Diff line change
@@ -1,27 +1,3 @@
buildscript {
repositories {
mavenLocal()
if (project.rootProject.hasProperty("gradlePluginProxy")) {
maven {
url project.rootProject.property("gradlePluginProxy")
allowInsecureProtocol = true
}
}
if (project.rootProject.hasProperty("mavenRepositoryProxy")) {
maven {
url project.rootProject.property("mavenRepositoryProxy")
allowInsecureProtocol = true
}
}
gradlePluginPortal()
mavenCentral()
}

dependencies {
classpath libs.forbiddenapis
}
}

apply plugin: "de.thetaphi.forbiddenapis"

def mainFilterFile = files("$rootDir/gradle/forbiddenApiFilters/main.txt")
Expand Down