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

Resolves #951: DefaultArtifactVersion::getVersion can be null #952

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 @@ -75,6 +75,9 @@ public ArtifactVersions(Artifact artifact, List<ArtifactVersion> versions, Versi
this.versionComparator = versionComparator;
this.versions = new TreeSet<>(versionComparator);
this.versions.addAll(versions);
// DefaultArtifact objects are often built from raw model, without a version set
// (where the actual version is taken from parent or dependency/plugin management)
// this probably isn't the case in an actual Maven execution
if (artifact.getVersion() != null) {
setCurrentVersion(artifact.getVersion());
}
Expand Down Expand Up @@ -119,8 +122,12 @@ public boolean equals(Object o) {

ArtifactVersions that = (ArtifactVersions) o;

// can't just use Artifact::equals() since e.g. we can have an empty version here
return new EqualsBuilder()
.append(getArtifact(), that.getArtifact())
.append(getArtifact().getGroupId(), that.getGroupId())
.append(getArtifact().getArtifactId(), that.getArtifact().getArtifactId())
.append(getArtifact().getVersion(), that.getArtifact().getVersion())
.append(getArtifact().getScope(), that.getArtifact().getScope())
.append(getVersions(true), that.getVersions(true))
.append(getVersionComparator(), that.getVersionComparator())
.isEquals();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:dependency-updates-report
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>localhost</groupId>
<artifactId>dummy-artifact</artifactId>
<version>1.0.0-SNAPSHOT</version>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>localhost</groupId>
<artifactId>dummy-api</artifactId>
<version>[1.0,2.3]</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>localhost</groupId>
<artifactId>dummy-api</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>

</project>