mirror of https://github.com/apache/ant-ivy
IMPROVEMENT: add branch attribute in ivy:install task (IVY-727)
git-svn-id: https://svn.apache.org/repos/asf/ant/ivy/core/trunk@632587 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3561d1a87f
commit
3eef3cd67e
|
|
@ -65,6 +65,7 @@ for detailed view of each issue, please consult http://issues.apache.org/jira/br
|
|||
trunk version
|
||||
=====================================
|
||||
- IMPROVEMENT: Make Ivy standalone runnable with no required dependencies (IVY-757)
|
||||
- IMPROVEMENT: add branch attribute in ivy:install task (IVY-727)
|
||||
|
||||
- FIX: XML schema ambiguity (IVY-750)
|
||||
- FIX: ivy-resolve fails when a project has different dependencies in different branches (IVY-717)
|
||||
|
|
|
|||
|
|
@ -46,6 +46,8 @@ For more details about this task and its usage see the <a href="../tutorial/buil
|
|||
<td>Yes</td></tr>
|
||||
<tr><td>module</td><td>the name of the module to install</td>
|
||||
<td>Yes</td></tr>
|
||||
<tr><td>branch</td><td>the branch of the module to install <span class="since">since 2.0</span></td>
|
||||
<td>No, defaults to default branch with exact matcher, '*' with any other matcher</td></tr>
|
||||
<tr><td>revision</td><td>the revision of the module to install</td>
|
||||
<td>Yes</td></tr>
|
||||
<tr><td>validate</td><td>true to force ivy files validation against ivy.xsd, false to force no validation</td>
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ package org.apache.ivy.ant;
|
|||
import java.io.File;
|
||||
|
||||
import org.apache.ivy.Ivy;
|
||||
import org.apache.ivy.core.module.id.ModuleId;
|
||||
import org.apache.ivy.core.module.id.ModuleRevisionId;
|
||||
import org.apache.ivy.core.report.ResolveReport;
|
||||
import org.apache.ivy.core.settings.IvySettings;
|
||||
|
|
@ -37,6 +38,8 @@ public class IvyInstall extends IvyTask {
|
|||
|
||||
private String revision;
|
||||
|
||||
private String branch;
|
||||
|
||||
private boolean overwrite = false;
|
||||
|
||||
private String from;
|
||||
|
|
@ -76,6 +79,11 @@ public class IvyInstall extends IvyTask {
|
|||
} else if (revision == null && !PatternMatcher.EXACT.equals(matcher)) {
|
||||
revision = PatternMatcher.ANY_EXPRESSION;
|
||||
}
|
||||
if (branch == null && PatternMatcher.EXACT.equals(matcher)) {
|
||||
branch = settings.getDefaultBranch(ModuleId.newInstance(organisation, module));
|
||||
} else if (branch == null && !PatternMatcher.EXACT.equals(matcher)) {
|
||||
branch = PatternMatcher.ANY_EXPRESSION;
|
||||
}
|
||||
if (from == null) {
|
||||
throw new BuildException(
|
||||
"no from resolver name: please provide it through parameter 'from'");
|
||||
|
|
@ -84,7 +92,9 @@ public class IvyInstall extends IvyTask {
|
|||
throw new BuildException(
|
||||
"no to resolver name: please provide it through parameter 'to'");
|
||||
}
|
||||
ModuleRevisionId mrid = ModuleRevisionId.newInstance(organisation, module, revision);
|
||||
ModuleRevisionId mrid =
|
||||
ModuleRevisionId.newInstance(organisation, module, branch, revision);
|
||||
|
||||
ResolveReport report;
|
||||
try {
|
||||
report = ivy.install(mrid, from, to, transitive, doValidate(settings), overwrite,
|
||||
|
|
@ -119,6 +129,14 @@ public class IvyInstall extends IvyTask {
|
|||
this.module = module;
|
||||
}
|
||||
|
||||
public String getBranch() {
|
||||
return branch;
|
||||
}
|
||||
|
||||
public void setBranch(String branch) {
|
||||
this.branch = branch;
|
||||
}
|
||||
|
||||
public String getOrganisation() {
|
||||
return organisation;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ import java.io.File;
|
|||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.ivy.util.FileUtil;
|
||||
import org.apache.tools.ant.BuildException;
|
||||
import org.apache.tools.ant.Project;
|
||||
import org.apache.tools.ant.taskdefs.Delete;
|
||||
|
||||
public class IvyInstallTest extends TestCase {
|
||||
private File cache;
|
||||
|
|
@ -34,7 +34,7 @@ public class IvyInstallTest extends TestCase {
|
|||
|
||||
protected void setUp() throws Exception {
|
||||
createCache();
|
||||
cleanTestLib();
|
||||
cleanInstall();
|
||||
project = new Project();
|
||||
project.setProperty("ivy.settings.file", "test/repositories/ivysettings.xml");
|
||||
|
||||
|
|
@ -50,21 +50,29 @@ public class IvyInstallTest extends TestCase {
|
|||
|
||||
protected void tearDown() throws Exception {
|
||||
cleanCache();
|
||||
cleanTestLib();
|
||||
cleanInstall();
|
||||
}
|
||||
|
||||
private void cleanCache() {
|
||||
Delete del = new Delete();
|
||||
del.setProject(new Project());
|
||||
del.setDir(cache);
|
||||
del.execute();
|
||||
FileUtil.forceDelete(cache);
|
||||
}
|
||||
|
||||
private void cleanTestLib() {
|
||||
Delete del = new Delete();
|
||||
del.setProject(new Project());
|
||||
del.setDir(new File("build/test/lib"));
|
||||
del.execute();
|
||||
private void cleanInstall() {
|
||||
FileUtil.forceDelete(new File("build/test/install"));
|
||||
}
|
||||
|
||||
public void testInstallWithBranch() {
|
||||
project.setProperty("ivy.settings.file", "test/repositories/branches/ivysettings.xml");
|
||||
install.setOrganisation("foo");
|
||||
install.setModule("foo1");
|
||||
install.setBranch("branch1");
|
||||
install.setRevision("2");
|
||||
install.setFrom("default");
|
||||
install.setTo("install");
|
||||
|
||||
install.execute();
|
||||
|
||||
assertTrue(new File("build/test/install/foo/foo1/branch1/ivy-2.xml").exists());
|
||||
}
|
||||
|
||||
public void testDependencyNotFoundFailure() {
|
||||
|
|
@ -72,11 +80,11 @@ public class IvyInstallTest extends TestCase {
|
|||
install.setModule("yyy");
|
||||
install.setRevision("zzz");
|
||||
install.setFrom("test");
|
||||
install.setTo("1");
|
||||
install.setTo("install");
|
||||
|
||||
try {
|
||||
install.execute();
|
||||
fail("unknown dependency, failure expected (haltunresolved=true)");
|
||||
fail("unknown dependency, failure expected (haltonfailure=true)");
|
||||
} catch (BuildException be) {
|
||||
// success
|
||||
}
|
||||
|
|
@ -93,7 +101,7 @@ public class IvyInstallTest extends TestCase {
|
|||
try {
|
||||
install.execute();
|
||||
} catch (BuildException be) {
|
||||
fail("unknown dependency, failure unexepected (haltunresolved=false)");
|
||||
fail("unknown dependency, failure unexpected (haltonfailure=false). Failure: " + be);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,5 +23,9 @@
|
|||
<ivy pattern="${ivy.settings.dir}/[organisation]/[module]/[branch]/[revision]/[artifact].[ext]" />
|
||||
<artifact pattern="${ivy.settings.dir}/[organisation]/[module]/[branch]/[revision]/[artifact].[ext]" />
|
||||
</filesystem>
|
||||
<filesystem name="install">
|
||||
<ivy pattern="build/test/install/[organisation]/[module]/[branch]/[artifact]-[revision].[ext]"/>
|
||||
<artifact pattern="build/test/install/[organisation]/[module]/[branch]/[artifact]-[revision].[ext]"/>
|
||||
</filesystem>
|
||||
</resolvers>
|
||||
</ivysettings>
|
||||
|
|
|
|||
Loading…
Reference in New Issue