문제

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

올바른 솔루션이 없습니다

다른 팁

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
   }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top