Error opening jacocoagent.jar due to long path to

plugins
issue-acknowledged
gradle-3547

(Vital Lobachevskij) #1

Hi,

When ‘jacoco’ plugin is applied for all subproject in my multiproject build

subprojects { apply plugin: 'jacoco' }

‘gradle test’ failed with the error like this one:

:my.long.subproject.name:test
Error opening zip file or JAR manifest missing : …/…/build/components/my.long.subproject.name/tmp/expandedArchives/org.jacoco.agent-0.7.6.201602180812.jar_29dabwwwl4sb8maj0h13tor2d/jacocoagent.jar
Error occurred during initialization of VM
agent library failed to init: instrument
Could not write standard input into: Gradle Test Executor 2.
java.io.IOException: The pipe is being closed
at java.io.FileOutputStream.writeBytes(Native Method)
at java.io.FileOutputStream.write(FileOutputStream.java:326)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
at org.gradle.process.internal.streams.ExecOutputHandleRunner.run(ExecOutputHandleRunner.java:56)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
:my.long.subproject.name:test FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:my.long.subproject.name:test’.

Process Gradle Test Executor 2 finished with non-zero exit value 1

I’ve found that Gradle starts ‘Gradle Test Executor’ processes using commands like this one:

java.exe -Djava.security.manager=worker.org.gradle.process.internal.worker.child.BootstrapSecurityManager -javaagent:…/…/build/components/my.long.subproject.name/tmp/expandedArchives/org.jacoco.agent-0.7.6.201602180812.jar_29dabwwwl4sb8maj0h13tor2d/jacocoagent.jar=destfile=…/…/build/components/my.long.subproject.name/jacoco/test.exec,append=true,inclnolocationclasses=false,dumponexit=true,output=file,jmx=false -Xms256m -Xmx1024m -Dfile.encoding=windows-1251 -Duser.country=US -Duser.language=en -Duser.variant -ea -cp C:\Users\Vital_Lobachevskij.gradle\caches\2.14\workerMain\gradle-worker.jar worker.org.gradle.process.internal.worker.GradleWorkerMain ‘Gradle Test Executor 2’

It works in the same way for all subprojects. But, if the subproject name is rather long, e.g. ‘my.long.subproject.name’, Gradle can’t open jacocoagent.jar. On my local, full path to this jar for ‘my.long.subproject.name’ is d:\Projects…\build\components\my.long.subproject.name\tmp\expandedArchives\org.jacoco.agent-0.7.6.201602180812.jar_29dabwwwl4sb8maj0h13tor2d\jacocoagent.jar (179 chars) and the error is thrown.
If I move project folder to the root of disk D, the full path will be shorter (156 chars) and unit tests are passed successfully and code coverage is generated.

I didn’t find any length limitation for ‘javaagent’ parameter. Maybe, the path is loaded into a fixed length buffer inside the plugin.

I don’t see any good workaround right now except excluding some subprojects if length of the path to the jar exceeds a hardcoded limit. Any ideas? Is it know issue on Windows?

Thanks

Gradle Version: 2.14
Operating System: Windows 10


(Stefan Wolf) #2

Hi Vital,

thanks for reporting! I opened GRADLE-3547 to track this issue. I hope to be able to look into it shortly.

Regards,
Stefan


(Vital Lobachevskij) #3

Thank you, Stefan!

Vital