提交 29df1717 编写于 作者: A abayer

[FIXED HUDSON-4205] Added support for Use Private Repository option for...

[FIXED HUDSON-4205] Added support for Use Private Repository option for freestyle Maven steps, including those invoked through m2-extra-steps

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@20969 71c3de6d-444a-0410-be80-ed276b4c234a
上级 741c66e3
......@@ -98,26 +98,49 @@ public class Maven extends Builder {
*/
public final String properties;
/**
* If true, the build will use its own local Maven repository
* via "-Dmaven.repo.local=...".
* <p>
* This would consume additional disk space, but provides isolation with other builds on the same machine,
* such as mixing SNAPSHOTS. Maven also doesn't try to coordinate the concurrent access to Maven repositories
* from multiple Maven process, so this helps there too.
*
* Identical to logic used in maven-plugin.
*
* @since 1.322
*/
public boolean usePrivateRepository = false;
private final static String MAVEN_1_INSTALLATION_COMMON_FILE = "bin/maven";
private final static String MAVEN_2_INSTALLATION_COMMON_FILE = "bin/mvn";
public Maven(String targets,String name) {
this(targets,name,null,null,null);
this(targets,name,null,null,null,false);
}
@DataBoundConstructor
public Maven(String targets,String name, String pom, String properties, String jvmOptions) {
public Maven(String targets,String name, String pom, String properties, String jvmOptions, boolean usePrivateRepository) {
this.targets = targets;
this.mavenName = name;
this.pom = Util.fixEmptyAndTrim(pom);
this.properties = Util.fixEmptyAndTrim(properties);
this.jvmOptions = Util.fixEmptyAndTrim(jvmOptions);
this.usePrivateRepository = usePrivateRepository;
}
public String getTargets() {
return targets;
}
public void setUsePrivateRepository(boolean usePrivateRepository) {
this.usePrivateRepository = usePrivateRepository;
}
public boolean usesPrivateRepository() {
return usePrivateRepository;
}
/**
* Gets the Maven to invoke,
* or null to invoke the default one.
......@@ -221,6 +244,8 @@ public class Maven extends Builder {
args.add("-f",pom);
args.addKeyValuePairs("-D",build.getBuildVariables());
args.addKeyValuePairsFromPropertyString("-D",properties,vr);
if(usesPrivateRepository())
args.add("-Dmaven.repo.local="+build.getWorkspace().child(".repository"));
args.addTokenized(normalizedTarget);
if(mi!=null) {
......
......@@ -46,5 +46,8 @@ THE SOFTWARE.
<f:entry title="${%JVM Options}" help="/plugin/maven-plugin/maven-opts.html">
<f:expandableTextbox field="jvmOptions"/>
</f:entry>
<f:entry field="usePrivateRepository" title="${%Use private Maven repository}" help="/plugin/maven-plugin/private-repository.html">
<f:checkbox checked="${it.usesPrivateRepository()}" />
</f:entry>
</f:advanced>
</j:jelly>
\ No newline at end of file
......@@ -145,8 +145,9 @@ public class EnvVarsInConfigTasksTest extends HudsonTestCase {
"/simple-projects.zip")));
project.getBuildersList().add(
new Maven("test", "varMaven", "pom.xml${"
+ DUMMY_LOCATION_VARNAME + "}", "", ""));
new Maven("test", "varMaven", "pom.xml${"
+ DUMMY_LOCATION_VARNAME + "}", "", "",
false));
// test the regular slave - variable not expanded
project.setAssignedLabel(slaveRegular.getSelfLabel());
......
......@@ -65,7 +65,7 @@ public class MavenTest extends HudsonTestCase {
hudson.getDescriptorByType(Maven.DescriptorImpl.class).setInstallations(); // reset
FreeStyleProject p = createFreeStyleProject();
p.getBuildersList().add(new Maven("a", null, "b.pom", "c=d", "-e"));
p.getBuildersList().add(new Maven("a", null, "b.pom", "c=d", "-e", true));
WebClient webClient = new WebClient();
HtmlPage page = webClient.getPage(p, "configure");
......@@ -80,6 +80,7 @@ public class MavenTest extends HudsonTestCase {
assertEquals("b.pom", m.pom);
assertEquals("c=d", m.properties);
assertEquals("-e", m.jvmOptions);
assertTrue(m.usesPrivateRepository());
}
public void testWithNodeProperty() throws Exception {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册