Skip to content

Commit

Permalink
Do not use textual 'null' for dependencies without group (#725)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vampire committed Feb 20, 2023
1 parent fae2043 commit 724f61c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
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,7 +69,7 @@ class Resolver(
val resolvedCoordinate = Coordinate.from(dependency.module.id)
val originalCoordinate = coordinates[resolvedCoordinate.key]
val coord = originalCoordinate ?: resolvedCoordinate
if (originalCoordinate == null && resolvedCoordinate.groupId != "null") {
if (originalCoordinate == null && resolvedCoordinate.groupId != "none") {
project.logger.info("Skipping hidden dependency: $resolvedCoordinate")
} else {
val projectUrl = getProjectUrl(dependency.module.id)
Expand Down Expand Up @@ -167,7 +167,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 +191,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 @@ -378,7 +378,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

0 comments on commit 724f61c

Please sign in to comment.