use of org.apache.ivy.core.module.descriptor.Artifact in project ant-ivy by apache.
the class FileSystemResolverTest method testDisableTransaction.
@Test
public void testDisableTransaction() throws Exception {
FileSystemResolver resolver = new FileSystemResolver();
resolver.setName("test");
resolver.setSettings(settings);
resolver.setTransactional("false");
resolver.addIvyPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/[revision]/[artifact].[ext]");
resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]");
ModuleRevisionId mrid = ModuleRevisionId.newInstance("myorg", "mymodule", "myrevision");
Artifact ivyArtifact = new DefaultArtifact(mrid, new Date(), "ivy", "ivy", "xml");
Artifact artifact = new DefaultArtifact(mrid, new Date(), "myartifact", "mytype", "myext");
File src = new File("test/repositories/ivysettings.xml");
resolver.beginPublishTransaction(mrid, false);
// with transactions disabled the file should be available as soon as they are published
resolver.publish(ivyArtifact, src, false);
assertTrue(new File("test/repositories/1/myorg/mymodule/myrevision/ivy.xml").exists());
resolver.publish(artifact, src, false);
assertTrue(new File("test/repositories/1/myorg/mymodule/myrevision/myartifact-myrevision.myext").exists());
resolver.commitPublishTransaction();
assertTrue(new File("test/repositories/1/myorg/mymodule/myrevision/ivy.xml").exists());
assertTrue(new File("test/repositories/1/myorg/mymodule/myrevision/myartifact-myrevision.myext").exists());
}
use of org.apache.ivy.core.module.descriptor.Artifact in project ant-ivy by apache.
the class XmlModuleUpdaterTest method testUpdateWithExcludeConfigurations4.
@Test
public void testUpdateWithExcludeConfigurations4() throws Exception {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
URL settingsUrl = new File("test/java/org/apache/ivy/plugins/parser/xml/" + "test-update-excludedconfs4.xml").toURI().toURL();
XmlModuleDescriptorUpdater.update(settingsUrl, buffer, getUpdateOptions("release", "mynewrev").setConfsToExclude(new String[] { "myconf2" }));
XmlModuleDescriptorParser parser = XmlModuleDescriptorParser.getInstance();
ModuleDescriptor updatedMd = parser.parseDescriptor(new IvySettings(), new ByteArrayInputStream(buffer.toByteArray()), new BasicResource("test", false, 0, 0, false), true);
// test the number of configurations
Artifact[] artifacts = updatedMd.getAllArtifacts();
assertNotNull("Published artifacts shouldn't be null", artifacts);
assertEquals("Number of published artifacts incorrect", 4, artifacts.length);
// test that the correct configuration has been removed
for (Artifact current : artifacts) {
List<String> currentConfs = Arrays.asList(current.getConfigurations());
assertTrue("myconf2 hasn't been removed for artifact " + current.getName(), !currentConfs.contains("myconf2"));
}
}
use of org.apache.ivy.core.module.descriptor.Artifact in project ant-ivy by apache.
the class BintrayResolverTest method testBintrayArtifacts.
@Test
public void testBintrayArtifacts() throws Exception {
BintrayResolver resolver = new BintrayResolver();
resolver.setName("test");
resolver.setSettings(settings);
assertEquals("test", resolver.getName());
ModuleRevisionId mrid = ModuleRevisionId.newInstance("org.apache.ant", "ant-antunit", "1.2");
DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(mrid, false);
dd.addIncludeRule("default", new DefaultIncludeRule(new ArtifactId(mrid.getModuleId(), "ant-antunit", "javadoc", "jar"), ExactPatternMatcher.INSTANCE, null));
dd.addIncludeRule("default", new DefaultIncludeRule(new ArtifactId(mrid.getModuleId(), "ant-antunit", "sources", "jar"), ExactPatternMatcher.INSTANCE, null));
ResolvedModuleRevision rmr = resolver.getDependency(dd, data);
assertNotNull(rmr);
assertEquals(mrid, rmr.getId());
DefaultArtifact profiler = new DefaultArtifact(mrid, rmr.getPublicationDate(), "ant-antunit", "javadoc", "jar");
DefaultArtifact trace = new DefaultArtifact(mrid, rmr.getPublicationDate(), "ant-antunit", "sources", "jar");
DownloadReport report = resolver.download(new Artifact[] { profiler, trace }, downloadOptions());
assertNotNull(report);
assertEquals(2, report.getArtifactsReports().length);
ArtifactDownloadReport ar = report.getArtifactReport(profiler);
assertNotNull(ar);
assertEquals(profiler, ar.getArtifact());
assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());
ar = report.getArtifactReport(trace);
assertNotNull(ar);
assertEquals(trace, ar.getArtifact());
assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());
// test to ask to download again, should use cache
report = resolver.download(new Artifact[] { profiler, trace }, downloadOptions());
assertNotNull(report);
assertEquals(2, report.getArtifactsReports().length);
ar = report.getArtifactReport(profiler);
assertNotNull(ar);
assertEquals(profiler, ar.getArtifact());
assertEquals(DownloadStatus.NO, ar.getDownloadStatus());
ar = report.getArtifactReport(trace);
assertNotNull(ar);
assertEquals(trace, ar.getArtifact());
assertEquals(DownloadStatus.NO, ar.getDownloadStatus());
}
use of org.apache.ivy.core.module.descriptor.Artifact in project ant-ivy by apache.
the class PackagerResolverTest method testZipResourceInclusion.
@Test
public void testZipResourceInclusion() throws Exception {
Locale oldLocale = Locale.getDefault();
try {
// set the locale to UK as workaround for SUN bug 6240963
Locale.setDefault(Locale.UK);
// Create and configure resolver
PackagerResolver resolver = new PackagerResolver();
resolver.setSettings(settings);
String repoRoot = new File("test/repositories/IVY-1179/repo").toURI().toURL().toExternalForm();
resolver.addIvyPattern(repoRoot + "[organisation]/[module]/[revision]/ivy.xml");
resolver.setPackagerPattern(repoRoot + "[organisation]/[module]/[revision]/packager.xml");
resolver.setBuildRoot(builddir);
resolver.setResourceCache(cachedir);
resolver.setPreserveBuildDirectories(true);
resolver.setVerbose(true);
resolver.setProperty("packager.website.url", new File("test/repositories/IVY-1179/website").toURI().toURL().toExternalForm());
resolver.setName("packager");
// Get module descriptor
ModuleRevisionId mrid = ModuleRevisionId.newInstance("org", "A", "1.0");
ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
// Download artifact
Artifact artifact = new DefaultArtifact(mrid, rmr.getPublicationDate(), "A", "jar", "jar");
resolver.download(new Artifact[] { artifact }, downloadOptions());
// assert that the file A.jar is extracted from the archive
File jar = new File(builddir, "org/A/1.0/artifacts/jars/A.jar");
assertTrue(jar.exists());
// assert that the file README is not extracted from the archive
File readme = new File(builddir, "org/A/1.0/extract/A-1.0/README");
assertFalse(readme.exists());
} finally {
Locale.setDefault(oldLocale);
}
}
use of org.apache.ivy.core.module.descriptor.Artifact in project ant-ivy by apache.
the class PackagerResolverTest method testTarResourceInclusion.
@Test
public void testTarResourceInclusion() throws Exception {
Locale oldLocale = Locale.getDefault();
try {
// set the locale to UK as workaround for SUN bug 6240963
Locale.setDefault(Locale.UK);
// Create and configure resolver
PackagerResolver resolver = new PackagerResolver();
resolver.setSettings(settings);
String repoRoot = new File("test/repositories/IVY-1179/repo").toURI().toURL().toExternalForm();
resolver.addIvyPattern(repoRoot + "[organisation]/[module]/[revision]/ivy.xml");
resolver.setPackagerPattern(repoRoot + "[organisation]/[module]/[revision]/packager.xml");
resolver.setBuildRoot(builddir);
resolver.setResourceCache(cachedir);
resolver.setPreserveBuildDirectories(true);
resolver.setVerbose(true);
resolver.setProperty("packager.website.url", new File("test/repositories/IVY-1179/website").toURI().toURL().toExternalForm());
resolver.setName("packager");
// Get module descriptor
ModuleRevisionId mrid = ModuleRevisionId.newInstance("org", "B", "1.0");
ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
// Download artifact
Artifact artifact = new DefaultArtifact(mrid, rmr.getPublicationDate(), "B", "jar", "jar");
resolver.download(new Artifact[] { artifact }, downloadOptions());
// assert that the file B.jar is extracted from the archive
File jar = new File(builddir, "org/B/1.0/artifacts/jars/B.jar");
assertTrue(jar.exists());
// assert that the file README is not extracted from the archive
File readme = new File(builddir, "org/B/1.0/extract/B-1.0/README");
assertFalse(readme.exists());
} finally {
Locale.setDefault(oldLocale);
}
}
Aggregations