Question

I'm building a JavaAgent which can be loaded either via --javaagent:my.jar=<option> or dynamically attached to the jvm at runtime (e.g. virtualMachine.loadAgent(jarFile, "");). In any case it requires a Jar file with proper manifest.txt file to work. Which is a problem for my tests right now.

I'm using Gradle and I'm currently struggeling with the following problems:

  1. Gradle's Test task does not depend on Jar (see here) => need to add that dependency for test execution
  2. By default the compiled test classes are add to the class path. The test class path must be removed and replaced by the jar file name

Any idea how to achieve that. Especially the 2nd?

Thanks for your help

No correct solution

OTHER TIPS

I am assuming that by 'compiled test classes' in 2, you actually mean the main classes

If so, you should be able to do 1 & 2 like this

 sourceSets {
     test {
         runtimeClasspath = output + configurations.testRuntime 
     }
 }

dependencies {
   testRuntime files(jar.archivePath) {
        builtBy jar
   }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top