use of org.apache.ivy.core.deliver.DeliverOptions in project ant-ivy by apache.
the class ResolveTest method testIVY1300.
/**
* Test case for IVY-1300.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-1300">IVY-1300</a>
*/
@Test
public void testIVY1300() throws Exception {
ivy = Ivy.newInstance();
ivy.configure(new File("test/repositories/IVY-1300/ivysettings.xml"));
ResolveOptions opts = new ResolveOptions();
opts.setConfs(new String[] { "*" });
opts.setResolveId("resolveid");
opts.setTransitive(true);
ResolveReport report = ivy.resolve(new File("test/repositories/IVY-1300/assembly-ivy.xml"), opts);
assertFalse(report.hasError());
ModuleRevisionId modAExpectedRevId = ModuleRevisionId.newInstance("myorg", "modA", "trunk", "5");
ModuleRevisionId modBExpectedRevId = ModuleRevisionId.newInstance("myorg", "modB", "releasebranch", "1");
// check that the resolve report has the expected results, namely that
// trunk/5 is considered later than branch/1 purely because 5>1. Of
// course it is more likely that we would want to consider this a
// 'bad comparison', but this Unit Test is not about that. It is about
// inconsistency of results between the resolve report and the
// delivered descriptor. In fact the delivered descriptor is out of
// step, because retrieve and the report both agree that trunk/5 is
// selected. Deliver begs to differ.
Set<ModuleRevisionId> reportMrids = report.getConfigurationReport("default").getModuleRevisionIds();
assertEquals(new HashSet<>(Arrays.asList(modAExpectedRevId, modBExpectedRevId)), reportMrids);
DeliverOptions dopts = new DeliverOptions();
dopts.setGenerateRevConstraint(true);
dopts.setConfs(new String[] { "*" });
dopts.setStatus("release");
dopts.setPubdate(new Date());
dopts.setResolveId("resolveid");
String pubrev = "1";
String deliveryPattern = "build/test/deliver/assembly-[revision].xml";
ivy.deliver(pubrev, deliveryPattern, dopts);
// now check that the resolve report has the same info as the delivered descriptor
File deliveredIvyFile = new File("build/test/deliver/assembly-1.xml");
assertTrue(deliveredIvyFile.exists());
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(ivy.getSettings(), deliveredIvyFile.toURI().toURL(), false);
DependencyDescriptor[] dds = md.getDependencies();
assertEquals(2, dds.length);
assertEquals(ModuleRevisionId.newInstance("myorg", "modB", "releasebranch", "1"), dds[1].getDependencyRevisionId());
assertEquals(ModuleRevisionId.newInstance("myorg", "modA", "trunk", "5"), dds[0].getDependencyRevisionId());
}
use of org.apache.ivy.core.deliver.DeliverOptions in project ant-ivy by apache.
the class ResolveTest method testIVY1159.
private void testIVY1159(String modCIvyFile, boolean replaceForced) throws Exception {
ivy = Ivy.newInstance();
ivy.configure(new File("test/repositories/IVY-1159/ivysettings.xml"));
ResolveOptions opts = new ResolveOptions();
opts.setConfs(new String[] { "*" });
opts.setResolveId("resolveid");
opts.setRefresh(true);
opts.setTransitive(true);
ResolveReport report = ivy.resolve(new File("test/repositories/IVY-1159/" + modCIvyFile), opts);
assertFalse(report.hasError());
assertEquals(new HashSet<>(Arrays.asList(ModuleRevisionId.newInstance("myorg", "modA", "1"), ModuleRevisionId.newInstance("myorg", "modB", "1"))), report.getConfigurationReport("default").getModuleRevisionIds());
DeliverOptions dopts = new DeliverOptions();
dopts.setReplaceForcedRevisions(replaceForced);
dopts.setGenerateRevConstraint(true);
dopts.setConfs(new String[] { "*" });
dopts.setStatus("release");
dopts.setPubdate(new Date());
dopts.setResolveId("resolveid");
String pubrev = "1";
String deliveryPattern = "build/test/deliver/ivy-[revision].xml";
ivy.deliver(pubrev, deliveryPattern, dopts);
}
use of org.apache.ivy.core.deliver.DeliverOptions in project ant-ivy by apache.
the class ResolveTest method testNoAttributesForcedDependencies.
@Test
public void testNoAttributesForcedDependencies() throws Exception {
Ivy ivy = new Ivy();
ivy.configure(new File("test/repositories/extra-attributes-forceddependencies/ivysettings-filerepo-noattribs.xml"));
ivy.getSettings().setDefaultCache(cache);
ResolveReport report = ivy.resolve(ResolveTest.class.getResource("ivy-extra-attrib-forced-dependencies.xml"), getResolveOptions(ivy.getSettings(), new String[] { "*" }).setValidate(false));
assertFalse(report.hasError());
ivy.deliver("1.0.0", deliverDir.getAbsolutePath() + "/ivy-1.0.0.xml", new DeliverOptions().setResolveId(report.getResolveId()).setValidate(false).setPubdate(new Date()));
File deliveredIvyFile = new File(deliverDir, "ivy-1.0.0.xml");
assertTrue(deliveredIvyFile.exists());
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(ivy.getSettings(), deliveredIvyFile.toURI().toURL(), false);
DependencyDescriptor[] dds = md.getDependencies();
assertEquals(2, dds.length);
assertEquals(ModuleRevisionId.newInstance("CAE-Visualization-Components", "SGL", "MAIN", "6.2.34.7"), dds[1].getDependencyRevisionId());
}
use of org.apache.ivy.core.deliver.DeliverOptions in project ant-ivy by apache.
the class ResolveTest method testExtraAttributesForcedDependencies.
@Test
public void testExtraAttributesForcedDependencies() throws Exception {
Ivy ivy = new Ivy();
ivy.configure(new File("test/repositories/extra-attributes-forceddependencies/ivysettings-filerepo-attribs.xml"));
ivy.getSettings().setDefaultCache(cache);
ResolveReport report = ivy.resolve(ResolveTest.class.getResource("ivy-extra-attrib-forced-dependencies.xml"), getResolveOptions(ivy.getSettings(), new String[] { "*" }).setValidate(false));
assertFalse(report.hasError());
ivy.deliver("1.0.0", deliverDir.getAbsolutePath() + "/ivy-1.0.0.xml", new DeliverOptions().setResolveId(report.getResolveId()).setValidate(false).setPubdate(new Date()));
File deliveredIvyFile = new File(deliverDir, "ivy-1.0.0.xml");
assertTrue(deliveredIvyFile.exists());
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(ivy.getSettings(), deliveredIvyFile.toURI().toURL(), false);
DependencyDescriptor[] dds = md.getDependencies();
assertEquals(2, dds.length);
assertEquals(ModuleRevisionId.newInstance("CAE-Visualization-Components", "SGL", "MAIN", "6.2.34.7"), dds[1].getDependencyRevisionId());
}
use of org.apache.ivy.core.deliver.DeliverOptions in project ant-ivy by apache.
the class IvyDeliver method doExecute.
public void doExecute() throws BuildException {
Ivy ivy = getIvyInstance();
IvySettings settings = ivy.getSettings();
organisation = getProperty(organisation, settings, "ivy.organisation", resolveId);
module = getProperty(module, settings, "ivy.module", resolveId);
revision = getProperty(revision, settings, "ivy.revision", resolveId);
pubBranch = getProperty(pubBranch, settings, "ivy.deliver.branch");
pubRevision = getProperty(pubRevision, settings, "ivy.deliver.revision");
deliverpattern = getProperty(deliverpattern, settings, "ivy.deliver.ivy.pattern");
status = getProperty(status, settings, "ivy.status");
if (deliveryList == null) {
String deliveryListPath = getProperty(settings, "ivy.delivery.list.file");
if (deliveryListPath == null) {
deliveryList = new File(System.getProperty("java.io.tmpdir") + "/delivery.properties");
} else {
deliveryList = getProject().resolveFile(settings.substitute(deliveryListPath));
}
}
if (resolveId == null) {
if (organisation == null) {
throw new BuildException("no organisation provided for ivy deliver task: " + "It can either be set explicitly via the attribute 'organisation' " + "or via 'ivy.organisation' property or a prior call to <resolve/>");
}
if (module == null) {
throw new BuildException("no module name provided for ivy deliver task: " + "It can either be set explicitly via the attribute 'module' " + "or via 'ivy.module' property or a prior call to <resolve/>");
}
}
if (revision == null) {
revision = Ivy.getWorkingRevision();
}
Date pubdate = getPubDate(this.pubdate, new Date());
if (pubRevision == null) {
if (revision.startsWith("working@")) {
pubRevision = DateUtil.format(pubdate);
} else {
pubRevision = revision;
}
}
if (deliverpattern == null) {
throw new BuildException("deliver ivy pattern is missing: either provide it as parameters " + "or through ivy.deliver.ivy.pattern properties");
}
if (status == null) {
throw new BuildException("no status provided: either provide it as parameter or through " + "the ivy.status.default property");
}
ModuleRevisionId mrid = null;
if (resolveId == null) {
mrid = ModuleRevisionId.newInstance(organisation, module, revision);
}
boolean isLeading = false;
try {
if (!deliveryList.exists()) {
isLeading = true;
}
loadDeliveryList();
PublishingDependencyRevisionResolver drResolver;
if (isNullOrEmpty(deliverTarget)) {
drResolver = new DefaultPublishingDRResolver();
} else {
drResolver = new DeliverDRResolver();
}
DeliverOptions options = new DeliverOptions(status, pubdate, drResolver, doValidate(settings), replacedynamicrev, splitToArray(conf)).setResolveId(resolveId).setReplaceForcedRevisions(isReplaceForcedRev()).setGenerateRevConstraint(generateRevConstraint).setMerge(merge).setPubBranch(pubBranch);
if (mrid == null) {
ivy.deliver(pubRevision, deliverpattern, options);
} else {
ivy.deliver(mrid, pubRevision, deliverpattern, options);
}
} catch (Exception e) {
throw new BuildException("impossible to deliver " + (mrid == null ? resolveId : mrid) + ": " + e, e);
} finally {
if (isLeading) {
if (deliveryList.exists()) {
deliveryList.delete();
}
}
}
}
Aggregations