Why use Gradle detached configurations?

I’m reading about Gradle’s detached dependency configurations and the API docs’ method description says “Creates a configuration, but does not add it to this container”. What I’d like to know is

  • Why would I want to do this?
  • At what point would I then use this dependency configuration?

Some initial searching revealed a plugin related reason but this was not conclusive.



Note: I first posted this over on SO but then decided these forums might be a better place to ask.

One reason you might want to do this is that you might want to use Gradle’s resolution mechanism to resolve some artifact coordinates to an artifact in a more general way (say those coordinates come from some external source and not the build file). You can construct a detached configuration, resolve it, and then use the resolved artifact (say by adding it to a classloader or something). In general, you might use this as part of a plugin, but probably not in a build script anywhere.

1 Like

That makes sense - thanks for the info! Feel free to add that answer to my SO question if you want to score some fake internet points. Otherwise I can add it in.