use of org.apache.ivy.core.module.descriptor.Artifact in project ant-ivy by apache.
the class XmlModuleDescriptorWriter method printPublications.
private static void printPublications(ModuleDescriptor md, PrintWriter out) {
out.println("\t<publications>");
for (Artifact artifact : md.getAllArtifacts()) {
out.print(String.format("\t\t<artifact name=\"%s\" type=\"%s\" ext=\"%s\" conf=\"%s\"", XMLHelper.escape(artifact.getName()), XMLHelper.escape(artifact.getType()), XMLHelper.escape(artifact.getExt()), XMLHelper.escape(getConfs(md, artifact))));
printExtraAttributes(artifact, out, " ");
out.println("/>");
}
out.println("\t</publications>");
}
use of org.apache.ivy.core.module.descriptor.Artifact in project ant-ivy by apache.
the class FileSystemResolverTest method testPublishTransactionWithDottedOrganisation.
@Test
public void testPublishTransactionWithDottedOrganisation() throws Exception {
FileSystemResolver resolver = new FileSystemResolver();
resolver.setName("test");
resolver.setM2compatible(true);
resolver.setSettings(settings);
resolver.addIvyPattern(settings.getBaseDir() + "/test/repositories/m2/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]");
resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/m2/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]");
ModuleRevisionId mrid = ModuleRevisionId.newInstance("org.apache", "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);
// files should not be available until the transaction is committed
resolver.publish(ivyArtifact, src, false);
assertFalse(new File("test/repositories/m2/org/apache/mymodule/myrevision/ivy-myrevision.xml").exists());
resolver.publish(artifact, src, false);
assertFalse(new File("test/repositories/m2/org/apache/mymodule/myrevision/myartifact-myrevision.myext").exists());
resolver.commitPublishTransaction();
assertTrue(new File("test/repositories/m2/org/apache/mymodule/myrevision/ivy-myrevision.xml").exists());
assertTrue(new File("test/repositories/m2/org/apache/mymodule/myrevision/myartifact-myrevision.myext").exists());
}
use of org.apache.ivy.core.module.descriptor.Artifact in project ant-ivy by apache.
the class FileSystemResolverTest method testSHA256Checksum.
/**
* Tests that <code>SHA-256</code> algorithm can be used for checksums on resolvers
*
* @throws Exception if something goes wrong
*/
@Test
public void testSHA256Checksum() throws Exception {
final FileSystemResolver resolver = new FileSystemResolver();
resolver.setName("sha256-checksum-resolver");
resolver.setSettings(settings);
resolver.addIvyPattern(settings.getBaseDir() + "/test/repositories/checksums/[module]/[revision]/[artifact]-[revision].[ext]");
resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/checksums/[module]/[revision]/[artifact]-[revision].[ext]");
resolver.setChecksums("SHA-256");
final ModuleRevisionId mrid = ModuleRevisionId.newInstance("test", "allright", "2.0");
final ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
assertNotNull("Resolved module revision was null for " + mrid, rmr);
final DownloadReport dr = resolver.download(rmr.getDescriptor().getAllArtifacts(), getDownloadOptions());
final ArtifactDownloadReport[] successfulDownloadReports = dr.getArtifactsReports(DownloadStatus.SUCCESSFUL);
assertNotNull("No artifacts were downloaded successfully", successfulDownloadReports);
assertEquals("Unexpected number of successfully downloaded artifacts", 1, successfulDownloadReports.length);
final ArtifactDownloadReport successfulDownloadReport = successfulDownloadReports[0];
final Artifact downloadedArtifact = successfulDownloadReport.getArtifact();
assertEquals("Unexpected organization of downloaded artifact", "test", downloadedArtifact.getModuleRevisionId().getOrganisation());
assertEquals("Unexpected module of downloaded artifact", "allright", downloadedArtifact.getModuleRevisionId().getModuleId().getName());
assertEquals("Unexpected revision of downloaded artifact", "2.0", downloadedArtifact.getModuleRevisionId().getRevision());
}
use of org.apache.ivy.core.module.descriptor.Artifact in project ant-ivy by apache.
the class FileSystemResolverTest method testPublishTransaction.
@Test
public void testPublishTransaction() throws Exception {
FileSystemResolver resolver = new FileSystemResolver();
resolver.setName("test");
resolver.setSettings(settings);
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);
// files should not be available until the transaction is committed
resolver.publish(ivyArtifact, src, false);
assertFalse(new File("test/repositories/1/myorg/mymodule/myrevision/ivy.xml").exists());
resolver.publish(artifact, src, false);
assertFalse(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 FileSystemResolverTest method testPublishTransactionWithBranch.
@Test
public void testPublishTransactionWithBranch() throws Exception {
FileSystemResolver resolver = new FileSystemResolver();
resolver.setName("test");
resolver.setSettings(settings);
resolver.addIvyPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/[branch]/[revision]/[artifact].[ext]");
resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/[branch]/[revision]/[artifact]-[revision].[ext]");
ModuleRevisionId mrid = ModuleRevisionId.newInstance("myorg", "mymodule", "mybranch", "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);
// files should not be available until the transaction is committed
resolver.publish(ivyArtifact, src, false);
assertFalse(new File("test/repositories/1/myorg/mymodule/mybranch/myrevision/ivy.xml").exists());
resolver.publish(artifact, src, false);
assertFalse(new File("test/repositories/1/myorg/mymodule/mybranch/myrevision/myartifact-myrevision.myext").exists());
resolver.commitPublishTransaction();
assertTrue(new File("test/repositories/1/myorg/mymodule/mybranch/myrevision/ivy.xml").exists());
assertTrue(new File("test/repositories/1/myorg/mymodule/mybranch/myrevision/myartifact-myrevision.myext").exists());
}
Aggregations