org.apache.ivy.core.report.DownloadReport Java Examples
The following examples show how to use
org.apache.ivy.core.report.DownloadReport.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FileSystemResolverTest.java From ant-ivy with Apache License 2.0 | 6 votes |
/** * Tests that <code>SHA-512</code> algorithm can be used for checksums on resolvers * * @throws Exception if something goes wrong */ @Test public void testSHA512Checksum() 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-512"); final ModuleRevisionId mrid = ModuleRevisionId.newInstance("test", "allright", "3.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", "3.0", downloadedArtifact.getModuleRevisionId().getRevision()); }
Example #2
Source File: FileSystemResolverTest.java From ant-ivy with Apache License 2.0 | 6 votes |
/** * 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()); }
Example #3
Source File: CacheResolver.java From ant-ivy with Apache License 2.0 | 6 votes |
@Override public DownloadReport download(Artifact[] artifacts, DownloadOptions options) { ensureConfigured(); clearArtifactAttempts(); DownloadReport dr = new DownloadReport(); for (Artifact artifact : artifacts) { final ArtifactDownloadReport adr = new ArtifactDownloadReport(artifact); dr.addArtifactReport(adr); ResolvedResource artifactRef = getArtifactRef(artifact, null); if (artifactRef != null) { Message.verbose("\t[NOT REQUIRED] " + artifact); ArtifactOrigin origin = new ArtifactOrigin(artifact, true, artifactRef .getResource().getName()); File archiveFile = ((FileResource) artifactRef.getResource()).getFile(); adr.setDownloadStatus(DownloadStatus.NO); adr.setSize(archiveFile.length()); adr.setArtifactOrigin(origin); adr.setLocalFile(archiveFile); } else { adr.setDownloadStatus(DownloadStatus.FAILED); } } return dr; }
Example #4
Source File: BasicResolver.java From ant-ivy with Apache License 2.0 | 6 votes |
public DownloadReport download(Artifact[] artifacts, DownloadOptions options) { RepositoryCacheManager cacheManager = getRepositoryCacheManager(); clearArtifactAttempts(); DownloadReport dr = new DownloadReport(); for (Artifact artifact : artifacts) { ArtifactDownloadReport adr = cacheManager.download(artifact, artifactResourceResolver, downloader, getCacheDownloadOptions(options)); if (DownloadStatus.FAILED == adr.getDownloadStatus()) { if (!ArtifactDownloadReport.MISSING_ARTIFACT.equals(adr.getDownloadDetails())) { Message.warn("\t" + adr); } } else if (DownloadStatus.NO == adr.getDownloadStatus()) { Message.verbose("\t" + adr); } else if (LogOptions.LOG_QUIET.equals(options.getLog())) { Message.verbose("\t" + adr); } else { Message.info("\t" + adr); } dr.addArtifactReport(adr); checkInterrupted(); } return dr; }
Example #5
Source File: P2DescriptorTest.java From ant-ivy with Apache License 2.0 | 5 votes |
@Test public void testResolveNotZipped() throws Exception { settings.setDefaultResolver("p2-zipped"); ModuleRevisionId mrid = ModuleRevisionId.newInstance(BundleInfo.BUNDLE_TYPE, "org.eclipse.e4.core.services", "1.0.0.v20120521-2346"); ResolvedModuleRevision rmr = p2ZippedResolver.getDependency( new DefaultDependencyDescriptor(mrid, false), data); assertNotNull(rmr); assertEquals(mrid, rmr.getId()); assertEquals(1, rmr.getDescriptor().getAllArtifacts().length); DownloadOptions options = new DownloadOptions(); DownloadReport report = p2ZippedResolver.download(rmr.getDescriptor().getAllArtifacts(), options); assertNotNull(report); assertEquals(1, report.getArtifactsReports().length); Artifact artifact = rmr.getDescriptor().getAllArtifacts()[0]; ArtifactDownloadReport ar = report.getArtifactReport(artifact); assertNotNull(ar); assertEquals(artifact, ar.getArtifact()); assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus()); assertNull(ar.getUnpackedLocalFile()); }
Example #6
Source File: MockResolver.java From ant-ivy with Apache License 2.0 | 5 votes |
public DownloadReport download(Artifact[] artifacts, DownloadOptions options) { DownloadReport dr = new DownloadReport(); for (Artifact artifact : artifacts) { dr.addArtifactReport(new ArtifactDownloadReport(artifact)); } return dr; }
Example #7
Source File: FileSystemResolverTest.java From ant-ivy with Apache License 2.0 | 5 votes |
@Test public void testDownloadWithUseOriginIsTrue() throws Exception { FileSystemResolver resolver = new FileSystemResolver(); resolver.setName("test"); resolver.setSettings(settings); ((DefaultRepositoryCacheManager) resolver.getRepositoryCacheManager()).setUseOrigin(true); assertEquals("test", resolver.getName()); resolver.addIvyPattern(IVY_PATTERN); resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/1/" + "[organisation]/[module]/[type]s/[artifact]-[revision].[type]"); ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "1.0"); ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data); assertNotNull(rmr); assertEquals(mrid, rmr.getId()); Date pubdate = new GregorianCalendar(2004, 10, 1, 11, 0, 0).getTime(); assertEquals(pubdate, rmr.getPublicationDate()); // test to ask to download DefaultArtifact artifact = new DefaultArtifact(mrid, pubdate, "mod1.1", "jar", "jar"); DownloadReport report = resolver.download(new Artifact[] {artifact}, getDownloadOptions()); assertNotNull(report); assertEquals(1, report.getArtifactsReports().length); ArtifactDownloadReport ar = report.getArtifactReport(artifact); assertNotNull(ar); assertEquals(artifact, ar.getArtifact()); assertEquals(DownloadStatus.NO, ar.getDownloadStatus()); }
Example #8
Source File: BintrayResolverTest.java From ant-ivy with Apache License 2.0 | 5 votes |
@Test public void testBintray() throws Exception { BintrayResolver resolver = new BintrayResolver(); resolver.setSettings(settings); ModuleRevisionId mrid = ModuleRevisionId .newInstance("org.apache.ant", "ant-antunit", "1.2"); ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data); assertNotNull(rmr); assertEquals(mrid, rmr.getId()); DefaultArtifact artifact = new DefaultArtifact(mrid, rmr.getPublicationDate(), "ant-antunit", "jar", "jar"); DownloadReport report = resolver.download(new Artifact[] {artifact}, downloadOptions()); assertNotNull(report); assertEquals(1, report.getArtifactsReports().length); ArtifactDownloadReport ar = report.getArtifactReport(artifact); assertNotNull(ar); assertEquals(artifact, ar.getArtifact()); assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus()); // test to ask to download again, should use cache report = resolver.download(new Artifact[] {artifact}, downloadOptions()); assertNotNull(report); assertEquals(1, report.getArtifactsReports().length); ar = report.getArtifactReport(artifact); assertNotNull(ar); assertEquals(artifact, ar.getArtifact()); assertEquals(DownloadStatus.NO, ar.getDownloadStatus()); }
Example #9
Source File: URLResolverTest.java From ant-ivy with Apache License 2.0 | 5 votes |
@Test public void testDownloadWithUseOriginIsTrue() throws Exception { URLResolver resolver = new URLResolver(); resolver.setSettings(settings); String rootpath = new File("test/repositories/1").toURI().toURL().toExternalForm(); resolver.addIvyPattern(rootpath + "/[organisation]/[module]/ivys/ivy-[revision].xml"); resolver.addArtifactPattern(rootpath + "/[organisation]/[module]/[type]s/[artifact]-[revision].[type]"); resolver.setName("test"); ((DefaultRepositoryCacheManager) resolver.getRepositoryCacheManager()).setUseOrigin(true); assertEquals("test", resolver.getName()); ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "1.0"); ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data); assertNotNull(rmr); assertEquals(mrid, rmr.getId()); Date pubdate = new GregorianCalendar(2004, 10, 1, 11, 0, 0).getTime(); assertEquals(pubdate, rmr.getPublicationDate()); // test to ask to download DefaultArtifact artifact = new DefaultArtifact(mrid, pubdate, "mod1.1", "jar", "jar"); DownloadReport report = resolver.download(new Artifact[] {artifact}, new DownloadOptions()); assertNotNull(report); assertEquals(1, report.getArtifactsReports().length); ArtifactDownloadReport ar = report.getArtifactReport(artifact); assertNotNull(ar); assertEquals(artifact, ar.getArtifact()); assertEquals(DownloadStatus.NO, ar.getDownloadStatus()); }
Example #10
Source File: ChainResolverTest.java From ant-ivy with Apache License 2.0 | 5 votes |
@Test public void testDownloadWithDual() { ChainResolver chain = new ChainResolver(); chain.setName("chain"); chain.setSettings(settings); chain.setDual(true); // first resolver has only an artifact pattern which don't lead to anything: it won't find // the module FileSystemResolver resolver = new FileSystemResolver(); resolver.setName("1"); resolver.setSettings(settings); resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/nowhere/[organisation]/[module]/[type]s/[artifact]-[revision].[type]"); chain.add(resolver); resolver = new FileSystemResolver(); resolver.setName("2"); resolver.setSettings(settings); resolver.addIvyPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/ivys/ivy-[revision].xml"); resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/[type]s/[artifact]-[revision].[type]"); chain.add(resolver); settings.addResolver(chain); MockMessageLogger mockLogger = new MockMessageLogger(); IvyContext.getContext().getIvy().getLoggerEngine().setDefaultLogger(mockLogger); DownloadReport report = chain.download( new Artifact[] {new DefaultArtifact(ModuleRevisionId.parse("org1#mod1.1;1.0"), new Date(), "mod1.1", "jar", "jar")}, new DownloadOptions()); assertNotNull(report); assertEquals(1, report.getArtifactsReports().length); assertEquals(DownloadStatus.SUCCESSFUL, report.getArtifactsReports()[0].getDownloadStatus()); mockLogger.assertLogDoesntContain("[FAILED ] org1#mod1.1;1.0!mod1.1.jar"); }
Example #11
Source File: AggregatedOSGiResolverTest.java From ant-ivy with Apache License 2.0 | 5 votes |
private void genericTestResolveDownload(DependencyResolver resolver, ModuleRevisionId mrid) throws ParseException { ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data); assertNotNull(rmr); assertEquals(mrid, rmr.getId()); Artifact artifact = rmr.getDescriptor().getAllArtifacts()[0]; DownloadReport report = resolver.download(new Artifact[] {artifact}, new DownloadOptions()); assertNotNull(report); assertEquals(1, report.getArtifactsReports().length); ArtifactDownloadReport ar = report.getArtifactReport(artifact); assertNotNull(ar); assertEquals(artifact, ar.getArtifact()); assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus()); // test to ask to download again, should use cache report = resolver.download(new Artifact[] {artifact}, new DownloadOptions()); assertNotNull(report); assertEquals(1, report.getArtifactsReports().length); ar = report.getArtifactReport(artifact); assertNotNull(ar); assertEquals(artifact, ar.getArtifact()); assertEquals(DownloadStatus.NO, ar.getDownloadStatus()); }
Example #12
Source File: OBRResolverTest.java From ant-ivy with Apache License 2.0 | 5 votes |
private void genericTestResolveDownload(DependencyResolver resolver, ModuleRevisionId mrid) throws ParseException { ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data); assertNotNull(rmr); assertEquals(mrid, rmr.getId()); Artifact artifact = rmr.getDescriptor().getAllArtifacts()[0]; DownloadReport report = resolver.download(new Artifact[] {artifact}, new DownloadOptions()); assertNotNull(report); assertEquals(1, report.getArtifactsReports().length); ArtifactDownloadReport ar = report.getArtifactReport(artifact); assertNotNull(ar); assertEquals(artifact, ar.getArtifact()); assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus()); // test to ask to download again, should use cache report = resolver.download(new Artifact[] {artifact}, new DownloadOptions()); assertNotNull(report); assertEquals(1, report.getArtifactsReports().length); ar = report.getArtifactReport(artifact); assertNotNull(ar); assertEquals(artifact, ar.getArtifact()); assertEquals(DownloadStatus.NO, ar.getDownloadStatus()); }
Example #13
Source File: UpdateSiteResolverTest.java From ant-ivy with Apache License 2.0 | 5 votes |
private void genericTestResolveDownload(DependencyResolver resolver, ModuleRevisionId mrid) throws ParseException { ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data); assertNotNull(rmr); assertEquals(mrid, rmr.getId()); Artifact artifact = rmr.getDescriptor().getAllArtifacts()[0]; DownloadReport report = resolver.download(new Artifact[] {artifact}, new DownloadOptions()); assertNotNull(report); assertEquals(1, report.getArtifactsReports().length); ArtifactDownloadReport ar = report.getArtifactReport(artifact); assertNotNull(ar); assertEquals(artifact, ar.getArtifact()); assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus()); // test to ask to download again, should use cache report = resolver.download(new Artifact[] {artifact}, new DownloadOptions()); assertNotNull(report); assertEquals(1, report.getArtifactsReports().length); ar = report.getArtifactReport(artifact); assertNotNull(ar); assertEquals(artifact, ar.getArtifact()); assertEquals(DownloadStatus.NO, ar.getDownloadStatus()); }
Example #14
Source File: P2DescriptorTest.java From ant-ivy with Apache License 2.0 | 5 votes |
@Test public void testResolvePacked() throws Exception { settings.setDefaultResolver("p2-with-packed"); ModuleRevisionId mrid = ModuleRevisionId.newInstance(BundleInfo.BUNDLE_TYPE, "org.junit", "4.10.0.v4_10_0_v20120426-0900"); ResolvedModuleRevision rmr = p2WithPackedResolver.getDependency( new DefaultDependencyDescriptor(mrid, false), data); assertNotNull(rmr); assertEquals(mrid, rmr.getId()); assertEquals(1, rmr.getDescriptor().getAllArtifacts().length); DownloadOptions options = new DownloadOptions(); DownloadReport report = p2WithPackedResolver.download( rmr.getDescriptor().getAllArtifacts(), options); assertNotNull(report); assertEquals(1, report.getArtifactsReports().length); Artifact artifact = rmr.getDescriptor().getAllArtifacts()[0]; ArtifactDownloadReport ar = report.getArtifactReport(artifact); assertNotNull(ar); assertEquals(artifact, ar.getArtifact()); assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus()); assertNotNull(ar.getUnpackedLocalFile()); }
Example #15
Source File: P2DescriptorTest.java From ant-ivy with Apache License 2.0 | 5 votes |
@Test public void testResolveZipped() throws Exception { settings.setDefaultResolver("p2-zipped"); ModuleRevisionId mrid = ModuleRevisionId.newInstance(BundleInfo.BUNDLE_TYPE, "org.apache.ant", "1.8.3.v20120321-1730"); ResolvedModuleRevision rmr = p2ZippedResolver.getDependency( new DefaultDependencyDescriptor(mrid, false), data); assertNotNull(rmr); assertEquals(mrid, rmr.getId()); assertEquals(2, rmr.getDescriptor().getAllArtifacts().length); DownloadOptions options = new DownloadOptions(); DownloadReport report = p2ZippedResolver.download(rmr.getDescriptor().getAllArtifacts(), options); assertNotNull(report); assertEquals(2, report.getArtifactsReports().length); for (int i = 0; i < 2; i++) { Artifact artifact = rmr.getDescriptor().getAllArtifacts()[i]; ArtifactDownloadReport ar = report.getArtifactReport(artifact); assertNotNull(ar); assertEquals(artifact, ar.getArtifact()); assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus()); // only the binary get unpacked if (ar.getArtifact().getType().equals("source")) { assertNull(ar.getUnpackedLocalFile()); } else { assertNotNull(ar.getUnpackedLocalFile()); } } }
Example #16
Source File: RepositoryResolver.java From ant-ivy with Apache License 2.0 | 5 votes |
@Override public DownloadReport download(Artifact[] artifacts, DownloadOptions options) { EventManager eventManager = getEventManager(); try { if (eventManager != null) { repository.addTransferListener(eventManager); } return super.download(artifacts, options); } finally { if (eventManager != null) { repository.removeTransferListener(eventManager); } } }
Example #17
Source File: AbstractResolver.java From ant-ivy with Apache License 2.0 | 5 votes |
/** * Default implementation actually download the artifact Subclasses should overwrite this to * avoid the download * * @param artifact ArtifactOrigin * @return ArtifactOrigin */ public ArtifactOrigin locate(Artifact artifact) { DownloadReport dr = download(new Artifact[] {artifact}, new DownloadOptions()); if (dr == null) { /* * according to IVY-831, it seems that this actually happen sometime, while the * contract of DependencyResolver says that it should never return null */ throw new IllegalStateException("null download report returned by " + getName() + " (" + getClass().getName() + ")" + " when trying to download " + artifact); } ArtifactDownloadReport adr = dr.getArtifactReport(artifact); return adr.getDownloadStatus() == DownloadStatus.FAILED ? null : adr.getArtifactOrigin(); }
Example #18
Source File: URLResolverTest.java From ant-ivy with Apache License 2.0 | 4 votes |
@Test public void testFile() throws Exception { URLResolver resolver = new URLResolver(); resolver.setSettings(settings); String rootpath = new File("test/repositories/1").toURI().toURL().toExternalForm(); resolver.addIvyPattern(rootpath + "/[organisation]/[module]/ivys/ivy-[revision].xml"); resolver.addArtifactPattern(rootpath + "/[organisation]/[module]/[type]s/[artifact]-[revision].[type]"); resolver.setName("test"); assertEquals("test", resolver.getName()); ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "1.0"); ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data); assertNotNull(rmr); assertEquals(mrid, rmr.getId()); Date pubdate = new GregorianCalendar(2004, 10, 1, 11, 0, 0).getTime(); assertEquals(pubdate, rmr.getPublicationDate()); // test to ask to download DefaultArtifact artifact = new DefaultArtifact(mrid, pubdate, "mod1.1", "jar", "jar"); DownloadReport report = resolver.download(new Artifact[] {artifact}, downloadOptions()); assertNotNull(report); assertEquals(1, report.getArtifactsReports().length); ArtifactDownloadReport ar = report.getArtifactReport(artifact); assertNotNull(ar); assertEquals(artifact, ar.getArtifact()); assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus()); // test to ask to download again, should use cache report = resolver.download(new Artifact[] {artifact}, downloadOptions()); assertNotNull(report); assertEquals(1, report.getArtifactsReports().length); ar = report.getArtifactReport(artifact); assertNotNull(ar); assertEquals(artifact, ar.getArtifact()); assertEquals(DownloadStatus.NO, ar.getDownloadStatus()); }
Example #19
Source File: LoopbackDependencyResolver.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public DownloadReport download(Artifact[] artifacts, DownloadOptions options) { throw new UnsupportedOperationException(); }
Example #20
Source File: LegacyDependencyResolver.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public DownloadReport download(Artifact[] artifacts, DownloadOptions options) { // This is never used throw new UnsupportedOperationException(); }
Example #21
Source File: AbstractMavenResolver.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public DownloadReport download(Artifact[] artifacts, DownloadOptions options) { throw new UnsupportedOperationException("A Maven deployer cannot be used to resolve dependencies. It can only be used to publish artifacts."); }
Example #22
Source File: LoopbackDependencyResolver.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public DownloadReport download(Artifact[] artifacts, DownloadOptions options) { throw new UnsupportedOperationException(); }
Example #23
Source File: FileSystemResolverTest.java From ant-ivy with Apache License 2.0 | 4 votes |
@Test public void testChecksum() throws Exception { FileSystemResolver resolver = new FileSystemResolver(); resolver.setName("test"); resolver.setSettings(settings); resolver.addIvyPattern(settings.getBaseDir() + "/test/repositories/checksums/[module]/[artifact]-[revision].[ext]"); resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/checksums/[module]/[artifact]-[revision].[ext]"); resolver.setChecksums("sha1, md5"); ModuleRevisionId mrid = ModuleRevisionId.newInstance("test", "allright", "1.0"); ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data); assertNotNull("Resolver could not get dependency " + mrid, rmr); DownloadReport dr = resolver.download(rmr.getDescriptor().getAllArtifacts(), getDownloadOptions()); assertEquals(4, dr.getArtifactsReports(DownloadStatus.SUCCESSFUL).length); resolver.setChecksums("md5"); mrid = ModuleRevisionId.newInstance("test", "badivycs", "1.0"); rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data); assertNull(rmr); resolver.setChecksums("none"); rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data); assertNotNull(rmr); dr = resolver.download(new Artifact[] {new DefaultArtifact(mrid, rmr.getPublicationDate(), mrid.getName(), "jar", "jar")}, getDownloadOptions()); assertEquals(1, dr.getArtifactsReports(DownloadStatus.SUCCESSFUL).length); resolver.setChecksums("md5"); mrid = ModuleRevisionId.newInstance("test", "badartcs", "1.0"); rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data); assertNotNull("Could not get dependency " + mrid, rmr); dr = resolver.download(new Artifact[] {new DefaultArtifact(mrid, rmr.getPublicationDate(), mrid.getName(), "jar", "jar")}, getDownloadOptions()); assertEquals(1, dr.getArtifactsReports(DownloadStatus.FAILED).length); resolver.setChecksums(""); rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data); assertNotNull(rmr); dr = resolver.download(new Artifact[] {new DefaultArtifact(mrid, rmr.getPublicationDate(), mrid.getName(), "jar", "jar")}, getDownloadOptions()); assertEquals(1, dr.getArtifactsReports(DownloadStatus.SUCCESSFUL).length); }
Example #24
Source File: FileSystemResolverTest.java From ant-ivy with Apache License 2.0 | 4 votes |
@Test public void testFixedRevision() throws Exception { FileSystemResolver resolver = new FileSystemResolver(); resolver.setName("test"); resolver.setSettings(settings); assertEquals("test", resolver.getName()); resolver.addIvyPattern(IVY_PATTERN); resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/[type]s/[artifact]-[revision].[type]"); ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "1.0"); ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data); assertNotNull(rmr); assertEquals(mrid, rmr.getId()); Date pubdate = new GregorianCalendar(2004, 10, 1, 11, 0, 0).getTime(); assertEquals(pubdate, rmr.getPublicationDate()); // test to ask to download DefaultArtifact artifact = new DefaultArtifact(mrid, pubdate, "mod1.1", "jar", "jar"); DownloadReport report = resolver.download(new Artifact[] {artifact}, getDownloadOptions()); assertNotNull(report); assertEquals(1, report.getArtifactsReports().length); ArtifactDownloadReport ar = report.getArtifactReport(artifact); assertNotNull(ar); assertEquals(artifact, ar.getArtifact()); assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus()); // test to ask to download again, should use cache report = resolver.download(new Artifact[] {artifact}, getDownloadOptions()); assertNotNull(report); assertEquals(1, report.getArtifactsReports().length); ar = report.getArtifactReport(artifact); assertNotNull(ar); assertEquals(artifact, ar.getArtifact()); assertEquals(DownloadStatus.NO, ar.getDownloadStatus()); }
Example #25
Source File: PackagerResolverTest.java From ant-ivy with Apache License 2.0 | 4 votes |
@Test public void testFile() 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/packager/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/packager/website").toURI().toURL().toExternalForm()); resolver.setName("packager"); assertEquals("packager", resolver.getName()); // Get module descriptor ModuleRevisionId mrid = ModuleRevisionId.newInstance("org", "mod", "1.0"); ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor( mrid, false), data); assertNotNull(rmr); assertEquals(mrid, rmr.getId()); Date pubdate = new GregorianCalendar(2004, 10, 1, 11, 0, 0).getTime(); assertEquals(pubdate, rmr.getPublicationDate()); // Download artifact Artifact artifact = new DefaultArtifact(mrid, pubdate, "mod", "jar", "jar"); DownloadReport report = resolver.download(new Artifact[] {artifact}, downloadOptions()); assertNotNull(report); assertEquals(1, report.getArtifactsReports().length); ArtifactDownloadReport ar = report.getArtifactReport(artifact); System.out.println("download details: " + ar.getDownloadDetails()); assertNotNull(ar); assertEquals(artifact, ar.getArtifact()); assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus()); // Verify resource cache now contains the distribution archive assertTrue(new File(cachedir, "mod-1.0.tar.gz").exists()); // Download again, should use Ivy cache this time report = resolver.download(new Artifact[] {artifact}, downloadOptions()); assertNotNull(report); assertEquals(1, report.getArtifactsReports().length); ar = report.getArtifactReport(artifact); assertNotNull(ar); assertEquals(artifact, ar.getArtifact()); assertEquals(DownloadStatus.NO, ar.getDownloadStatus()); // Now download the maven2 artifact artifact = DefaultArtifact.cloneWithAnotherName(artifact, "foobar-janfu"); report = resolver.download(new Artifact[] {artifact}, downloadOptions()); assertNotNull(report); assertEquals(1, report.getArtifactsReports().length); ar = report.getArtifactReport(artifact); assertNotNull(ar); assertEquals(artifact, ar.getArtifact()); assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus()); } finally { Locale.setDefault(oldLocale); } }
Example #26
Source File: BintrayResolverTest.java From ant-ivy with Apache License 2.0 | 4 votes |
@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()); }
Example #27
Source File: LegacyDependencyResolver.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public DownloadReport download(Artifact[] artifacts, DownloadOptions options) { // This is never used throw new UnsupportedOperationException(); }
Example #28
Source File: ResolveEngine.java From ant-ivy with Apache License 2.0 | 4 votes |
public void downloadArtifacts(ResolveReport report, Filter<Artifact> artifactFilter, DownloadOptions options) { long start = System.currentTimeMillis(); eventManager.fireIvyEvent(new PrepareDownloadEvent(report.getArtifacts().toArray( new Artifact[report.getArtifacts().size()]))); long totalSize = 0; for (IvyNode dependency : report.getDependencies()) { checkInterrupted(); // download artifacts required in all asked configurations if (!dependency.isCompletelyEvicted() && !dependency.hasProblem() && dependency.getModuleRevision() != null) { DependencyResolver resolver = dependency.getModuleRevision() .getArtifactResolver(); Artifact[] selectedArtifacts = dependency.getSelectedArtifacts(artifactFilter); DownloadReport dReport = resolver.download(selectedArtifacts, options); for (ArtifactDownloadReport adr : dReport.getArtifactsReports()) { if (adr.getDownloadStatus() == DownloadStatus.FAILED) { if (adr.getArtifact().getExtraAttribute("ivy:merged") != null) { Message.warn("\tmerged artifact not found: " + adr.getArtifact() + ". It was required in " + adr.getArtifact().getExtraAttribute("ivy:merged")); } else { Message.warn("\t" + adr); resolver.reportFailure(adr.getArtifact()); } } else if (adr.getDownloadStatus() == DownloadStatus.SUCCESSFUL) { totalSize += adr.getSize(); } } // update concerned reports for (String dconf : dependency.getRootModuleConfigurations()) { // the report itself is responsible to take into account only // artifacts required in its corresponding configuration // (as described by the Dependency object) if (dependency.isEvicted(dconf) || dependency.isBlacklisted(dconf)) { report.getConfigurationReport(dconf).addDependency(dependency); } else { report.getConfigurationReport(dconf).addDependency(dependency, dReport); } } } } report.setDownloadTime(System.currentTimeMillis() - start); report.setDownloadSize(totalSize); }
Example #29
Source File: IvyRepResolverTest.java From ant-ivy with Apache License 2.0 | 4 votes |
@Test public void testIvyRepWithLocalURL() throws Exception { IvyRepResolver resolver = new IvyRepResolver(); String rootpath = new File("test/repositories/1").getAbsolutePath(); resolver.setName("testLocal"); resolver.setIvyroot("file:" + rootpath); resolver.setIvypattern("[organisation]/[module]/ivys/ivy-[revision].xml"); resolver.setArtroot("file:" + rootpath); resolver.setArtpattern("[organisation]/[module]/jars/[artifact]-[revision].[ext]"); resolver.setSettings(settings); ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "1.0"); ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data); assertNotNull(rmr); DefaultArtifact artifact = new DefaultArtifact(mrid, rmr.getPublicationDate(), "mod1.1", "jar", "jar"); DownloadReport report = resolver.download(new Artifact[] {artifact}, downloadOptions()); assertNotNull(report); assertEquals(1, report.getArtifactsReports().length); ArtifactDownloadReport ar = report.getArtifactReport(artifact); assertNotNull(ar); assertEquals(artifact, ar.getArtifact()); assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus()); // test to ask to download again, should use cache report = resolver.download(new Artifact[] {artifact}, downloadOptions()); assertNotNull(report); assertEquals(1, report.getArtifactsReports().length); ar = report.getArtifactReport(artifact); assertNotNull(ar); assertEquals(artifact, ar.getArtifact()); assertEquals(DownloadStatus.NO, ar.getDownloadStatus()); }
Example #30
Source File: IvyRepResolver.java From ant-ivy with Apache License 2.0 | 4 votes |
@Override public DownloadReport download(Artifact[] artifacts, DownloadOptions options) { ensureArtifactConfigured(getSettings()); return super.download(artifacts, options); }