if I'd like to have the list of the dependencies w...
# community-support
g
if I'd like to have the list of the dependencies with their corresponding resolved versions, I think I need the consumable configuration "api/runtimeElements", am I right?
I'm trying to get a module deps from the root project with a plugin in this way:
Copy code
project.childProjects["asgard-client"]!!.afterEvaluate {
    configurations["apiElements"].allDependencies.configureEach { println(this) }
}
but I don't get the versions the module depends on a platform, so maybe they will get resolved later on?
v
You are aware that this is extreeemly evil what you try to do there? You should not try to reach into the project models of other projects. Neither to configure them, nor to get information out of them. Besides that,
apiElements
is what you consume from outside, if that is what you want to have, just declare a dependency on that project in a configuration in your project and then get the dependency information from there, no need to touch the other project's model.
g
no, I wasn't aware, good to know, though ok, so, something along these lines?
Copy code
val webstartCfg = project.configurations.maybeCreate("webstart")
project.dependencies {
    webstartCfg(project.childProjects["asgard-client"]!!)
}
v
I wouldn't use
childProjects
but simply a normal
project(...)
dependency. And you should probably not use legacy configuration setup which is used by default, but properly separate dependency scope configurations from resolvable configurations. Either by using the incubating helper methods like
configurations.dependencyScope(...)
/
configurations.resolvable(...)
or by setting the
isCanBe...
properties accordingly.
g
ok, so to add dependencies, I need a
DependencyScopeConfiguration
to resolve it, a
ResolvableConfiguration
now, how can I wire the two? Like this?
Copy code
val webstartDep by project.configurations.dependencyScope("webstartDep")
val webstartRes by project.configurations.resolvable("webstartRes") {
    extendsFrom(webstartDep)
}
v
=
not
by
, but otherwise, yes.
by
with those is like using
.register
and immediately calling
get()
, so basically like using
.create
=
with those is like using
.register
👍 1
g
problem is that
extendsFrom
expects a
Configuration
, so I do have to call a `get()`:
extendsFrom(webstartDep.get())
v
Yes
g
if I need to define some attributes to distinguish among variants, shall these be define on the dependency or on the resolvable configuration?
I just tried on the resolvable and it looks working, but I wouldn't like to do something wrong
v
On the dependency scope configuration it would not have any effect. If it is only for a specific dependency, you can do it for that dependency when you declare that dependency. If it is for all dependencies in that resolvable configuration you can do it on the resolvable configuration.