提交 2acc9a83 编写于 作者: O olivier lamy

Merge branch 'master' of github.com:jenkinsci/jenkins

......@@ -61,6 +61,9 @@ Upcoming changes</a>
<li class=bug>
Fixed NPE in Subversion polling of Maven jobs.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-11592">issue 11592</a>)
<li class=bug>
Fixed ConcurrentModificationException in parallel Maven 3 builds.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-11256">issue 11256</a>)
<li class=rfe>
CLI jar now has the version number in the manifest as well as the "-version" option.
</ul>
......
......@@ -660,7 +660,7 @@ public class MavenBuild extends AbstractMavenBuild<MavenModule,MavenBuild> {
LOGGER.fine(getFullDisplayName()+" is building with mavenVersion " + mavenVersion + " from file " + mavenInformation.getVersionResourcePath());
boolean maven3orLater = new ComparableVersion(mavenVersion).compareTo( new ComparableVersion ("3.0") ) >= 0;
boolean maven3orLater = MavenUtil.maven3orLater(mavenVersion);
ProcessCache.MavenProcess process = MavenBuild.mavenProcessCache.get( launcher.getChannel(), listener, maven3orLater
? new Maven3ProcessFactory(
......
......@@ -22,6 +22,9 @@ package hudson.maven;
import java.io.Serializable;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.artifact.versioning.ComparableVersion;
/**
* @author Olivier Lamy
* @since 1.392
......@@ -39,4 +42,29 @@ public class MavenBuildInformation implements Serializable {
{
return mavenVersion;
}
/**
* @since 1.441
*/
public boolean isMaven3OrLater() {
return MavenUtil.maven3orLater(mavenVersion);
}
/**
* Returns if this maven version is at least 'version'.
* @param version the version to compare against
*
* @since 1.441
*/
public boolean isAtLeastMavenVersion(String version) {
if (StringUtils.isBlank(mavenVersion)) {
return false;
}
return new ComparableVersion(mavenVersion).compareTo(new ComparableVersion(version)) >= 0;
}
@Override
public String toString() {
return mavenVersion;
}
}
......@@ -701,8 +701,7 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
ProcessCache.MavenProcess process = null;
boolean maven3orLater = MavenUtil.maven3orLater( mavenVersion );
boolean maven3orLater = mavenBuildInformation.isMaven3OrLater();
if ( maven3orLater )
{
LOGGER.fine( "using maven 3 " + mavenVersion );
......@@ -1190,7 +1189,7 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
// FIXME handle 3.1 level when version will be here : no rush :-)
// or made something configurable tru the ui ?
ReactorReader reactorReader = null;
boolean maven3OrLater = new ComparableVersion (mavenVersion).compareTo( new ComparableVersion ("3.0") ) >= 0;
boolean maven3OrLater = MavenUtil.maven3orLater(mavenVersion);
if (maven3OrLater) {
mavenEmbedderRequest.setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0 );
} else {
......
......@@ -26,6 +26,7 @@ package hudson.maven.reporters;
import hudson.Extension;
import hudson.FilePath;
import hudson.maven.MavenBuild;
import hudson.maven.MavenBuildInformation;
import hudson.maven.MavenBuildProxy;
import hudson.maven.MavenBuildProxy.BuildCallable;
import hudson.maven.MavenModule;
......@@ -142,11 +143,9 @@ public class MavenFingerprinter extends MavenReporter {
File parentFile = parent.getFile();
if (parentFile == null) {
String mavenVersion = build.getMavenBuildInformation().getMavenVersion();
// Parent artifact contains no actual file, so we resolve against
// the local repository
ArtifactRepository localRepository = getLocalRepository(mavenVersion, parent, pom);
ArtifactRepository localRepository = getLocalRepository(build.getMavenBuildInformation(), parent, pom);
if (localRepository != null) {
Artifact parentArtifact = getArtifact(parent);
// Don't use ArtifactRepository.find(), for compatibility with Maven 2.x
......@@ -179,18 +178,18 @@ public class MavenFingerprinter extends MavenReporter {
return art;
}
private ArtifactRepository getLocalRepository(String mavenVersion, MavenProject parent, MavenProject pom) {
if (mavenVersion.startsWith("2.0") || mavenVersion.startsWith("2.1")) {
// Maven 2.0 has no corresponding mechanism
return null;
} else if (mavenVersion.startsWith("2.2")) {
// principally this should also work with Maven 2.1, but it's not tested, so err on the safe side
return getArtifactRepositoryMaven21(pom);
} else if (mavenVersion.startsWith("3.") || mavenVersion.startsWith("4.") /* who knows? ;) */) {
return parent.getProjectBuildingRequest()
.getLocalRepository();
private ArtifactRepository getLocalRepository(MavenBuildInformation mavenBuildInformation, MavenProject parent, MavenProject pom) {
if (mavenBuildInformation.isMaven3OrLater()) {
return parent.getProjectBuildingRequest().getLocalRepository();
} else if (mavenBuildInformation.isAtLeastMavenVersion("2.2")) {
// principally this should also work with Maven 2.1, but it's not tested, so err on the safe side
return getArtifactRepositoryMaven21(pom);
} else if (mavenBuildInformation.isAtLeastMavenVersion("2.0")) {
// Maven 2.0 has no corresponding mechanism
return null;
} else {
LOGGER.warning("Unknown Maven version: "+mavenVersion);
LOGGER.warning("Unknown Maven version: "+mavenBuildInformation.getMavenVersion());
return null;
}
}
......
......@@ -50,8 +50,6 @@ import java.util.ListIterator;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.artifact.versioning.ComparableVersion;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProject;
import org.apache.tools.ant.DirectoryScanner;
......@@ -65,7 +63,7 @@ import org.codehaus.plexus.util.xml.Xpp3Dom;
* @author Kohsuke Kawaguchi
*/
public class SurefireArchiver extends MavenReporter {
private TestResult result;
private transient TestResult result;
/**
* Store the filesets here as we want to track ignores between multiple runs of this class<br/>
......@@ -82,7 +80,7 @@ public class SurefireArchiver extends MavenReporter {
// note that because of the way Maven works, just updating system property at this point is too late
XmlPlexusConfiguration c = (XmlPlexusConfiguration) mojo.configuration.getChild("testFailureIgnore");
if(c!=null && c.getValue() != null && c.getValue().equals("${maven.test.failure.ignore}") && System.getProperty("maven.test.failure.ignore")==null) {
if (maven3orLater( build.getMavenBuildInformation().getMavenVersion() )) {
if (build.getMavenBuildInformation().isMaven3OrLater()) {
String fieldName = "testFailureIgnore";
if (mojo.mojoExecution.getConfiguration().getChild( fieldName ) != null) {
mojo.mojoExecution.getConfiguration().getChild( fieldName ).setValue( Boolean.TRUE.toString() );
......@@ -138,6 +136,9 @@ public class SurefireArchiver extends MavenReporter {
if(result==null) result = new TestResult();
result.parse(System.currentTimeMillis() - build.getMilliSecsSinceBuildStart(), reportsDir, reportFiles);
// final reference in order to serialize it:
final TestResult r = result;
int failCount = build.execute(new BuildCallable<Integer, IOException>() {
private static final long serialVersionUID = -1023888330720922136L;
......@@ -145,13 +146,13 @@ public class SurefireArchiver extends MavenReporter {
public Integer call(MavenBuild build) throws IOException, InterruptedException {
SurefireReport sr = build.getAction(SurefireReport.class);
if(sr==null)
build.getActions().add(new SurefireReport(build, result, listener));
build.getActions().add(new SurefireReport(build, r, listener));
else
sr.setResult(result,listener);
if(result.getFailCount()>0)
sr.setResult(r,listener);
if(r.getFailCount()>0)
build.setResult(Result.UNSTABLE);
build.registerAsProjectAction(new FactoryImpl());
return result.getFailCount();
return r.getFailCount();
}
});
......@@ -160,7 +161,7 @@ public class SurefireArchiver extends MavenReporter {
if(failCount>0 && error instanceof MojoFailureException) {
MavenBuilder.markAsSuccess = true;
}
// TODO currenlty error is empty : will be here with maven 3.0.2+
// TODO currently error is empty : will be here with maven 3.0.2+
if(failCount>0) {
Maven3Builder.markAsSuccess = true;
}
......@@ -307,14 +308,6 @@ public class SurefireArchiver extends MavenReporter {
return true;
}
public boolean maven3orLater(String mavenVersion) {
// null or empty so false !
if (StringUtils.isBlank( mavenVersion )) {
return false;
}
return new ComparableVersion (mavenVersion).compareTo( new ComparableVersion ("3.0") ) >= 0;
}
// I'm not sure if SurefireArchiver is actually ever (de-)serialized,
// but just to be sure, set fileSets here
protected Object readResolve() {
......
......@@ -58,7 +58,7 @@ public class NodeCanTakeTaskTest extends HudsonTestCase {
// First, attempt to run our project before adding the property
Future<FreeStyleBuild> build = project.scheduleBuild2(0);
assertBuildStatus(Result.SUCCESS, build.get(10, TimeUnit.SECONDS));
assertBuildStatus(Result.SUCCESS, build.get(20, TimeUnit.SECONDS));
// Add the build-blocker property and try again
slave.getNodeProperties().add(new RejectAllTasksProperty());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册