mirror of https://github.com/apache/ant-ivy
NEW: ability to use a dependency instead of an ivy file in standalone mode (IVY-96)
git-svn-id: https://svn.apache.org/repos/asf/incubator/ivy/trunk@484060 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4ebc515b84
commit
ecd6d97cc6
|
|
@ -1,3 +1,4 @@
|
|||
- NEW: ability to use a dependency instead of an ivy file in standalone mode (IVY-96)
|
||||
- NEW: ability to output a path of dependencies in cache from the standalone mode (IVY-92)
|
||||
- NEW: it is now possible to reference existing resolver in resolver containers (IVY-35)
|
||||
- NEW: overwrite attribute in the publish task now let force overwrite of read only files (IVY-83)
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import fr.jayasoft.ivy.url.URLHandlerDispatcher;
|
|||
import fr.jayasoft.ivy.url.URLHandlerRegistry;
|
||||
import fr.jayasoft.ivy.util.DefaultMessageImpl;
|
||||
import fr.jayasoft.ivy.util.Message;
|
||||
import fr.jayasoft.ivy.xml.XmlModuleDescriptorWriter;
|
||||
import fr.jayasoft.ivy.xml.XmlReportParser;
|
||||
|
||||
/**
|
||||
|
|
@ -61,6 +62,10 @@ public class Main {
|
|||
.hasArg()
|
||||
.withDescription( "use given file as ivy file" )
|
||||
.create( "ivy" );
|
||||
Option dependency = OptionBuilder.withArgName( "organisation module revision" )
|
||||
.hasArgs()
|
||||
.withDescription( "use this instead of ivy file to do the rest of the work with this as a dependency." )
|
||||
.create( "dependency" );
|
||||
Option confs = OptionBuilder.withArgName( "configurations" )
|
||||
.hasArgs()
|
||||
.withDescription( "resolve given configurations" )
|
||||
|
|
@ -122,6 +127,7 @@ public class Main {
|
|||
options.addOption(confs);
|
||||
options.addOption(cache);
|
||||
options.addOption(ivyfile);
|
||||
options.addOption(dependency);
|
||||
options.addOption(retrieve);
|
||||
options.addOption(cachepath);
|
||||
options.addOption(revision);
|
||||
|
|
@ -191,12 +197,7 @@ public class Main {
|
|||
} else if (!cache.isDirectory()) {
|
||||
error(options, cache+" is not a directory");
|
||||
}
|
||||
File ivyfile = new File(ivy.substitute(line.getOptionValue("ivy", "ivy.xml")));
|
||||
if (!ivyfile.exists()) {
|
||||
error(options, "ivy file not found: "+ivyfile);
|
||||
} else if (ivyfile.isDirectory()) {
|
||||
error(options, "ivy file is not a file: "+ivyfile);
|
||||
}
|
||||
|
||||
String[] confs;
|
||||
if (line.hasOption("confs")) {
|
||||
confs = line.getOptionValues("confs");
|
||||
|
|
@ -204,6 +205,31 @@ public class Main {
|
|||
confs = new String[] {"*"};
|
||||
}
|
||||
|
||||
File ivyfile;
|
||||
if (line.hasOption("dependency")) {
|
||||
String[] dep = line.getOptionValues("dependency");
|
||||
if (dep.length != 3) {
|
||||
error(options, "dependency should be expressed with exactly 3 arguments: organisation module revision");
|
||||
}
|
||||
ivyfile = File.createTempFile("ivy", ".xml");
|
||||
ivyfile.deleteOnExit();
|
||||
DefaultModuleDescriptor md = DefaultModuleDescriptor.newDefaultInstance(ModuleRevisionId.newInstance(dep[0], "standalone", "working"));
|
||||
DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(md, ModuleRevisionId.newInstance(dep[0], dep[1], dep[2]), false, false, true);
|
||||
for (int i = 0; i < confs.length; i++) {
|
||||
dd.addDependencyConfiguration("default", confs[i]);
|
||||
}
|
||||
md.addDependency(dd);
|
||||
XmlModuleDescriptorWriter.write(md, ivyfile);
|
||||
confs = new String[] {"default"};
|
||||
} else {
|
||||
ivyfile = new File(ivy.substitute(line.getOptionValue("ivy", "ivy.xml")));
|
||||
if (!ivyfile.exists()) {
|
||||
error(options, "ivy file not found: "+ivyfile);
|
||||
} else if (ivyfile.isDirectory()) {
|
||||
error(options, "ivy file is not a file: "+ivyfile);
|
||||
}
|
||||
}
|
||||
|
||||
Date date = new Date();
|
||||
|
||||
ModuleDescriptor md = ivy.resolve(
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import java.io.FileOutputStream;
|
|||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import fr.jayasoft.ivy.DependencyDescriptor;
|
||||
import fr.jayasoft.ivy.Ivy;
|
||||
import fr.jayasoft.ivy.ModuleDescriptor;
|
||||
|
||||
|
|
@ -34,7 +35,34 @@ public class XmlModuleDescriptorWriter {
|
|||
out.println("\t\tresolver=\""+md.getResolverName()+"\"");
|
||||
out.println("\t\tdefault=\""+(md.isDefault()?"true":"false")+"\"");
|
||||
out.println("\t/>");
|
||||
out.println("</ivy-module>");
|
||||
DependencyDescriptor[] dds = md.getDependencies();
|
||||
if (dds.length > 0) {
|
||||
out.println("\t<dependencies>");
|
||||
for (int i = 0; i < dds.length; i++) {
|
||||
out.print("\t\t<dependency");
|
||||
out.print(" org=\""+dds[i].getDependencyRevisionId().getOrganisation()+"\"");
|
||||
out.print(" name=\""+dds[i].getDependencyRevisionId().getName()+"\"");
|
||||
out.print(" rev=\""+dds[i].getDependencyRevisionId().getRevision()+"\"");
|
||||
out.print(" conf=\"");
|
||||
String[] modConfs = dds[i].getModuleConfigurations();
|
||||
for (int j = 0; j < modConfs.length; j++) {
|
||||
String[] depConfs = dds[i].getDependencyConfigurations(modConfs[j]);
|
||||
out.print(modConfs[j]+"->");
|
||||
for (int k = 0; k < depConfs.length; k++) {
|
||||
out.print(depConfs[k]);
|
||||
if (k+1 < depConfs.length) {
|
||||
out.print(",");
|
||||
}
|
||||
}
|
||||
if (j+1 < modConfs.length) {
|
||||
out.print(";");
|
||||
}
|
||||
}
|
||||
out.println("\"/>");
|
||||
}
|
||||
out.println("\t</dependencies>");
|
||||
}
|
||||
out.println("</ivy-module>");
|
||||
} finally {
|
||||
out.close();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue