Dependencies not being refreshed

Suddenly I’m having this issue. All my newly created Gradle projects won’t refresh any local dependencies, except from the basic that came with the build.gradle (commons-collections, junit, hamcrest)

My build.gradle is as following:

apply plugin: 'java'
apply plugin: 'eclipse'

sourceCompatibility = 1.8
version = '1.0'
jar {
    manifest {
        attributes 'Implementation-Title': 'Gradle Quickstart',
                   'Implementation-Version': version
    }
}

repositories {
    mavenCentral()
}

dependencies {
    compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
    //Newly added
    compile("org.springframework.boot:spring-boot-starter-data-jpa")
    compile("com.h2database:h2")
    //Endtag: Newly added
    testCompile group: 'junit', name: 'junit', version: '4.+'
}

test {
    systemProperties 'property': 'value'
}

uploadArchives {
    repositories {
       flatDir {
           dirs 'repos'
       }
    }
}

The Eclipse Error description shows the following:

Illegal entry in Gradle Dependencies: C:/Users/.../Eclipse_workspace/unresolved dependency - org.springframework.boot spring-boot-starter-data-jpa	org.springsource.ide.eclipse.gradle.core.classpathcontainer

and

Illegal entry in Gradle Dependencies: C:/Users/.../Eclipse_workspace/unresolved dependency - com.h2database h2org.springsource.ide.eclipse.gradle.core.classpathcontainer

The strange thing is that all of my previously created Gradle Projects before this started to happen, refreshes and downloads its dependencies without any problem!

Note: If these new projects needs to download a new dependency, then IT IS ADDED CORRECTLY.
Note2: I’ve already try deleting all the gradle cache and re-downloading every library again.

How do you call gradle? (which tasks)
Are you using the grad Eclipse plug-in?
Are you using the springsource gradle Eclipse plug-in?

I use the springsource Gradle Eclipse plug-in. I call Refresh Dependencies and Refresh All from the context menu.

Is it normal that you’re missing version
On your newly added dependencies?
Compile(“org.springframework.boot:spring-boot-starter-data-jpa”)
compile(“com.h2database:h2”)

And now that it is officially out, I suggest trying Buildship as well :blush:

Sorry!! Human stupidity has accomplished something stupid again… I think it was my mistake.

In the maelstrom of deleting some projects from the Eclipse workspace, I think i deleted some eclipse-plugin-related metadata files. And that was causing this behavior. I’ve just reinstalled the plugin and everything works great as usual!

Thanks again Francois

I’m facing some weird behavior here. It had nothing to do with the plugin reinstall. I’ve managed to fix the problem with the solution that you gave me Francois.

I’ve changed this:

compile("org.springframework.boot:spring-boot-starter-data-jpa")

with this:

compile ("org.springframework.boot:spring-boot-starter-data-jpa:1.2.4.RELEASE")

BUT!!!

All my other projects created before today, actually work with this:

compile("org.springframework.boot:spring-boot-starter-data-jpa")

Do you know why is that? Does it make any sense??


In fact, I’ve faced something even weirder, hear this. In my older projects, i’ve just tried this.

compile 'joda-time:joda-time'  (just some random lib for testing purpose)

And the project successfully downloaded and added this:

https://repo1.maven.org/maven2/joda-time/joda-time/2.5/joda-time-2.5.jar   (note the 2.5 version)

But in my new projects, created just moments ago, this code gave me the same error from the original question. So, I’ve try this:

compile 'joda-time:joda-time:2.8.1' (note the 2.8.1 latest version)

And, obviously, it worked just fine.


Why is that? Why the older projects can work without the explicit version and they automatically download some none-latest version, and the created-today projects work only with the explicit version??

Sorry for the so much extensive text. I’m not understanding all of this.

In gradle, when you declare a dependency on an external module, only the ‘name’ attribute is mandatory. ‘group’ and ‘version’ are optional.
I guess that in this case gradle takes the newest among the modules matching the specified name.
Anyway, your problem happens when using the springsource Eclipse plug-in.
A regular gradle build (ie on the command line) will work (you can print the dependency graph with the ‘dependencies’ task)

I’m not familiar enough with the springsource plug-in to know why it gives you this erratic behavior.

Try with buildship, it will only take you a few minutes to download, import your existing project, and launch your build.

Thanks!!
That is some great Great feedback! I’d never heard of buildship before and this piece of advise is simply cool!

Cheers from Argentina to France!

1 Like