Run runnable jarfile that lives in a local repo?


(ian.durkan) #1

In a project, I have a situation where I need to run a runnable jarfile, call it “r.jar”, via AntBuilder’s java task. However, r.jar is a dependency that lives in a corporate remote Maven repository. It’s easy enough to add the runtime dependency, so r.jar gets copied to my Gradle local repo, but how can I get r.jar into a location where I can easily run it from my code?

i.e. if my project is in dir /home/idurkan/projectR I want to have a task that will copy r.jar from my Gradle local repo to /home/idurkan/projectR/lib/r.jar.

I do not want to need to copy files out of hardcoded paths like /home/idurkan/.gradle/caches/artifacts-4/r-corp/…/r-jar

Is what I’m describing possible in Gradle?

As an alternative, is it possible to get Gradle to report the path to the jarfile or other artifact(s) underlying a dependency?


(Peter Niederwieser) #2

You don’t need to copy the Jar file. Just create a configuration, add the dependency and get the file with myconfig.singleFile. Or, even simpler, create a JavaExec task and add the configuration to the task’s class path.