Resolution: Won't Fix
Affects Version/s: 0.9
Fix Version/s: 0.9-rc-3
I've done an initial investigation on integrating Gradle with Nailgun. Nailgun does in fact work as advertised, and though it hasn't had a release since 2005, there is activity on the mailing list and reason to believe there will be a new release in the near future.
There are specific issues getting Gradle to work with Nailgun. The easiest way to explain this is probably to have you simply repeat the process I went through. It doesn't take long, but you will need Make installed on your machine:
- svn co https://nailgun.svn.sourceforge.net/svnroot/nailgun/trunk nailgun
- cd nailgun
- you should now have an 'ng' binary. let's call this $NG_BINARY_PATH for purposes below
- Import nailgun's java sources as an Ant project into your IDE
- Add all jars in your Gradle distribution's lib/ directory to the classpath of the nailgun project
- Run the main method in com.martiansoftware.nailgun.NGServer, with the following:
- the working directory should be the root of a gradle-based project
- You should see the following output from NGServer
- Just to prove everything is working as expected, issue the following:
in this case, the running NGServer accepted the request to execute HelloWorld's main method, and it did so. Keep in mind that HelloWorld is part of the nailgun-examples jar, and is on the classpath of the NGServer you just started up. Now let's get gradle to communicate with running NGServer in a similar fashion.
- Modify your Gradle distribution's 'gradle' script as follows:
You now have a working test environment.
- cd into the same working directory that you gave NGServer above, and run 'gradle clean'. This will probably execute without problems.
- run 'gradle clean' again. Notice that it hangs.
- switch back to your IDE console and notice this stack trace:
java.lang.ClassCastException: org.gradle.util.LinePerThreadBufferingOutputStream cannot be cast to com.martiansoftware.nailgun.ThreadLocalPrintStream
Exception in thread "NGSession 2: 127.0.0.1: org.gradle.launcher.GradleMain" java.lang.ClassCastException: org.gradle.util.LinePerThreadBufferingOutputStream cannot be cast tocom.martiansoftware.nailgun.ThreadLocalPrintStream
- Take a look at the code per the line numbers above, and you'll see that Nailgun does stdout/stderr capturing, but does so in a way that is at odds with Gradle's own stdout/err redirection. This is problem #1.
- Hack around, try commenting out the places where class casts are made, and run again.
- Notice that once you get past the classcastexceptions, you can only run gradle a few times before PermGen errors start cropping up (especially true if you're doing full 'gradle build' runs).
Nailgun seems like it has promising potential for speeding up command line performance in gradle, which I think for many is a 'first impression' issue that could make or break looking at Gradle any further. These issues would obviously need to be worked out first, however.