This message was deleted.
# dependency-management
s
This message was deleted.
c
I saw there is a
copy
method in
Configuration
but the comment is scary:
// Instead of copying a configuration's roles outright, we allow copied configurations
// to assume any role. However, any roles which were previously disabled will become
// deprecated in the copied configuration. In 9.0, we will update this to copy
// roles and deprecations without modification. Or, better yet, we will remove support
// for copying configurations altogether.
maybe I can do something like:
Copy code
configuration.dependencies.forEach {
  val newConfiguration = ...
  project.dependencies {
    newConfiguration(it)
  }
}
but... dependencies doesn't provide a live collection, so I guess I'll need an afterEvaluate
v
What's the use-case?
c
the same as last days šŸ˜‚
I have libs, for each lib I require a classpath (to be loaded with a different classloader)
so libA ends having a folder called libA containing all it's dependencies
I did use a collection for the libs project paths and created all the configurations when I already new the "bundles" (groups of libraries)
but it requires adding the paths before creating bundles, now I want to make it more "declarative" let's have a configuration for all those libs, and later when I know the bundles split the configuration per library to create the paths
(sorry, trying to remove the big amount of naming that would require more and more context..but it becomes messy)
let's see if I can make it simple: We have a service with "plugins" (each plugin = a classpath) We have different "flavours" of the server containing the server + a collection of plugins
• I want to declare all the plugins (using a configuration for all) • create a configuration for each plugin (to have my classpath per plugin)
actually
Copy code
afterEvaluate {
  configuration.dependencies.forEach {
    val newConfiguration = ...
    project.dependencies {
      newConfiguration(it)
    }
  }
}
seems to work fine
v
But `afterEvaluate`is evil šŸ˜„
šŸ¤ 1
There is a hook that is called right before dependency resolution, for example to add last-minute dependencies. Maybe that one would be a bit more appropriate than
afterEvaluate
?
c
which?
v
Searching for it, I always forget it
Ah, have it
c
(closing my laptop for today, CI is running to validate if everything works after the changes)
v
configuration.withDependencies { ... }
c
hum...never heard about it but I can try tomorrow morning
v
I think it should be exactly what you need šŸ™‚
Good night
c
reading the docs it doesn't seem so, but anyway, I'll try (again as always I learnt something from you, thanks!)
v
Always a pleasure šŸ™‚
Here an example of Jendrik where he uses it to make sure all dependencies are declared without version: https://github.com/jjohannes/gradle-project-setup-howto/blob/main/gradle/plugins/d[…]/main/kotlin/org.example.dependency-analysis-project.gradle.kts