What would be the best approach to add all resolve...
# community-support
t
What would be the best approach to add all resolved dependencies from resolvable configuration into consumable configuration artifacts without triggering the resolvable configuration resolve unless consumable configuration was requested by some other project?
✔️ 1
ArtifactHandler
has only
add
method which requires single artifact, while resolvable configuration may have more than one. So such approach is not working in some cases:
Copy code
artifacts {
    add(
        outgoingConf.name,
        resolvedConf.map { it.resolve().single() }
    )
}
I've come up with this solution, but it resolves configuration on every build:
Copy code
val resolvedConf = configurations.resolvable("resolveClasspath") {
    dependencies.addLater(providers.provider {
        project.dependencies.create("group:name:version")
    })
}

val outgoingConf = configurations.consumable("outElements") 

resolvedConf.get().incoming.afterResolve {
    files.forEach {
        project.artifacts.add(
            outgoingConf.name,
            it
        )
    }
}

afterEvaluate {
    resolvedConf.get().resolve()
}
FTR: this works:
Copy code
outgoingConf.configure {
    outgoing.artifacts(resolvedConf)
}