Cannot change dependencies of configuration ':compile' after it has been resolved

First, you have to add a repositories block to specify where dependencies are retrieved from (usually before dependencies {...}.

repositories {
  mavenCentral()
}

Then, if you put the dependencies block before the jar block it seems to work, although I'm not sure about why it doesn't work the other way (maybe jar {...} uses the compile configuration and "locks" it).


Try to set org.gradle.configureondemand to false if you use it in gradle.properties

Tags:

Java

Gradle