mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-16 05:22:22 +00:00
add GlobalSettingsProvider as new EP
This commit is contained in:
1 parent
e6f04215e4
commit
cdae926106
12 files changed
+241
-2
No files matched your search
@@ -0,0 +1,34 @@
|
||||
package hudson.mvn;
|
||||
|
||||
import hudson.Extension;
|
||||
import hudson.model.AbstractBuild;
|
||||
import hudson.util.ArgumentListBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.kohsuke.stapler.DataBoundConstructor;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:nicolas.deloof@gmail.com">Nicolas De Loof</a>
|
||||
* @author Dominik Bartholdi (imod)
|
||||
*/
|
||||
public class DefaultGlobalSettingsProvider extends GlobalSettingsProvider {
|
||||
|
||||
@DataBoundConstructor
|
||||
public DefaultGlobalSettingsProvider() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(ArgumentListBuilder margs, AbstractBuild project) throws IOException, InterruptedException {
|
||||
return;
|
||||
}
|
||||
|
||||
@Extension(ordinal = 99)
|
||||
public static class DescriptorImpl extends GlobalSettingsProviderDescriptor {
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "Use default maven global settings";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package hudson.mvn;
|
||||
|
||||
import hudson.Extension;
|
||||
import hudson.FilePath;
|
||||
import hudson.model.AbstractBuild;
|
||||
import hudson.util.ArgumentListBuilder;
|
||||
import hudson.util.IOUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.kohsuke.stapler.DataBoundConstructor;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:nicolas.deloof@gmail.com">Nicolas De Loof</a>
|
||||
* @author Dominik Bartholdi (imod)
|
||||
*/
|
||||
public class FilePathGlobalSettingsProvider extends GlobalSettingsProvider {
|
||||
|
||||
private final String path;
|
||||
|
||||
@DataBoundConstructor
|
||||
public FilePathGlobalSettingsProvider(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(ArgumentListBuilder margs, AbstractBuild project) throws IOException, InterruptedException {
|
||||
if (StringUtils.isEmpty(path)) return;
|
||||
if (IOUtils.isAbsolute(path)) {
|
||||
margs.add("-gs").add(path);
|
||||
} else {
|
||||
FilePath mrSettings = project.getModuleRoot().child(path);
|
||||
FilePath wsSettings = project.getWorkspace().child(path);
|
||||
if (!wsSettings.exists() && mrSettings.exists())
|
||||
wsSettings = mrSettings;
|
||||
|
||||
margs.add("-gs").add(wsSettings.getRemote());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Extension(ordinal = 10)
|
||||
public static class DescriptorImpl extends SettingsProviderDescriptor {
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "File in project workspace";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package hudson.mvn;
|
||||
|
||||
import hudson.ExtensionPoint;
|
||||
import hudson.model.AbstractBuild;
|
||||
import hudson.model.AbstractDescribableImpl;
|
||||
import hudson.model.Descriptor;
|
||||
import hudson.util.ArgumentListBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:nicolas.deloof@gmail.com">Nicolas De Loof</a>
|
||||
* @author Dominik Bartholdi (imod)
|
||||
*/
|
||||
public abstract class GlobalSettingsProvider extends AbstractDescribableImpl<GlobalSettingsProvider> implements ExtensionPoint {
|
||||
|
||||
/**
|
||||
* configure maven launcher argument list with adequate settings path
|
||||
* @param margs
|
||||
* @param project
|
||||
*/
|
||||
public abstract void configure(ArgumentListBuilder margs, AbstractBuild project) throws IOException, InterruptedException;
|
||||
|
||||
public static GlobalSettingsProvider parseSettingsProvider(StaplerRequest req) throws Descriptor.FormException, ServletException {
|
||||
String scm = req.getParameter("globalSettings");
|
||||
if(scm==null) return new DefaultGlobalSettingsProvider();
|
||||
|
||||
int scmidx = Integer.parseInt(scm);
|
||||
GlobalSettingsProviderDescriptor d = GlobalSettingsProviderDescriptor.all().get(scmidx);
|
||||
return d.newInstance(req, req.getSubmittedForm().getJSONObject("settings"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package hudson.mvn;
|
||||
|
||||
import hudson.model.Descriptor;
|
||||
import jenkins.model.Jenkins;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:nicolas.deloof@gmail.com">Nicolas De Loof</a>
|
||||
* @author Dominik Bartholdi (imod)
|
||||
*/
|
||||
public abstract class GlobalSettingsProviderDescriptor extends Descriptor<GlobalSettingsProvider> {
|
||||
|
||||
|
||||
public static List<GlobalSettingsProviderDescriptor> all() {
|
||||
return Jenkins.getInstance().getDescriptorList(GlobalSettingsProvider.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<!--
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
-->
|
||||
|
||||
<?jelly escape-by-default='true'?>
|
||||
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form">
|
||||
</j:jelly>
|
||||
@@ -0,0 +1,3 @@
|
||||
<div>
|
||||
Use default maven settings (<tt>$HOME/.m2/settings.xml</tt>) as set on build node.
|
||||
</div>
|
||||
@@ -0,0 +1,30 @@
|
||||
<!--
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
-->
|
||||
|
||||
<?jelly escape-by-default='true'?>
|
||||
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:f="/lib/form">
|
||||
<f:entry title="${%File path}" field="path">
|
||||
<f:textbox checkUrl="'descriptorByName/hudson.mvn.FilePathSettingsProvider/check?value='+escape(this.value)"/>
|
||||
</f:entry>
|
||||
</j:jelly>
|
||||
@@ -0,0 +1,3 @@
|
||||
<div>
|
||||
Path to settings.xml file, relative to project workspace.
|
||||
</div>
|
||||
@@ -0,0 +1,3 @@
|
||||
<div>
|
||||
Use a custom <tt>setting.xml</tt> file from job workspace. Such a file is checked out from SCM as part of the job
|
||||
</div>
|
||||
@@ -50,14 +50,19 @@ import hudson.model.ItemGroup;
|
||||
import hudson.model.Job;
|
||||
import hudson.model.Queue;
|
||||
import hudson.model.Queue.Task;
|
||||
import hudson.model.AbstractBuild;
|
||||
import hudson.model.ResourceActivity;
|
||||
import hudson.model.Result;
|
||||
import hudson.model.SCMedItem;
|
||||
import hudson.model.Saveable;
|
||||
import hudson.model.TaskListener;
|
||||
import hudson.model.TopLevelItem;
|
||||
import hudson.mvn.DefaultGlobalSettingsProvider;
|
||||
import hudson.mvn.DefaultSettingsProvider;
|
||||
import hudson.mvn.FilePathGlobalSettingsProvider;
|
||||
import hudson.mvn.FilePathSettingsProvider;
|
||||
import hudson.mvn.GlobalSettingsProvider;
|
||||
import hudson.mvn.GlobalSettingsProviderDescriptor;
|
||||
import hudson.mvn.SettingsProvider;
|
||||
import hudson.mvn.SettingsProviderDescriptor;
|
||||
import hudson.search.CollectionSearchIndex;
|
||||
@@ -73,6 +78,7 @@ import hudson.tasks.Maven.MavenInstallation;
|
||||
import hudson.tasks.Publisher;
|
||||
import hudson.tasks.JavadocArchiver;
|
||||
import hudson.tasks.junit.JUnitResultArchiver;
|
||||
import hudson.util.ArgumentListBuilder;
|
||||
import hudson.util.CopyOnWriteMap;
|
||||
import hudson.util.DescribableList;
|
||||
import hudson.util.FormValidation;
|
||||
@@ -270,6 +276,11 @@ public class MavenModuleSet extends AbstractMavenProject<MavenModuleSet,MavenMod
|
||||
* @since 1.481
|
||||
*/
|
||||
private SettingsProvider settings = new DefaultSettingsProvider();
|
||||
|
||||
/**
|
||||
* @since 1.481
|
||||
*/
|
||||
private GlobalSettingsProvider globalSettings = new DefaultGlobalSettingsProvider();
|
||||
|
||||
|
||||
public Object readResolve() {
|
||||
@@ -595,6 +606,13 @@ public class MavenModuleSet extends AbstractMavenProject<MavenModuleSet,MavenMod
|
||||
return settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.481
|
||||
*/
|
||||
public GlobalSettingsProvider getGlobalSettings() {
|
||||
return globalSettings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.426
|
||||
* @param globalSettingConfigId
|
||||
@@ -1076,6 +1094,7 @@ public class MavenModuleSet extends AbstractMavenProject<MavenModuleSet,MavenMod
|
||||
goals = Util.fixEmpty(req.getParameter("goals").trim());
|
||||
mavenOpts = Util.fixEmpty(req.getParameter("mavenOpts").trim());
|
||||
settings = SettingsProvider.parseSettingsProvider(req);
|
||||
globalSettings = GlobalSettingsProvider.parseSettingsProvider(req);
|
||||
|
||||
mavenName = req.getParameter("maven_version");
|
||||
aggregatorStyleBuild = !req.hasParameter("maven.perModuleBuild");
|
||||
@@ -1162,6 +1181,10 @@ public class MavenModuleSet extends AbstractMavenProject<MavenModuleSet,MavenMod
|
||||
public List<SettingsProviderDescriptor> getSettingsProviders() {
|
||||
return Jenkins.getInstance().getDescriptorList(SettingsProvider.class);
|
||||
}
|
||||
|
||||
public List<GlobalSettingsProviderDescriptor> getGlobalSettingsProviders() {
|
||||
return Jenkins.getInstance().getDescriptorList(GlobalSettingsProvider.class);
|
||||
}
|
||||
|
||||
public String getGlobalMavenOpts() {
|
||||
return globalMavenOpts;
|
||||
|
||||
@@ -53,6 +53,7 @@ import hudson.model.Result;
|
||||
import hudson.model.Run;
|
||||
import hudson.model.StringParameterDefinition;
|
||||
import hudson.model.TaskListener;
|
||||
import hudson.mvn.GlobalSettingsProvider;
|
||||
import hudson.mvn.SettingsProvider;
|
||||
import hudson.remoting.VirtualChannel;
|
||||
import hudson.scm.ChangeLogSet;
|
||||
@@ -722,8 +723,7 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
|
||||
|
||||
if (project.globalSettingConfigPath != null)
|
||||
margs.add("-gs" , project.globalSettingConfigPath);
|
||||
|
||||
|
||||
|
||||
|
||||
// If incrementalBuild is set
|
||||
// and the previous build didn't specify that we need a full build
|
||||
|
||||
@@ -85,6 +85,10 @@ THE SOFTWARE.
|
||||
<f:hetero-radio field="settings" descriptors="${descriptor.settingsProviders}"/>
|
||||
</f:entry>
|
||||
|
||||
<f:entry title="${%Global Settings file}">
|
||||
<f:hetero-radio field="globalSettings" descriptors="${descriptor.globalSettingsProviders}"/>
|
||||
</f:entry>
|
||||
|
||||
<f:optionalBlock name="maven.incrementalBuild"
|
||||
title="${%Incremental build - only build changed modules}"
|
||||
help="/plugin/maven-plugin/incremental.html"
|
||||
|
||||
Reference in new issue
Block a user