Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-17775] If MavenProject.getParent throws ISE during fingerpri…
…nting, report it but at least proceed.

Proper fix is to ensure that the model resolution uses the same environment as the actual build,
or is otherwise more lenient about finding the parent (e.g. enables plugin resolution).
Originally-Committed-As: d477296ffd3114f9f8416981f82e49cace605600
  • Loading branch information
jglick committed Apr 29, 2013
1 parent e218775 commit b4ae662
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/main/java/hudson/maven/reporters/MavenFingerprinter.java
Expand Up @@ -107,7 +107,7 @@ public boolean postExecute(MavenBuildProxy build, MavenProject pom, MojoInfo moj
*/
public boolean postBuild(MavenBuildProxy build, MavenProject pom, BuildListener listener) throws InterruptedException, IOException {

recordParents(build, pom);
recordParents(build, pom, listener);

build.executeAsync(new BuildCallable<Void,IOException>() {
private static final long serialVersionUID = -1360161848504044869L;
Expand Down Expand Up @@ -137,8 +137,8 @@ public Void call(MavenBuild build) throws IOException, InterruptedException {
return true;
}

private void recordParents(MavenBuildProxy build, MavenProject pom) throws IOException, InterruptedException {
MavenProject parent = pom.getParent();
private void recordParents(MavenBuildProxy build, MavenProject pom, BuildListener listener) throws IOException, InterruptedException {
MavenProject parent = getParent(pom, listener);
while (parent != null) {
File parentFile = parent.getFile();

Expand All @@ -163,10 +163,20 @@ private void recordParents(MavenBuildProxy build, MavenProject pom) throws IOExc
record(parent.getGroupId() + ":" + parent.getArtifactId(),
parentFile, used);
}
parent = parent.getParent();
parent = getParent(parent, listener);
}
}

// XXX consider calling also from PomInfo which makes a naked call to getParent
private static MavenProject getParent(MavenProject pom, BuildListener listener) {
try {
return pom.getParent();
} catch (IllegalStateException x) { // MNG-5075
x.printStackTrace(listener.error("Warning: failed to resolve parent of " + pom.getId()));
return null;
}
}

private Artifact getArtifact(MavenProject parent) {
Artifact art = parent.getArtifact();
if (art == null) {
Expand Down

0 comments on commit b4ae662

Please sign in to comment.