@@ -6,6 +6,8 @@ public class Pom implements Comparable<Pom> {
66 private final ArtifactId artifactId ;
77 private final VersionNumber version ;
88 private final String relativePath ;
9+ private final ResolvedUrl resolved ;
10+ private final RepositoryId repositoryId ;
911 private final String checksumAlgorithm ;
1012 private final String checksum ;
1113 private final Pom parent ;
@@ -15,13 +17,17 @@ public Pom(
1517 ArtifactId artifactId ,
1618 VersionNumber version ,
1719 String relativePath ,
20+ ResolvedUrl resolved ,
21+ RepositoryId repositoryId ,
1822 String checksumAlgorithm ,
1923 String checksum ,
2024 Pom parent ) {
2125 this .groupId = groupId ;
2226 this .artifactId = artifactId ;
2327 this .version = version ;
2428 this .relativePath = relativePath ;
29+ this .resolved = resolved ;
30+ this .repositoryId = repositoryId ;
2531 this .checksumAlgorithm = checksumAlgorithm ;
2632 this .checksum = checksum ;
2733 this .parent = parent ;
@@ -43,6 +49,14 @@ public String getRelativePath() {
4349 return relativePath ;
4450 }
4551
52+ public ResolvedUrl getResolved () {
53+ return resolved ;
54+ }
55+
56+ public RepositoryId getRepositoryId () {
57+ return repositoryId ;
58+ }
59+
4660 public String getChecksumAlgorithm () {
4761 return checksumAlgorithm ;
4862 }
@@ -76,6 +90,20 @@ public int compareTo(Pom o) {
7690 return pathCmp .compareTo (oPathCmp );
7791 }
7892
93+ ResolvedUrl resolvedCmp = this .resolved == null ? ResolvedUrl .Unresolved () : this .resolved ;
94+ ResolvedUrl oResolvedCmp = o .resolved == null ? ResolvedUrl .Unresolved () : o .resolved ;
95+
96+ if (resolvedCmp .compareTo (oResolvedCmp ) != 0 ) {
97+ return resolvedCmp .compareTo (oResolvedCmp );
98+ }
99+
100+ RepositoryId repoIdCmp = this .repositoryId == null ? RepositoryId .None () : this .repositoryId ;
101+ RepositoryId oRepoIdCmp = o .repositoryId == null ? RepositoryId .None () : o .repositoryId ;
102+
103+ if (repoIdCmp .compareTo (oRepoIdCmp ) != 0 ) {
104+ return repoIdCmp .compareTo (oRepoIdCmp );
105+ }
106+
79107 if (this .checksumAlgorithm .compareTo (o .checksumAlgorithm ) != 0 ) {
80108 return this .checksumAlgorithm .compareTo (o .checksumAlgorithm );
81109 }
@@ -108,16 +136,27 @@ public boolean equals(Object obj) {
108136 return false ;
109137 }
110138 Pom other = (Pom ) obj ;
139+ // Poms are either defined by their relative path or resolved from a repository by their GAV.
140+ // We cannot know where poms defined by their relative path will be hosted and thus their
141+ // resolved fields are null.
111142 String pathCmp = this .relativePath == null ? "" : this .relativePath ;
112143 String otherPathCmp = other .relativePath == null ? "" : other .relativePath ;
113144
145+ ResolvedUrl resolvedCmp = this .resolved == null ? ResolvedUrl .Unresolved () : this .resolved ;
146+ ResolvedUrl otherResolvedCmp = other .resolved == null ? ResolvedUrl .Unresolved () : other .resolved ;
147+
148+ RepositoryId repoIdCmp = this .repositoryId == null ? RepositoryId .None () : this .repositoryId ;
149+ RepositoryId otherRepoIdCmp = other .repositoryId == null ? RepositoryId .None () : other .repositoryId ;
150+
114151 boolean parentEqual = (this .parent == null && other .parent == null )
115152 || (this .parent != null && other .parent != null && this .parent .equals (other .parent ));
116153
117154 return this .groupId .equals (other .groupId )
118155 && this .artifactId .equals (other .artifactId )
119156 && this .version .equals (other .version )
120157 && pathCmp .equals (otherPathCmp )
158+ && resolvedCmp .equals (otherResolvedCmp )
159+ && repoIdCmp .equals (otherRepoIdCmp )
121160 && this .checksumAlgorithm .equals (other .checksumAlgorithm )
122161 && this .checksum .equals (other .checksum )
123162 && parentEqual ;
0 commit comments