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], dep[1]+"-caller", "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(settings.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);
}
}
ResolveOptions resolveOptions = new ResolveOptions()
.setConfs(confs)
.setCache(cacheManager)
.setValidate(validate)
.setUseOrigin(line.hasOption("useOrigin"));
ResolveReport report = ivy.resolve(
ivyfile.toURL(),
resolveOptions
);
if (report.hasError()) {
System.exit(1);
}
ModuleDescriptor md = report.getModuleDescriptor();
if (confs.length == 1 && "*".equals(confs[0])) {
confs = md.getConfigurationsNames();
}
if (line.hasOption("retrieve")) {
String retrievePattern = settings.substitute(line.getOptionValue("retrieve"));
if (retrievePattern.indexOf("[") == -1) {
retrievePattern = retrievePattern + "/lib/[conf]/[artifact].[ext]";
}
ivy.retrieve(
md.getModuleRevisionId(),
retrievePattern,
new RetrieveOptions()
.setConfs(confs)
.setCache(cacheManager)
.setSync(line.hasOption("sync"))
.setUseOrigin(line.hasOption("useOrigin")));
}
if (line.hasOption("cachepath")) {
outputCachePath(ivy, cache, md, confs, line.getOptionValue("cachepath", "ivycachepath.txt"));
}
if (line.hasOption("revision")) {
ivy.deliver(
md.getResolvedModuleRevisionId(),
settings.substitute(line.getOptionValue("revision")),
settings.substitute(line.getOptionValue("deliverto", "ivy-[revision].xml")),
DeliverOptions.newInstance(settings)
.setStatus(settings.substitute(line.getOptionValue("status", "release")))
.setValidate(validate)
.setCache(cacheManager)
);
if (line.hasOption("publish")) {
ivy.publish(
md.getResolvedModuleRevisionId(),
Collections.singleton(settings.substitute(line.getOptionValue("publishpattern", "distrib/[type]s/[artifact]-[revision].[ext]"))),
line.getOptionValue("publish"),
new PublishOptions()
.setCache(cacheManager)
.setPubrevision(settings.substitute(line.getOptionValue("revision")))