Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 120e5ee
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .project
Expand Up @@ -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 changes: 2 additions & 1 deletion pom.xml
Expand Up @@ -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>
Expand All @@ -24,6 +24,7 @@
<dependency>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>maven-plugin</artifactId>
<version>2.12</version>
<optional>true</optional>
</dependency>
<dependency>
Expand Down
Expand Up @@ -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) {
Expand Down

0 comments on commit 120e5ee

Please sign in to comment.