Utilize base-version instead of version #175
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Ahoy,
I've been integrating this amazing plugin into my stack to get BOMs, however I'd noticed my dependency graph is incomplete due to a subtly in maven's distinction between base-version and version.
The dependency tree of my project looks something like this when doing a
mvn dependency:tree
:While my BOM does contain all those dependencies, the dependency graph does not include
spring-boot
oranother-artifact
. I've spent some time tracking down the cause of the issue and found it stems from inconsistent version numbers in the purls being compared here: BaseCycloneDxMojo.java#L898Where
componentRefs
contains a purl using a version like1.0.0-SNAPSHOT
foranother-artifact
, thepurl
variable it's compared to has1.0.0-20220314.010735-1
. As there's no match in thecomponentRefs
, the dependency is never added and we only get a partial graph.The reason for the mismatch between version numbers themselves is because when converting a
org.apache.maven.artifact.DefaultArtifact
to aorg.cyclonedx.model.Component
we're using DefaultArtifact.getVersion() rather than DefaultArtifact.getBaseVersion(). When the purls were originally created and added to thecomponentRefs
they were created in such a way that they weren't using the timestamped version, and thus the confusion.Since the changes the fix this seem small I've prepared a PR that gets the two purls back inline with each other.