diff --git a/changelog.html b/changelog.html index 47fc9db68a59162910461f6354df9017c03c3d85..4345ab4beda1433743a8470353f2e2f3dba71115 100644 --- a/changelog.html +++ b/changelog.html @@ -55,7 +55,8 @@ Upcoming changes diff --git a/maven-plugin/src/main/java/hudson/maven/reporters/SurefireArchiver.java b/maven-plugin/src/main/java/hudson/maven/reporters/SurefireArchiver.java index 987b311749f3461a3d4adb0acf9934b1582fc0e7..b48602081767882393d7151c4c0aaa6776b50c53 100644 --- a/maven-plugin/src/main/java/hudson/maven/reporters/SurefireArchiver.java +++ b/maven-plugin/src/main/java/hudson/maven/reporters/SurefireArchiver.java @@ -74,10 +74,8 @@ public class SurefireArchiver extends MavenReporter { private transient ConcurrentMap fileSets = new ConcurrentHashMap(); public boolean preExecute(MavenBuildProxy build, MavenProject pom, MojoInfo mojo, BuildListener listener) throws InterruptedException, IOException { - if (isSurefireTest(mojo)) { - if ((!mojo.is("org.apache.maven.plugins", "maven-failsafe-plugin", "integration-test")) - && (!mojo.is("eviware", "maven-soapui-plugin", "test")) - && (!mojo.is("eviware", "maven-soapui-pro-plugin", "test"))) { + if (isTestMojo(mojo)) { + if (!isSoapUiMojo(mojo)) { // tell surefire:test to keep going even if there was a failure, // so that we can record this as yellow. // note that because of the way Maven works, just updating system property at this point is too late @@ -103,13 +101,12 @@ public class SurefireArchiver extends MavenReporter { } public boolean postExecute(MavenBuildProxy build, MavenProject pom, MojoInfo mojo, final BuildListener listener, Throwable error) throws InterruptedException, IOException { - if (!isSurefireTest(mojo)) return true; + if (!isTestMojo(mojo)) return true; listener.getLogger().println(Messages.SurefireArchiver_Recording()); File reportsDir; - if (mojo.is("org.apache.maven.plugins", "maven-surefire-plugin", "test") || - mojo.is("org.apache.maven.plugins", "maven-failsafe-plugin", "integration-test")) { + if (isSurefireOrFailsafeMojo(mojo)) { try { reportsDir = mojo.getConfigurationValue("reportsDirectory", File.class); } catch (ComponentConfigurationException e) { @@ -233,23 +230,20 @@ public class SurefireArchiver extends MavenReporter { } } - private boolean isSurefireTest(MojoInfo mojo) { + private boolean isTestMojo(MojoInfo mojo) { if ((!mojo.is("com.sun.maven", "maven-junit-plugin", "test")) && (!mojo.is("org.sonatype.flexmojos", "flexmojos-maven-plugin", "test-run")) && (!mojo.is("org.eclipse.tycho", "tycho-surefire-plugin", "test")) && (!mojo.is("org.sonatype.tycho", "maven-osgi-test-plugin", "test")) && (!mojo.is("org.codehaus.mojo", "gwt-maven-plugin", "test")) - && (!mojo.is("com.jayway.maven.plugins.android.generation2", "maven-android-plugin", "internal-integration-test")) - && (!mojo.is("com.jayway.maven.plugins.android.generation2", "android-maven-plugin", "internal-integration-test")) - && (!mojo.is("org.apache.maven.plugins", "maven-surefire-plugin", "test")) - && (!mojo.is("org.apache.maven.plugins", "maven-failsafe-plugin", "integration-test")) - && (!mojo.is("eviware", "maven-soapui-plugin", "test")) - && (!mojo.is("eviware", "maven-soapui-pro-plugin", "test"))) + && (!isAndroidMojo(mojo)) + && (!isSurefireOrFailsafeMojo(mojo)) + && (!isSoapUiMojo(mojo))) return false; try { - if (mojo.is("org.apache.maven.plugins", "maven-surefire-plugin", "test")) { - Boolean skip = mojo.getConfigurationValue("skip", Boolean.class); + if (isSurefireOrFailsafeMojo(mojo)) { + Boolean skip = mojo.getConfigurationValue("skip", Boolean.class); if (((skip != null) && (skip))) { return false; } @@ -292,12 +286,7 @@ public class SurefireArchiver extends MavenReporter { if (((skipTests != null) && (skipTests))) { return false; } - } else if (mojo.is("com.jayway.maven.plugins.android.generation2", "android-maven-plugin", "internal-integration-test")) { - Boolean skipTests = mojo.getConfigurationValue("skipTests", Boolean.class); - if (((skipTests != null) && (skipTests))) { - return false; - } - } else if (mojo.is("com.jayway.maven.plugins.android.generation2", "maven-android-plugin", "internal-integration-test")) { + } else if (isAndroidMojo(mojo)) { if (mojo.pluginName.version.compareTo("3.0.0-alpha-6") < 0) { // Earlier versions do not support tests return false; @@ -310,12 +299,7 @@ public class SurefireArchiver extends MavenReporter { } else if (mojo.is("org.codehaus.mojo", "gwt-maven-plugin", "test") && mojo.pluginName.version.compareTo("1.2") < 0) { // gwt-maven-plugin < 1.2 does not implement required Surefire option return false; - } else if (mojo.is("eviware", "maven-soapui-plugin", "test")) { - Boolean skipTests = mojo.getConfigurationValue("skip", Boolean.class); - if (((skipTests != null) && (skipTests))) { - return false; - } - } else if (mojo.is("eviware", "maven-soapui-pro-plugin", "test")) { + } else if (isSoapUiMojo(mojo)) { Boolean skipTests = mojo.getConfigurationValue("skip", Boolean.class); if (((skipTests != null) && (skipTests))) { return false; @@ -327,6 +311,22 @@ public class SurefireArchiver extends MavenReporter { return true; } + + private boolean isAndroidMojo(MojoInfo mojo) { + return mojo.is("com.jayway.maven.plugins.android.generation2", "maven-android-plugin", "internal-integration-test") + || mojo.is("com.jayway.maven.plugins.android.generation2", "android-maven-plugin", "internal-integration-test"); + } + + private boolean isSurefireOrFailsafeMojo(MojoInfo mojo) { + return mojo.is("org.apache.maven.plugins", "maven-surefire-plugin", "test") + || mojo.is("org.apache.maven.plugins", "maven-failsafe-plugin", "integration-test") + || mojo.is("org.apache.maven.plugins", "maven-failsafe-plugin", "verify"); + } + + private boolean isSoapUiMojo(MojoInfo mojo) { + return mojo.is("eviware", "maven-soapui-plugin", "test") + || mojo.is("eviware", "maven-soapui-pro-plugin", "test"); + } // I'm not sure if SurefireArchiver is actually ever (de-)serialized, // but just to be sure, set fileSets here