Index: src/java/org/apache/ivy/core/install/InstallOptions.java
===================================================================
--- src/java/org/apache/ivy/core/install/InstallOptions.java (revision 1244283)
+++ src/java/org/apache/ivy/core/install/InstallOptions.java (working copy)
@@ -25,6 +25,7 @@
private boolean transitive = true;
private boolean validate = true;
private boolean overwrite = false;
+ private String[] confs = {"*"};
private Filter artifactFilter = FilterHelper.NO_FILTER;
private String matcherName = PatternMatcher.EXACT;
@@ -63,4 +64,11 @@
this.matcherName = matcherName;
return this;
}
+ public String[] getConfs() {
+ return confs;
+ }
+ public InstallOptions setConfs(String[] conf) {
+ this.confs = conf;
+ return this;
+ }
}
Index: src/java/org/apache/ivy/core/install/InstallEngine.java
===================================================================
--- src/java/org/apache/ivy/core/install/InstallEngine.java (revision 1296741)
+++ src/java/org/apache/ivy/core/install/InstallEngine.java (working copy)
@@ -86,36 +86,51 @@
"apache", "ivy-install", "1.0"), settings.getStatusManager().getDefaultStatus(),
new Date());
String resolveId = ResolveOptions.getDefaultResolveId(md);
- md.addConfiguration(new Configuration("default"));
md.addConflictManager(new ModuleId(ExactPatternMatcher.ANY_EXPRESSION,
ExactPatternMatcher.ANY_EXPRESSION), ExactPatternMatcher.INSTANCE,
new NoConflictManager());
+
+ final String masterConf = "default";
+
+ md.addConfiguration(new Configuration(masterConf));
- if (MatcherHelper.isExact(matcher, mrid)) {
- DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(md, mrid, false,
- false, options.isTransitive());
- dd.addDependencyConfiguration("default", "*");
- md.addDependency(dd);
- } else {
- ModuleRevisionId[] mrids = searchEngine.listModules(fromResolver, mrid, matcher);
+ for (int c = 0; c < options.getConfs().length; c++) {
+
+ final String[] depConfs = options.getConfs();
- for (int i = 0; i < mrids.length; i++) {
- Message.info("\tfound " + mrids[i] + " to install: adding to the list");
- DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(md, mrids[i],
- false, false, options.isTransitive());
- dd.addDependencyConfiguration("default", "*");
- md.addDependency(dd);
+ for (int j = 0; j < depConfs.length; j++) {
+
+ final String depConf = depConfs[j].trim();
+
+ if (MatcherHelper.isExact(matcher, mrid)) {
+ DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(md, mrid, false,
+ false, options.isTransitive());
+ dd.addDependencyConfiguration(masterConf, depConf);
+ md.addDependency(dd);
+ } else {
+ ModuleRevisionId[] mrids = searchEngine.listModules(fromResolver, mrid, matcher);
+
+ for (int i = 0; i < mrids.length; i++) {
+ Message.info("\tfound " + mrids[i] + " to install: adding to the list");
+ DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(md, mrids[i],
+ false, false, options.isTransitive());
+ dd.addDependencyConfiguration(masterConf, depConf);
+ md.addDependency(dd);
+ }
+ }
}
}
-
+
// resolve using appropriate resolver
ResolveReport report = new ResolveReport(md, resolveId);
Message.info(":: resolving dependencies ::");
+
ResolveOptions resolveOptions = new ResolveOptions()
.setResolveId(resolveId)
- .setConfs(new String[] {"default"})
+ .setConfs(new String[] {masterConf})
.setValidate(options.isValidate());
+
IvyNode[] dependencies = resolveEngine.getDependencies(md, resolveOptions, report);
report.setDependencies(Arrays.asList(dependencies), options.getArtifactFilter());
Index: src/java/org/apache/ivy/ant/IvyInstall.java
===================================================================
--- src/java/org/apache/ivy/ant/IvyInstall.java (revision 1244283)
+++ src/java/org/apache/ivy/ant/IvyInstall.java (working copy)
@@ -40,6 +40,8 @@
private String revision;
private String branch;
+
+ private String conf = "*";
private boolean overwrite = false;
@@ -48,7 +50,7 @@
private String to;
private boolean transitive;
-
+
private String type;
private String matcher = PatternMatcher.EXACT;
@@ -103,6 +105,7 @@
.setTransitive(transitive)
.setValidate(doValidate(settings))
.setOverwrite(overwrite)
+ .setConfs(conf.split(","))
.setArtifactFilter(FilterHelper.getArtifactTypeFilter(type))
.setMatcherName(matcher));
} catch (Exception e) {
@@ -206,4 +209,13 @@
public void setMatcher(String matcher) {
this.matcher = matcher;
}
+
+ public String getConf() {
+ return conf;
+ }
+
+ public void setConf(String conf) {
+ this.conf = conf;
+ }
+
}
Index: test/repositories/IVY-1313/ivysettings.xml
===================================================================
--- test/repositories/IVY-1313/ivysettings.xml (revision 0)
+++ test/repositories/IVY-1313/ivysettings.xml (revision 0)
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: test/repositories/IVY-1313/repo/org1/mod1/ivys/ivy-1.0.xml
===================================================================
--- test/repositories/IVY-1313/repo/org1/mod1/ivys/ivy-1.0.xml (revision 0)
+++ test/repositories/IVY-1313/repo/org1/mod1/ivys/ivy-1.0.xml (revision 0)
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: test/repositories/IVY-1313/repo/org1/mod1/sources/mod1-1.0.jar
===================================================================
Index: test/repositories/IVY-1313/repo/org1/mod1/jars/mod1-1.0.jar
===================================================================
Index: test/repositories/IVY-1313/repo/org1/mod2/jars/mod2-1.0.jar
===================================================================
Index: test/repositories/IVY-1313/repo/org1/mod2/sources/mod2-1.0.jar
===================================================================
Index: test/repositories/IVY-1313/repo/org1/mod2/ivys/ivy-1.0.xml
===================================================================
--- test/repositories/IVY-1313/repo/org1/mod2/ivys/ivy-1.0.xml (revision 0)
+++ test/repositories/IVY-1313/repo/org1/mod2/ivys/ivy-1.0.xml (revision 0)
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: test/repositories/IVY-1313/repo/org1/mod3/sources/mod3-1.0.jar
===================================================================
Index: test/repositories/IVY-1313/repo/org1/mod3/ivys/ivy-1.0.xml
===================================================================
--- test/repositories/IVY-1313/repo/org1/mod3/ivys/ivy-1.0.xml (revision 0)
+++ test/repositories/IVY-1313/repo/org1/mod3/ivys/ivy-1.0.xml (revision 0)
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: test/repositories/IVY-1313/repo/org1/mod3/jars/mod3-1.0.jar
===================================================================
Index: test/java/org/apache/ivy/ant/IvyInstallTest.java
===================================================================
--- test/java/org/apache/ivy/ant/IvyInstallTest.java (revision 1245872)
+++ test/java/org/apache/ivy/ant/IvyInstallTest.java (working copy)
@@ -110,6 +110,45 @@
assertTrue(new File("build/test/install/org8/mod8.1/a-1.1.txt").exists());
}
+ /**
+ * Normal case; no confs set (should use the default->* configuration).
+ */
+ public void testInstallWithConfsDefaultSettings() {
+ project.setProperty("ivy.settings.file", "test/repositories/IVY-1313/ivysettings.xml");
+ install.setOrganisation("org1");
+ install.setModule("mod1");
+ install.setRevision("1.0");
+ install.setFrom("default");
+ install.setTo("install");
+ install.setTransitive(true);
+
+ install.execute();
+
+ assertTrue(new File("build/test/install/org1/mod1/jars/mod1-1.0.jar").exists());
+ assertTrue(new File("build/test/install/org1/mod2/jars/mod2-1.0.jar").exists());
+ assertTrue(new File("build/test/install/org1/mod3/jars/mod3-1.0.jar").exists());
+ }
+
+ /**
+ * Test retrieving artifacts under only the master and runtime configuration.
+ */
+ public void testInstallWithConfsRuntimeOnly() {
+ project.setProperty("ivy.settings.file", "test/repositories/IVY-1313/ivysettings.xml");
+ install.setOrganisation("org1");
+ install.setModule("mod1");
+ install.setRevision("1.0");
+ install.setFrom("default");
+ install.setTo("install");
+ install.setConf("master,runtime");
+ install.setTransitive(true);
+
+ install.execute();
+
+ assertTrue(new File("build/test/install/org1/mod1/jars/mod1-1.0.jar").exists());
+ assertTrue(new File("build/test/install/org1/mod2/jars/mod2-1.0.jar").exists());
+ assertFalse(new File("build/test/install/org1/mod3/jars/mod3-1.0.jar").exists());
+ }
+
public void testInstallWithClassifiers() throws Exception {
// IVY-1324
project.setProperty("ivy.settings.url", new File("test/repositories/m2/ivysettings.xml").toURL().toExternalForm());