I need to use execOperations.javaexec to call a groovy library so i can add a later version of groovy to the classpath than the one included in gradle. As such i need to resolve the dependency to groovy artifacts in the apply method of the plugin and build a classpath based on the results. I.e. I want to declare, resolve, and use the result in the plugin apply method. How can i use gradle functionality to do this?
What you are after is a “detached configuration”, with that term you should easily find the information you need.
1 Like
Thank you! Does something like this look like i’m on the right path?
def configuration = project.configurations.detachedConfiguration(
project.dependencies.create('group:artifact:version'),
project.dependencies.create('another.group:another-artifact:version')
)
def resolvedFiles = configuration.resolve()
def classpath = project.files(resolvedFiles)
Yes, i can confirm that this was right and i was able to get it working using detached configuration.
1 Like
You should never call resolve
on any configuraiton though.
A Configuration
is already a FileCollection
.
So if you need a FileCollection
, directly use it.
If you need a classpath string, use asPath
.
…
1 Like