Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add global maven config to define default settings providers
- Loading branch information
Showing
4 changed files
with
81 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package jenkins.mvn; | ||
|
||
import hudson.Extension; | ||
import jenkins.model.GlobalConfiguration; | ||
import net.sf.json.JSONObject; | ||
|
||
import org.kohsuke.stapler.StaplerRequest; | ||
|
||
//as close as it gets to the global Maven Project configuration | ||
@Extension(ordinal = 50) | ||
public class GlobalMavenConfig extends GlobalConfiguration { | ||
private SettingsProvider settingsProvider; | ||
private GlobalSettingsProvider globalSettingsProvider; | ||
|
||
public GlobalMavenConfig() { | ||
load(); | ||
} | ||
|
||
@Override | ||
public boolean configure(StaplerRequest req, JSONObject json) throws FormException { | ||
req.bindJSON(this, json); | ||
return true; | ||
} | ||
|
||
public void setGlobalSettingsProvider(GlobalSettingsProvider globalSettingsProvider) { | ||
this.globalSettingsProvider = globalSettingsProvider; | ||
save(); | ||
} | ||
|
||
public void setSettingsProvider(SettingsProvider settingsProvider) { | ||
this.settingsProvider = settingsProvider; | ||
save(); | ||
} | ||
|
||
public GlobalSettingsProvider getGlobalSettingsProvider() { | ||
return globalSettingsProvider != null ? globalSettingsProvider : new DefaultGlobalSettingsProvider(); | ||
} | ||
|
||
public SettingsProvider getSettingsProvider() { | ||
return settingsProvider != null ? settingsProvider : new DefaultSettingsProvider(); | ||
} | ||
|
||
public static GlobalMavenConfig get() { | ||
return GlobalConfiguration.all().get(GlobalMavenConfig.class); | ||
} | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
core/src/main/resources/jenkins/mvn/GlobalMavenConfig/config.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package jenkins.mvn.GlobalMavenConfig; | ||
|
||
def f = namespace(lib.FormTagLib) | ||
|
||
f.section(title:_("Maven Configuration")) { | ||
f.dropdownDescriptorSelector(title:_("Default settings provider"), field:"settingsProvider") | ||
f.dropdownDescriptorSelector(title:_("Default global settings provider"), field:"globalSettingsProvider") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b8adcb4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From: JENKINS-17723