I am trying to get one of my projects (ProjectA) to create a jar file containing all the test classes so that it can be used in ProjectB.
I did some research and found this a possible solution: Create a test artifact banner in gradle . This suggests that the next piece of code should do the trick.
apply plugin: 'java' task testJar(type: Jar) { classifier = 'tests' from sourceSets.test.classes }
However, when I add this to my build.gradle
, I get the following error message:
There was a problem evaluating the root project "gradle_project".
Could not find property 'sourceSets' on task ': testJar'.
I searched the documentation of both Google and Gradle for more information, but either it was deleted without documentation, wherever I am, or I use it incorrectly. I suspect the latter, I just don't know what I'm doing wrong.
I tried the same piece of code inside my subprojects{}
section, but then I got the following error message:
There was a problem evaluating the root project "gradle_project".
Unable to get the value of the write-only class for testing the source code.
source share