I’ve run into a bug with the Jacoco plugin, that seems to be caused either by Windows or by Java limitations for long path names. It happens when the “wrong” path is passed as -javaagent
when spawning new JVMs. I am consistently seeing the problem with all combinations of:
- Windows 10, Windows 8.1, Windows 7
- Java 7, Java 8
- Gradle 2.13, Gradle 3.0
This is how I recreate it:
- Save the contents of this pastebin to a file
C:\reproduce.bat
. - Have Gradle on your PATH.
- Run the batch file. It will create some files and run
gradle build
, which will result in an error. - Clean up by deleting
C:\reproduce.bat
andC:\my-server-root-directory
.
The fix I’ve found is pretty short: Change this line [JacocoTaskExtension.java#L268] (https://github.com/gradle/gradle/blob/2a327629cf76ec1998a8c9b6db7a6ae306903edf/subprojects/jacoco/src/main/java/org/gradle/testing/jacoco/plugins/JacocoTaskExtension.java#L268) to use the absolute instead of the relative path. Ironically, this makes the path loner, but it solves the issue.
I have only seen this happen when the relative path moves up some directories, so a slightly less invasive fix would be to check if the relative path contains ..
and use the absolute path in that case.