Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #442 from Vlatombe/JENKINS-8663
[FIXED JENKINS-8663] Flag -U is not used during the parsing step of a Maven Job
good catch !
  • Loading branch information
olamy committed Apr 14, 2012
2 parents 0f08dc0 + 1421ca1 commit f0130bf
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions changelog.html
Expand Up @@ -55,6 +55,9 @@
<!-- Record your changes in the trunk here. -->
<div id="trunk" style="display:none"><!--=TRUNK-BEGIN=-->
<ul class=image>
<li class=bug>
Flag -U is not used during the parsing step of a Maven Job
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-8663">issue 8663</a>)
<li class=bug>
Custom workspace validation not working.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-13404">issue 13404</a>)
Expand Down
14 changes: 14 additions & 0 deletions maven-plugin/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;
}
}
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 maven-plugin/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 f0130bf

Please sign in to comment.