Skip to content

Commit

Permalink
[FIXED JENKINS-8663] Flag -U is not used during the parsing step of a
Browse files Browse the repository at this point in the history
Maven Job

If the -U flag is specified in the goals/options of the build step of a
Maven job, it should be used as well in the parsing step.

Originally-Committed-As: 1421ca15d5a36706214476e613eeab789b9066df
  • Loading branch information
Vlatombe committed Apr 14, 2012
1 parent 298a4df commit 54e770f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/main/java/hudson/maven/MavenEmbedderRequest.java
Expand Up @@ -83,6 +83,11 @@ public class MavenEmbedderRequest
* @since 1.426
*/
private File globalSettings;

/**
* @since 1.461
*/
private boolean updateSnapshots;

/**
* @param listener
Expand Down Expand Up @@ -224,4 +229,13 @@ public MavenEmbedderRequest setGlobalSettings( File globalSettings ) {
this.globalSettings = globalSettings;
return this;
}

public MavenEmbedderRequest setUpdateSnapshots(boolean updateSnapshots) {
this.updateSnapshots = updateSnapshots;
return this;
}

public boolean isUpdateSnapshots() {
return updateSnapshots;
}
}
8 changes: 8 additions & 0 deletions src/main/java/hudson/maven/MavenModuleSetBuild.java
Expand Up @@ -1069,6 +1069,8 @@ private static final class PomParser implements FileCallable<List<PomInfo>> {

private int mavenValidationLevel = -1;

private boolean updateSnapshots = false;

String rootPOMRelPrefix;

public PomParser(BuildListener listener, MavenInstallation mavenHome, String mavenVersion, EnvVars envVars, MavenModuleSetBuild build) {
Expand All @@ -1079,6 +1081,7 @@ public PomParser(BuildListener listener, MavenInstallation mavenHome, String mav
this.rootPOM = project.getRootPOM();
this.profiles = project.getProfiles();
this.properties = project.getMavenProperties();
this.updateSnapshots = isUpdateSnapshots(project.getGoals());
ParametersDefinitionProperty parametersDefinitionProperty = project.getProperty( ParametersDefinitionProperty.class );
if (parametersDefinitionProperty != null && parametersDefinitionProperty.getParameterDefinitions() != null) {
for (ParameterDefinition parameterDefinition : parametersDefinitionProperty.getParameterDefinitions()) {
Expand Down Expand Up @@ -1121,6 +1124,10 @@ public PomParser(BuildListener listener, MavenInstallation mavenHome, String mav
}


private boolean isUpdateSnapshots(String goals) {
return StringUtils.contains(goals, "-U") || StringUtils.contains(goals, "--update-snapshots");
}

public List<PomInfo> invoke(File ws, VirtualChannel channel) throws IOException {
File pom;

Expand Down Expand Up @@ -1186,6 +1193,7 @@ public List<PomInfo> invoke(File ws, VirtualChannel channel) throws IOException
profiles, properties,
privateRepository, settingsLoc );
mavenEmbedderRequest.setTransferListener( new SimpleTransferListener(listener) );
mavenEmbedderRequest.setUpdateSnapshots( this.updateSnapshots );

mavenEmbedderRequest.setProcessPlugins( this.processPlugins );
mavenEmbedderRequest.setResolveDependencies( this.resolveDependencies );
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/hudson/maven/MavenUtil.java
Expand Up @@ -176,6 +176,8 @@ public static MavenEmbedder createEmbedder(MavenEmbedderRequest mavenEmbedderReq
mavenRequest.setWorkspaceReader( mavenEmbedderRequest.getWorkspaceReader() );
}

mavenRequest.setUpdateSnapshots(mavenEmbedderRequest.isUpdateSnapshots());

// TODO olamy check this sould be userProperties
mavenRequest.setSystemProperties(mavenEmbedderRequest.getSystemProperties());

Expand Down

0 comments on commit 54e770f

Please sign in to comment.