Hi!
I have currently been working 12 hours on this last bug in migrating from Maven to Gradle, and I hope to get some pointers for a fix here.
From test method:
URL fileResource = CaseReportMock.class.getClassLoader().getResource(JasperConstants.PATH);
fileResouce is null, and I believe getClassLoader() is to blame. As I understand it, Gradle instantiates it’s own JVM for tests, rendering getClassLoader() useless.
I found this solution
FilteringClassLoader filter = getServices().get(ClassLoaderRegistry).gradleApiClassLoader.parent
filter.allowPackage('org.apache.tools.zip')
on the Nabble forum.
I also found the FilteringClassLoader-class on GitHub, but I don’t know how to define this in my project.
I can think of two possible solutions:
-
Add a modified version of the Nabbler-snippet in my Java testclass, or even in the CaseReportMock class, and define a compiledependency in the main build.gradle like so:
subproject {
dependencies {
compile: ‘org.gradle:internal:2.6’
}
}
or 2) As the snippet didn’t have semicolons, I was tempted to think that this should go in the subproject’s build.gradle.
I am totally lost, and growing desperate for help on this issue. I am aware that my definition of the compile dependency is wrong, but I’m not that skilled to just take a resource from GitHub and transform it into a dependency yet. Any pointers in the right direction will be extremely helpful!
Thanks in advance!