Skip to content
Permalink
Browse files

[JENKINS-8383] Fixed parent fingerprinting for relativePath style

parents
  • Loading branch information
Stephan Pauxberger
Stephan Pauxberger committed Sep 3, 2011
1 parent 5d202a2 commit 6f389236eaaf799a07b53ffd7f1aed996bdb95c3
Showing with 23 additions and 9 deletions.
  1. +23 −9 maven-plugin/src/main/java/hudson/maven/reporters/MavenFingerprinter.java
@@ -81,18 +81,11 @@ public boolean preBuild(MavenBuildProxy build, MavenProject pom, BuildListener l
* Mojos perform different dependency resolution, so we need to check this for each mojo.
*/
public boolean postExecute(MavenBuildProxy build, MavenProject pom, MojoInfo mojo, BuildListener listener, Throwable error) throws InterruptedException, IOException {
MavenProject parent = pom.getParent();
while (parent != null) {
// Parent Artifact contains no acual file, so we resolve against the local repository
Artifact parentArtifact = parent.getProjectBuildingRequest().getLocalRepository().find(parent.getArtifact());
record(parentArtifact, used);
parent = parent.getParent();
}

recordParents(pom);
record(pom.getArtifacts(),used);
record(pom.getArtifact(),produced);
record(pom.getAttachedArtifacts(),produced);
record(pom.getGroupId(),pom.getFile(),produced);
record(pom.getGroupId() + ":" + pom.getArtifactId(),pom.getFile(),produced);

return true;
}
@@ -127,6 +120,27 @@ public Void call(MavenBuild build) throws IOException, InterruptedException {
return true;
}

private void recordParents(MavenProject pom) throws IOException, InterruptedException {
MavenProject parent = pom.getParent();
while (parent != null) {
File parentFile = parent.getFile();
if (parentFile == null) {
// Parent Artifact contains no acual file, so we resolve against
// the local repository
parentFile = parent.getProjectBuildingRequest()
.getLocalRepository().find(parent.getArtifact())
.getFile();
}
// we need to include the artifact Id for poms as well, otherwise a
// project with the same groupId would override its parent's
// fingerprint
record(parent.getGroupId() + ":" + parent.getArtifactId(),
parentFile, used);
parent = parent.getParent();
}
}


private void record(Collection<Artifact> artifacts, Map<String,String> record) throws IOException, InterruptedException {
for (Artifact a : artifacts)
record(a,record);

0 comments on commit 6f38923

Please sign in to comment.
You can’t perform that action at this time.