-
Notifications
You must be signed in to change notification settings - Fork 5k
Closed
Labels
a:featureA new functionalityA new functionalitygood first issueGood for newcomersGood for newcomersin:dependency-version-catalog
Milestone
Description
Consider:
fun getDependencyAsString(dependencyProvider: Provider<MinimalExternalModuleDependency>): String {
val dependency = dependencyProvider.get()
return dependency.module.toString() + ":" + dependency.versionConstraint.toString()
}
fun Project.createConfiguration(): FileCollection {
val configuration = configurations.findByName("metalava") ?: configurations.create("metalava") {
val libs = project.extensions.getByType(
VersionCatalogsExtension::class.java
).find("libs").get()
val dependency = dependencies.create(
getDependencyAsString(libs.findDependency("metalava").get())
)
it.dependencies.add(dependency)
}
return project.files(configuration)
and gradle/libs.versions.toml
[libraries]
metalava = { module = "com.android.tools.metalava:metalava", version = "1.0.0-alpha04" }
Expected Behavior
MinimalExternalModuleDependency.toString()
returns com.android.tools.metalava:metalava:1.0.0-alpha04
Current Behavior
MinimalExternalModuleDependency.toString()
returns org.gradle.api.internal.artifacts.dependencies.DefaultMinimalDependency@5e055771
, so we have to write our own getDependencyAsString function.
Context
It is very common to need string representation of a dependency and thus it should work out of the box or at least have getAsString() type method.
Maragues
Metadata
Metadata
Assignees
Labels
a:featureA new functionalityA new functionalitygood first issueGood for newcomersGood for newcomersin:dependency-version-catalog