Simply configuring the source set is not sufficient enough to inform Eclipse of the additional configuration. You’ll have to configure the ‘eclipse’ plugin. However, you may want to take a look at the Netflix plugin specifically designed for this purpose.
I would like to avoid a third party plugin unless desired behavior can’t be achieved with Gradle provided plugins.
Configuration applied by me has been mentioned as working solutions in various articles for implementing provided dependency. So I was just wondering why its not working in my case.
It seems that I need to add following configuration to my build file -
What went wrong: A problem occurred evaluating project ‘:piston-core:piston-model’. > Cannot change configuration ‘:piston-core:piston-model:provided’ after it has been resolved.
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Take a look at the Gradle docs. There is an example there that I think fits your exact need. The only difference I see is that in the documentation example the configuration is being wrapped in a collection ‘[ configurations.provided ]’. I’m not sure how that would affect anything but you might want to give that a try.
Well it seems that extending compile from provided is causing another issue now.
In my project I have to create many jars where all these jars should have their compile and runtime dependencies in a lib folder inside the jar. Extending compile from provided is pulling provided dependencies in lib folder which should not happen.
I am not sure how that can be achieved. I am using sync task to copy runtime dependencies to lib folder. I am trying to exclude provided dependencies using following code but still provided dependencies are not excluded -
task copyDependencies(type: Sync) {
from ([ configurations.runtime ] - [ configurations.provided ])
into "$buildDir/dependencies/lib"
}
Frankly speaking I am not sure why we are extending compile from provided when these are two different type of dependencies. Also I have following code in my build.gradle script which in my opinion should be sufficient to make provided dependencies available at the time of compiling the code -
The correct way to implement this is to have ‘compile’ extend from ‘provided’. The reason for this is for dependency resolution. Gradle does dependency deconfliction per configuration. That means by simply concatenating two independent configurations you could likely have duplicate, and possibly incompatible, libraries on your classpath.