Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not use textual 'null' for dependencies without group (#725) #731

Merged
merged 1 commit into from
Feb 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class PlainTextReporter(
companion object {
/** Returns the dependency key as a stringified label. */
private fun label(dependency: Dependency): String {
return "${dependency.group}:${dependency.name}"
return "${dependency.group.orEmpty()}:${dependency.name}"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,8 @@ class Resolver(
val resolvedCoordinate = Coordinate.from(dependency.module.id)
val originalCoordinate = coordinates[resolvedCoordinate.key]
val coord = originalCoordinate ?: resolvedCoordinate
if (originalCoordinate == null && resolvedCoordinate.groupId != "null") {
project.logger.info("Skipping hidden dependency: $resolvedCoordinate")
} else {
val projectUrl = getProjectUrl(dependency.module.id)
result.add(DependencyStatus(coord, resolvedCoordinate.version, projectUrl))
}
val projectUrl = getProjectUrl(dependency.module.id)
result.add(DependencyStatus(coord, resolvedCoordinate.version, projectUrl))
}

for (dependency in unresolved) {
Expand Down Expand Up @@ -167,7 +163,7 @@ class Resolver(
}

// Format the query with an optional classifier and extension
var query = "${dependency.group}:${dependency.name}:$version"
var query = "${dependency.group.orEmpty()}:${dependency.name}:$version"
if (dependency.artifacts.isNotEmpty()) {
dependency.artifacts.firstOrNull()?.classifier?.let { classifier ->
query += ":$classifier"
Expand All @@ -191,7 +187,7 @@ class Resolver(
// If no version was specified then use "none" to pass it through.
val version = if (dependency.version == null) "none" else "+"
val nonTransitiveDependency =
project.dependencies.create("${dependency.group}:${dependency.name}:$version") as ModuleDependency
project.dependencies.create("${dependency.group.orEmpty()}:${dependency.name}:$version") as ModuleDependency
nonTransitiveDependency.isTransitive = false
return nonTransitiveDependency
}
Expand Down Expand Up @@ -249,7 +245,7 @@ class Resolver(
/** Returns the coordinates for the current (declared) dependency versions. */
private fun getCurrentCoordinates(configuration: Configuration): Map<Coordinate.Key, Coordinate> {
val declared = getResolvableDependencies(configuration)
.associateBy({ it.key }, { it })
.associateBy { it.key }
if (declared.isEmpty()) {
return emptyMap()
}
Expand Down Expand Up @@ -378,7 +374,7 @@ class Resolver(
} else {
val parent = getParentFromPom(file)
if (parent != null &&
"${parent.group}:${parent.name}" != "org.sonatype.oss:oss-parent"
"${parent.group.orEmpty()}:${parent.name}" != "org.sonatype.oss:oss-parent"
) {
url = getProjectUrl(parent)
if (!url.isNullOrEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ComponentSelectionWithCurrent(
override fun toString(): String {
return """\
ComponentSelectionWithCurrent{
group="${candidate.group}",
group="${candidate.group.orEmpty()}",
module="${candidate.module}",
version="${candidate.version}",
currentVersion="$currentVersion",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,11 +358,11 @@ final class DependencyUpdatesSpec extends Specification {
with(reporter) {
unresolved.collect { it.selector }.collectEntries { dependency ->
[['group': dependency.group, 'name': dependency.name]: dependency.version]
} == [['group': 'null', 'name': 'guava-18.0']: NONE_VERSION]
} == [['group': '', 'name': 'guava-18.0']: NONE_VERSION]
upgradeVersions.isEmpty()
upToDateVersions.isEmpty()
downgradeVersions.isEmpty()
undeclared.contains(new Coordinate('null', 'guice-4.0', NONE_VERSION, null))
undeclared.contains(new Coordinate('', 'guice-4.0', NONE_VERSION, null))
}
}

Expand Down