I’m trying to move from Java 6 to Java 7. When I use Java 6 Gradle works properly. However after I’ve upgraded to Java 1.7.0.15 I observe the following behavior:
When I try to build the projects that suppose to open web connection, for example, download some artifacts, the exception is raised:
Many people use Gradle with Java 7, so I’d be surprised if the ‘preferIPv4Stack’ flag would solve your problem.
The Gradle Worker that you refer to is the JVM that runs your tests, not the JVM that runs the build. The JVM arguments for test JVMs can be modified by configuring the ‘test’ task (see ‘Test’ in the Gradle Build Language Reference). But if, as you say, the problem occurs while Gradle is downloading dependences, you won’t have to configure the test JVMs.
Here is debug log of the running testing phase. It seems that gradle workers(that run in parallel) are trying to open sockets for their internal use. So that might be the issue
When I run test task I suppose Gradle will use Java 6 to run the tests(and also use IPv4 protocol).
gradle -Djava.net.preferIPv4Stack=true test
However I see in my firewall that Gradle opens(or tries to open) 6 TCP connections. Five of them are TCPv4 opened by javaw.exe. And one is java.exe(which is Java 7) and TCPv6.
TCPv6 somehow doesn’t work with Gradle so overall tests failed.
Many people are using Java 7 with Gradle and IPv6 with no problem. There’s something particular about your environment. I think you’re hitting Java bug 7179799, which I can’t find a working link for.
I don’t understand why you are getting so many test workers. Do you have ‘maxParallelForks’ set for the test task?