Specify Gradle version for Eclipse

Trying to import Gradle project into Eclipse, got an error

FAILURE: Build failed with an exception.

  • Where:
    Build file ‘myProject\build.gradle’ line: 3
  • What went wrong:
    Could not compile build file ‘myProject\build.gradle’.

    startup failed:
    build file ‘myProject\build.gradle’: 3: unable to resolve class org.apache.ivy.plugins.resolver.URLResolver
    @ line 3, column 13.
    add(new org.apache.ivy.plugins.resolver.URLResolver()) {


Gradle version incompatibility – the URLResolver requires Gradle version 2.0 or lower.

Gradle version – If you do not specify a Gradle version, Eclipse uses the latest from services.gradle.org, which is 2.2 at time of posting.


To specify the version, add a folder “gradle” and underneath it another folder called “wrapper”. Then add a file “gradle-wrapper.properties” in the wrapper folder

..|_ gradle

like the above structure.

In gradle-wrapper.properties, put

Save the file.

In this case I am using 1.11. You may pick your version from https://services.gradle.org/distributions

Eclipse will use the specified version to build. Viola, no more errors. 🙂



Ghost files

Halloween has passed but I’ve been experiencing ghost files. I am trying to delete a file after reading it, but it gave me AccessDeniedException.
Here are the symptoms:

file.delete() returns false
file.exists() returns false

dir.listFiles(…) -> I see the file
in Windows Explorer -> I see the file

when I try to open the file in notepad++ – it says it doesn’t exists and asks if I want to create it — I click yes — and it says it cannot be created.

After some investigation, I have solved the mystery.

I had

turns out the stream wasn’t closed. So it was holding on to the file and kept it in a weird state.

So when I change it to

try(Stream<String> lines = Files.lines(Paths.get(filename))) {

The stream closes on exit, and I no longer get AccessDeniedException when I try to delete the file.

Although the Stream from Files gave me some hiccups (including not mockable when testing in Mockito because it is static), I still love it for its convenience.

Gradle Tutorial : Part 4 : Java Web Applications


Welcome to Part 4 of the Gradle Tutorial. This part takes off from Part 3 , where we covered building multiple interdependent Java projects.

LAST UPDATE : January 22, 2015 :
i) Fixed minor Text
ii) Updated code in Github
iii) Updated web page screenshot
iv) Fixed web/build.gradle : Added stopKey and stopPort to allow “gradle jettyStop” task to function correctly.

In this part of the tutorial, we shall look at building Java Web Applications via Gradle. As is the pattern, we shall have a multi-project scenario where we will have one Java Project that has some utility class and which is built separately. And then we have a Java Web Project that is dependent on this project and has JSP/Servlets and so on.

View original post 1,697 more words