mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-16 05:22:22 +00:00
made the location of Maven local repositories pluggable
This commit is contained in:
1 parent
44c3253fd4
commit
5c0b36da02
15 files changed
+258
-19
No files matched your search
@@ -24,7 +24,7 @@
|
||||
*/
|
||||
package hudson.maven;
|
||||
|
||||
import static hudson.Util.fixEmpty;
|
||||
import static hudson.Util.*;
|
||||
import static hudson.model.ItemGroupMixIn.loadChildren;
|
||||
import hudson.CopyOnWrite;
|
||||
import hudson.EnvVars;
|
||||
@@ -34,6 +34,9 @@ import hudson.FilePath;
|
||||
import hudson.Functions;
|
||||
import hudson.Indenter;
|
||||
import hudson.Util;
|
||||
import hudson.maven.local_repo.DefaultLocalRepositoryLocator;
|
||||
import hudson.maven.local_repo.LocalRepositoryLocator;
|
||||
import hudson.maven.local_repo.PerJobLocalRepositoryLocator;
|
||||
import hudson.maven.settings.SettingsProviderUtils;
|
||||
import hudson.model.AbstractProject;
|
||||
import hudson.model.Action;
|
||||
@@ -183,8 +186,20 @@ public class MavenModuleSet extends AbstractMavenProject<MavenModuleSet,MavenMod
|
||||
* from multiple Maven process, so this helps there too.
|
||||
*
|
||||
* @since 1.223
|
||||
* @deprecated as of 1.448
|
||||
* Subsumed by {@link #localRepository}. false maps to {@link DefaultLocalRepositoryLocator},
|
||||
* and true maps to {@link PerJobLocalRepositoryLocator}
|
||||
*/
|
||||
private boolean usePrivateRepository = false;
|
||||
private transient Boolean usePrivateRepository;
|
||||
|
||||
/**
|
||||
* Encapsulates where to run the local repository.
|
||||
*
|
||||
* If null, inherited from the global configuration.
|
||||
*
|
||||
* @since 1.448
|
||||
*/
|
||||
private LocalRepositoryLocator localRepository = null;
|
||||
|
||||
/**
|
||||
* If true, the build will send a failure e-mail for each failing maven module.
|
||||
@@ -440,8 +455,12 @@ public class MavenModuleSet extends AbstractMavenProject<MavenModuleSet,MavenMod
|
||||
return aggregatorStyleBuild;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated as of 1.448
|
||||
* Use {@link #getLocalRepository()}
|
||||
*/
|
||||
public boolean usesPrivateRepository() {
|
||||
return usePrivateRepository;
|
||||
return !(getLocalRepository() instanceof DefaultLocalRepositoryLocator);
|
||||
}
|
||||
|
||||
public boolean isPerModuleEmail() {
|
||||
@@ -468,8 +487,31 @@ public class MavenModuleSet extends AbstractMavenProject<MavenModuleSet,MavenMod
|
||||
this.aggregatorStyleBuild = aggregatorStyleBuild;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated as of 1.448.
|
||||
* Use {@link #setLocalRepository(LocalRepositoryLocator)} instead
|
||||
*/
|
||||
public void setUsePrivateRepository(boolean usePrivateRepository) {
|
||||
this.usePrivateRepository = usePrivateRepository;
|
||||
setLocalRepository(usePrivateRepository?new PerJobLocalRepositoryLocator() : new DefaultLocalRepositoryLocator());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* never null
|
||||
*/
|
||||
public LocalRepositoryLocator getLocalRepository() {
|
||||
return localRepository!=null ? localRepository : getDescriptor().getLocalRepository();
|
||||
}
|
||||
|
||||
/**
|
||||
* Undefaulted locally configured value with taking inheritance from the global configuration into account.
|
||||
*/
|
||||
public LocalRepositoryLocator getExplicitLocalRepository() {
|
||||
return localRepository;
|
||||
}
|
||||
|
||||
public void setLocalRepository(LocalRepositoryLocator localRepository) {
|
||||
this.localRepository = localRepository;
|
||||
}
|
||||
|
||||
public void setIgnoreUpstremChanges(boolean ignoreUpstremChanges) {
|
||||
@@ -681,6 +723,11 @@ public class MavenModuleSet extends AbstractMavenProject<MavenModuleSet,MavenMod
|
||||
perModuleEmail = Boolean.TRUE;
|
||||
}
|
||||
|
||||
if (Boolean.TRUE.equals(usePrivateRepository)) {
|
||||
this.localRepository = new PerJobLocalRepositoryLocator();
|
||||
usePrivateRepository = null;
|
||||
}
|
||||
|
||||
updateTransientActions();
|
||||
}
|
||||
|
||||
@@ -1002,7 +1049,10 @@ public class MavenModuleSet extends AbstractMavenProject<MavenModuleSet,MavenMod
|
||||
mavenOpts = Util.fixEmpty(req.getParameter("mavenOpts").trim());
|
||||
mavenName = req.getParameter("maven_version");
|
||||
aggregatorStyleBuild = !req.hasParameter("maven.perModuleBuild");
|
||||
usePrivateRepository = req.hasParameter("maven.usePrivateRepository");
|
||||
if (json.optBoolean("usePrivateRepository"))
|
||||
localRepository = req.bindJSON(LocalRepositoryLocator.class,json.getJSONObject("explicitLocalRepository"));
|
||||
else
|
||||
localRepository = null;
|
||||
perModuleEmail = req.hasParameter("maven.perModuleEmail");
|
||||
ignoreUpstremChanges = !json.has("triggerByDependency");
|
||||
runHeadless = req.hasParameter("maven.runHeadless");
|
||||
@@ -1085,6 +1135,11 @@ public class MavenModuleSet extends AbstractMavenProject<MavenModuleSet,MavenMod
|
||||
*/
|
||||
private Map<String, Integer> mavenValidationLevels = new LinkedHashMap<String, Integer>();
|
||||
|
||||
/**
|
||||
* @since 1.448
|
||||
*/
|
||||
private LocalRepositoryLocator localRepository = new DefaultLocalRepositoryLocator();
|
||||
|
||||
public DescriptorImpl() {
|
||||
super();
|
||||
load();
|
||||
@@ -1105,6 +1160,18 @@ public class MavenModuleSet extends AbstractMavenProject<MavenModuleSet,MavenMod
|
||||
save();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return never null.
|
||||
*/
|
||||
public LocalRepositoryLocator getLocalRepository() {
|
||||
return localRepository!=null ? localRepository : new DefaultLocalRepositoryLocator();
|
||||
}
|
||||
|
||||
public void setLocalRepository(LocalRepositoryLocator localRepository) {
|
||||
this.localRepository = localRepository;
|
||||
save();
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return Messages.MavenModuleSet_DiplayName();
|
||||
}
|
||||
@@ -1128,6 +1195,7 @@ public class MavenModuleSet extends AbstractMavenProject<MavenModuleSet,MavenMod
|
||||
@Override
|
||||
public boolean configure( StaplerRequest req, JSONObject o ) {
|
||||
globalMavenOpts = Util.fixEmptyAndTrim(o.getString("globalMavenOpts"));
|
||||
localRepository = req.bindJSON(LocalRepositoryLocator.class,o.getJSONObject("localRepository"));
|
||||
save();
|
||||
|
||||
return true;
|
||||
|
||||
Reference in new issue
Block a user