Gradle: sourceSets.test.classes not found

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:

  • Something went wrong:

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:

  • Something went wrong:

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.

+4
source share
1 answer

Bug fixed:

Step 1: Move the code snippet inside the subprojects{} section

Step 2: The source file sourceSets.test.classes has been deleted. It seems that sourceSets.test.output does the trick. Found this: Creating a Jar of test binaries - Gradle

+3
source

Source: https://habr.com/ru/post/1415381/


All Articles