I am customizing a build script to download & parse a POM XML, and dynamically include some of the dependencies during ‘afterEvaluate’.
You can see it here:
It works fine but I think downloading it every time is a bit of an overkill. I could store it manually inside ‘./gradle’ folder and check if it exists. But I am wondering if there’s an official way to tell the build script this needs to be cached…like inputs in a task.
I’m not sure what you are trying to achieve. It seems tat you explicitly want to add the groovy-all & log4j dependencies to compile. Why not just add them to compile anyway without jumping through the hoops of parsing the POM?
I want add the same versions used by the SoapUI version automatically but without all the rest. For instance if I use soapUI 4.5.2 (http://smartbearsoftware.com/repository/maven2/com/smartbear/soapui/soapui/4.5.2/soapui-4.5.2.pom), it will include groovy-all 1.8.0. That way I make sure I don’t use any feature not available and the change will only require changing a single property value.
Also, there’s a second reason, that is just for fun and personal learning ^^
then run gradle dep and look at the transitive dependencies for SoapUI. He would then have to chaneg the script to
compile ("com.smartbear.soapui:soapui:$soapuiVersion") {
exclude group: 'org.reflections'
// and so on for everyone of the 20+ deps he does not want to include
}
That was my first approach, but as @Schalk_Cronje said I had to go through dependencies…and it was a huge list.
In fact what I am doing here is kind of a “includeOnly” option, because I just want the dependencies for code completion, not for actual compilation and deployment.
Thanks a lot to all, but I feel we are digressing a bit.
We are focussing on the dependency management and the question was more focused on caching files downloaded during the build.
@rahulsom I like that, even when it’s not practical to my case here it will be helpfull for another stuff I have
In short, the only simple way I know of to use caching in Gradle is to put it in a configuration. The other way is to use the VFS plugin and create a download task.