Skip to content
Permalink
Browse files

Copy all existing maven config values to newly created builder

[JENKINS-29093] The Maven top-level target slicer was trying to be
careful about the maven installation version used, but this ends up
breaking other maven settings when the default maven installation is used.

The fix is to copy the config values if we have an old maven builder,
regardless of whether it has a maven installation version set.
  • Loading branch information
mdonohue committed Sep 18, 2015
1 parent 4887f9f commit 120e5ee47bfdb1551755fbcd831a979159cc9071
Showing with 20 additions and 17 deletions.
  1. +1 −1 .project
  2. +2 −1 pom.xml
  3. +17 −15 src/main/java/configurationslicing/executeshell/MavenTargetsSlicer.java
@@ -9,6 +9,6 @@
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.jdt.groovy.core.groovyNature</nature>
<nature>org.eclipse.jdt.groovy.core.groovyNature</nature>
</natures>
</projectDescription>
@@ -3,7 +3,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.509.3</version>
<version>1.580.1</version>
</parent>
<artifactId>configurationslicing</artifactId>
<packaging>hpi</packaging>
@@ -24,6 +24,7 @@
<dependency>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>maven-plugin</artifactId>
<version>2.12</version>
<optional>true</optional>
</dependency>
<dependency>
@@ -32,21 +32,23 @@ public String getUrl() {
}
@Override
public Maven createBuilder(String command, List<Maven> existingBuilders, Maven oldBuilder) {
if (oldBuilder != null && oldBuilder.getMaven() != null) {
String mavenName = oldBuilder.getMaven().getName();
return new Maven(command, mavenName, oldBuilder.pom, oldBuilder.properties, oldBuilder.jvmOptions, oldBuilder.usePrivateRepository);
} else {
// if the job already has another maven command, use the right version of maven
String mavenName = DEFAULT_MAVEN;
for (Maven maven: existingBuilders) {
MavenInstallation install = maven.getMaven();
if (install != null) {
mavenName = install.getName();
break;
}
}
return new Maven(command, mavenName);
}
if (oldBuilder != null) {
MavenInstallation mavenInstall = oldBuilder.getMaven();
String mavenName = mavenInstall == null ? null : mavenInstall.getName();
return new Maven(command, mavenName, oldBuilder.pom, oldBuilder.properties, oldBuilder.jvmOptions,
oldBuilder.usePrivateRepository, oldBuilder.getSettings(), oldBuilder.getGlobalSettings());
} else {
// if the job already has another maven command, use the right version of maven
String mavenName = DEFAULT_MAVEN;
for (Maven maven: existingBuilders) {
MavenInstallation install = maven.getMaven();
if (install != null) {
mavenName = install.getName();
break;
}
}
return new Maven(command, mavenName);
}
}
@Override
public Maven[] createBuilderArray(int len) {

0 comments on commit 120e5ee

Please sign in to comment.