提交 342965dc 编写于 作者: C Christoph Kutzinski

resolved a TODO

上级 1e80d2ec
......@@ -526,7 +526,7 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal
if (mavenReporters != null) {
for (MavenReporter mavenReporter : mavenReporters) {
try {
mavenReporter.postExecute( mavenBuildProxy2, mavenProject, mojoInfo, maven3Builder.listener, null);
mavenReporter.postExecute( mavenBuildProxy2, mavenProject, mojoInfo, maven3Builder.listener, getExecutionException(event));
} catch ( InterruptedException e ) {
e.printStackTrace();
}
......@@ -587,14 +587,7 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal
if (mavenReporters != null) {
for (MavenReporter mavenReporter : mavenReporters) {
try {
// http://issues.jenkins-ci.org/browse/HUDSON-8493
// with maven 3.0.2 see http://jira.codehaus.org/browse/MNG-4922
// catch NoSuchMethodError if folks not using 3.0.2+
try {
mavenReporter.postExecute( mavenBuildProxy2, mavenProject, mojoInfo, maven3Builder.listener, event.getException() );
} catch (NoSuchMethodError e) {
mavenReporter.postExecute( mavenBuildProxy2, mavenProject, mojoInfo, maven3Builder.listener, null );
}
mavenReporter.postExecute( mavenBuildProxy2, mavenProject, mojoInfo, maven3Builder.listener, getExecutionException(event) );
} catch ( InterruptedException e ) {
e.printStackTrace();
} catch ( IOException e ) {
......@@ -602,7 +595,18 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal
}
}
}
}
}
private Exception getExecutionException(ExecutionEvent event) {
// http://issues.jenkins-ci.org/browse/JENKINS-8493
// with maven 3.0.2 see http://jira.codehaus.org/browse/MNG-4922
// catch NoSuchMethodError if folks not using 3.0.2+
try {
return event.getException();
} catch (NoSuchMethodError e) {
return null;
}
}
/**
* @see org.apache.maven.execution.ExecutionListener#forkStarted(org.apache.maven.execution.ExecutionEvent)
......
......@@ -27,6 +27,7 @@ import hudson.Extension;
import hudson.Util;
import hudson.maven.Maven3Builder;
import hudson.maven.MavenBuild;
import hudson.maven.MavenBuildInformation;
import hudson.maven.MavenBuildProxy;
import hudson.maven.MavenBuildProxy.BuildCallable;
import hudson.maven.MavenBuilder;
......@@ -158,12 +159,8 @@ public class SurefireArchiver extends MavenReporter {
// if surefire plugin is going to kill maven because of a test failure,
// intercept that (or otherwise build will be marked as failure)
if(failCount>0 && error instanceof MojoFailureException) {
MavenBuilder.markAsSuccess = true;
}
// TODO currently error is empty : will be here with maven 3.0.2+
if(failCount>0) {
Maven3Builder.markAsSuccess = true;
markBuildAsSuccess(error,build.getMavenBuildInformation());
}
}
}
......@@ -171,6 +168,15 @@ public class SurefireArchiver extends MavenReporter {
return true;
}
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification="It's okay to write to static fields here, as each Maven build is started in its own VM")
private void markBuildAsSuccess(Throwable mojoError, MavenBuildInformation buildInfo) {
if(mojoError == null // in the success case we don't get any exception in Maven 3.0.2+; Maven < 3.0.2 returns no exception anyway
|| mojoError instanceof MojoFailureException) {
MavenBuilder.markAsSuccess = true;
Maven3Builder.markAsSuccess = true;
}
}
/**
* Returns the appropriate FileSet for the selected baseDir
* @param baseDir
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册