org.apache.ivy.core.report.DownloadStatus Java Examples
The following examples show how to use
org.apache.ivy.core.report.DownloadStatus.
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: 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 #2
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 #3
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 #4
Source File: AntBuildResolverTest.java From ant-ivy with Apache License 2.0 | 6 votes |
@Test public void testProject() throws Exception { IvyResolve resolve = new IvyResolve(); resolve.setProject(project); resolve.setFile(new File("test/workspace/project2/ivy.xml")); resolve.setKeep(true); resolve.execute(); ResolveReport report = project.getReference("ivy.resolved.report"); assertEquals(2, report.getDependencies().size()); assertEquals(MRID_PROJECT1, report.getDependencies().get(0).getResolvedId()); assertEquals(MRID_MODULE1, report.getDependencies().get(1).getResolvedId()); assertEquals(1, report.getArtifactsReports(MRID_PROJECT1).length); assertEquals(DownloadStatus.NO, report.getArtifactsReports(MRID_PROJECT1)[0].getDownloadStatus()); assertEquals(new File("test/workspace/project1/target/dist/jars/project1.jar").toURI() .toURL(), report.getArtifactsReports(MRID_PROJECT1)[0].getArtifact().getUrl()); assertEquals( new File("test/workspace/project1/target/dist/jars/project1.jar").getAbsoluteFile(), report.getArtifactsReports(MRID_PROJECT1)[0].getLocalFile()); }
Example #5
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 #6
Source File: AntBuildResolverTest.java From ant-ivy with Apache License 2.0 | 6 votes |
@Test public void testProjectFolder() throws Exception { wa.setPath("target/classes"); IvyResolve resolve = new IvyResolve(); resolve.setProject(project); resolve.setFile(new File("test/workspace/project2/ivy.xml")); resolve.setKeep(true); resolve.execute(); ResolveReport report = project.getReference("ivy.resolved.report"); assertEquals(2, report.getDependencies().size()); assertEquals(MRID_PROJECT1, report.getDependencies().get(0).getResolvedId()); assertEquals(MRID_MODULE1, report.getDependencies().get(1).getResolvedId()); assertEquals(1, report.getArtifactsReports(MRID_PROJECT1).length); assertEquals(DownloadStatus.NO, report.getArtifactsReports(MRID_PROJECT1)[0].getDownloadStatus()); assertEquals(new File("test/workspace/project1/target/classes").toURI().toURL(), report.getArtifactsReports(MRID_PROJECT1)[0].getArtifact().getUrl()); assertEquals(new File("test/workspace/project1/target/classes").getAbsoluteFile(), report.getArtifactsReports(MRID_PROJECT1)[0].getLocalFile()); }
Example #7
Source File: AntBuildResolverTest.java From ant-ivy with Apache License 2.0 | 6 votes |
@Test public void testDependencyArtifact() throws Exception { IvyResolve resolve = new IvyResolve(); resolve.setProject(project); resolve.setFile(new File("test/workspace/project3/ivy.xml")); resolve.setKeep(true); resolve.execute(); ResolveReport report = project.getReference("ivy.resolved.report"); assertEquals(2, report.getDependencies().size()); assertEquals(MRID_PROJECT1, report.getDependencies().get(0).getResolvedId()); assertEquals(MRID_MODULE1, report.getDependencies().get(1).getResolvedId()); assertEquals(1, report.getArtifactsReports(MRID_PROJECT1).length); assertEquals(DownloadStatus.NO, report.getArtifactsReports(MRID_PROJECT1)[0].getDownloadStatus()); assertEquals(new File("test/workspace/project1/target/dist/jars/project1.jar").toURI() .toURL(), report.getArtifactsReports(MRID_PROJECT1)[0].getArtifact().getUrl()); assertEquals( new File("test/workspace/project1/target/dist/jars/project1.jar").getAbsoluteFile(), report.getArtifactsReports(MRID_PROJECT1)[0].getLocalFile()); }
Example #8
Source File: DefaultRepositoryCacheManager.java From ant-ivy with Apache License 2.0 | 6 votes |
private void unpackArtifact(Artifact artifact, ArtifactDownloadReport adr, CacheDownloadOptions options) { Artifact unpacked = packagingManager.getUnpackedArtifact(artifact); if (unpacked == null) { // nothing to unpack return; } File archiveFile = getArchiveFileInCache(unpacked, null, false); if (archiveFile.exists() && !options.isForce()) { adr.setUnpackedLocalFile(archiveFile); adr.setUnpackedArtifact(unpacked); } else { Message.info("\tUnpacking " + artifact.getId()); try { final Artifact unpackedArtifact = packagingManager.unpackArtifact(artifact, adr.getLocalFile(), archiveFile); adr.setUnpackedLocalFile(archiveFile); adr.setUnpackedArtifact(unpackedArtifact); } catch (Exception e) { Message.debug(e); adr.setDownloadStatus(DownloadStatus.FAILED); adr.setDownloadDetails("The packed artifact " + artifact.getId() + " could not be unpacked (" + e.getMessage() + ")"); } } }
Example #9
Source File: UpdateSiteLoader.java From ant-ivy with Apache License 2.0 | 6 votes |
private UpdateSiteDescriptor loadFromSite(UpdateSite site) throws IOException, SAXException { UpdateSiteDescriptor repoDescriptor = new UpdateSiteDescriptor(site.getUri(), ExecutionEnvironmentProfileProvider.getInstance()); for (EclipseFeature feature : site.getFeatures()) { URL url = site.getUri().resolve(feature.getUrl()).toURL(); final URLResource res = new URLResource(url, this.timeoutConstraint); ArtifactDownloadReport report = repositoryCacheManager.downloadRepositoryResource(res, feature.getId(), "feature", "jar", options, urlRepository); if (report.getDownloadStatus() == DownloadStatus.FAILED) { return null; } try (InputStream in = new FileInputStream(report.getLocalFile())) { ZipInputStream zipped = findEntry(in, "feature.xml"); if (zipped == null) { return null; } EclipseFeature f = FeatureParser.parse(zipped); f.setURL(feature.getUrl()); repoDescriptor.addFeature(f); } } return repoDescriptor; }
Example #10
Source File: UpdateSiteLoader.java From ant-ivy with Apache License 2.0 | 6 votes |
private UpdateSite loadSite(URI repoUri) throws IOException, SAXException { URI siteUri = normalizeSiteUri(repoUri, null); URL u = siteUri.resolve("site.xml").toURL(); final URLResource res = new URLResource(u, this.timeoutConstraint); ArtifactDownloadReport report = repositoryCacheManager.downloadRepositoryResource(res, "site", "updatesite", "xml", options, urlRepository); if (report.getDownloadStatus() == DownloadStatus.FAILED) { return null; } try (InputStream in = new FileInputStream(report.getLocalFile())) { UpdateSite site = EclipseUpdateSiteParser.parse(in); site.setUri(normalizeSiteUri(site.getUri(), siteUri)); return site; } }
Example #11
Source File: UpdateSiteLoader.java From ant-ivy with Apache License 2.0 | 6 votes |
private UpdateSiteDescriptor loadFromDigest(UpdateSite site) throws IOException, SAXException { URI digestBaseUri = site.getDigestUri(); if (digestBaseUri == null) { digestBaseUri = site.getUri(); } else if (!digestBaseUri.isAbsolute()) { digestBaseUri = site.getUri().resolve(digestBaseUri); } URL digest = digestBaseUri.resolve("digest.zip").toURL(); Message.verbose("\tReading " + digest); final URLResource res = new URLResource(digest, this.timeoutConstraint); ArtifactDownloadReport report = repositoryCacheManager.downloadRepositoryResource(res, "digest", "digest", "zip", options, urlRepository); if (report.getDownloadStatus() == DownloadStatus.FAILED) { return null; } try (InputStream in = new FileInputStream(report.getLocalFile())) { ZipInputStream zipped = findEntry(in, "digest.xml"); if (zipped == null) { return null; } return UpdateSiteDigestParser.parse(zipped, site); } }
Example #12
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 #13
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 #14
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 #15
Source File: JarResolver.java From ant-ivy with Apache License 2.0 | 5 votes |
@Override public void setSettings(ResolverSettings settings) { super.setSettings(settings); if (url == null) { return; } // let's resolve the url ArtifactDownloadReport report; EventManager eventManager = getEventManager(); try { if (eventManager != null) { getRepository().addTransferListener(eventManager); } Resource jarResource = new URLResource(url, this.getTimeoutConstraint()); CacheResourceOptions options = new CacheResourceOptions(); report = getRepositoryCacheManager().downloadRepositoryResource(jarResource, "jarrepository", "jar", "jar", options, new URLRepository()); } finally { if (eventManager != null) { getRepository().removeTransferListener(eventManager); } } if (report.getDownloadStatus() == DownloadStatus.FAILED) { throw new RuntimeException("The jar file " + url.toExternalForm() + " could not be downloaded (" + report.getDownloadDetails() + ")"); } setJarFile(report.getLocalFile()); }
Example #16
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 #17
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 #18
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 #19
Source File: ResolveEngineTest.java From ant-ivy with Apache License 2.0 | 5 votes |
private void testLocateThenDownload(ResolveEngine engine, Artifact artifact, File artifactFile) { ArtifactOrigin origin = engine.locate(artifact); assertNotNull(origin); assertTrue(origin.isLocal()); assertEquals(artifactFile.getAbsolutePath(), new File(origin.getLocation()).getAbsolutePath()); ArtifactDownloadReport r = engine.download(origin, new DownloadOptions()); assertNotNull(r); assertEquals(DownloadStatus.SUCCESSFUL, r.getDownloadStatus()); assertNotNull(r.getLocalFile()); assertTrue(r.getLocalFile().exists()); }
Example #20
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 #21
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 #22
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 #23
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 #24
Source File: BasicResolver.java From ant-ivy with Apache License 2.0 | 5 votes |
protected ResourceMDParser getDefaultRMDParser(final ModuleId mid) { return new ResourceMDParser() { public MDResolvedResource parse(Resource resource, String rev) { DefaultModuleDescriptor md = DefaultModuleDescriptor .newDefaultInstance(new ModuleRevisionId(mid, rev)); MetadataArtifactDownloadReport madr = new MetadataArtifactDownloadReport( md.getMetadataArtifact()); madr.setDownloadStatus(DownloadStatus.NO); madr.setSearched(true); return new MDResolvedResource(resource, rev, new ResolvedModuleRevision( BasicResolver.this, BasicResolver.this, md, madr, isForce())); } }; }
Example #25
Source File: XmlReportParser.java From ant-ivy with Apache License 2.0 | 5 votes |
public void endElement(String uri, String localName, String qname) throws SAXException { if ("dependencies".equals(qname)) { // add the artifacts in the correct order for (List<ArtifactDownloadReport> artifactReports : revisionsMap.values()) { SaxXmlReportParser.this.artifactReports.addAll(artifactReports); for (ArtifactDownloadReport artifactReport : artifactReports) { if (artifactReport.getDownloadStatus() != DownloadStatus.FAILED) { artifacts.add(artifactReport.getArtifact()); } } } } }
Example #26
Source File: DownloadingRepositoryCacheManager.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public ResolvedModuleRevision cacheModuleDescriptor(DependencyResolver resolver, final ResolvedResource resolvedResource, DependencyDescriptor dd, Artifact moduleArtifact, ResourceDownloader downloader, CacheMetadataOptions options) throws ParseException { if (!moduleArtifact.isMetadata()) { return null; } ArtifactResourceResolver artifactResourceResolver = new ArtifactResourceResolver() { public ResolvedResource resolve(Artifact artifact) { return resolvedResource; } }; ArtifactDownloadReport report = download(moduleArtifact, artifactResourceResolver, downloader, new CacheDownloadOptions().setListener(options.getListener()).setForce(true)); if (report.getDownloadStatus() == DownloadStatus.FAILED) { LOGGER.warn("problem while downloading module descriptor: {}: {} ({} ms)", resolvedResource.getResource(), report.getDownloadDetails(), report.getDownloadTimeMillis()); return null; } ModuleDescriptor md = parseModuleDescriptor(resolver, moduleArtifact, options, report.getLocalFile(), resolvedResource.getResource()); LOGGER.debug("\t{}: parsed downloaded md file for {}; parsed={}" + getName(), moduleArtifact.getModuleRevisionId(), md.getModuleRevisionId()); MetadataArtifactDownloadReport madr = new MetadataArtifactDownloadReport(md.getMetadataArtifact()); madr.setSearched(true); madr.setDownloadStatus(report.getDownloadStatus()); madr.setDownloadDetails(report.getDownloadDetails()); madr.setArtifactOrigin(report.getArtifactOrigin()); madr.setDownloadTimeMillis(report.getDownloadTimeMillis()); madr.setOriginalLocalFile(report.getLocalFile()); madr.setSize(report.getSize()); return new ResolvedModuleRevision(resolver, resolver, md, madr); }
Example #27
Source File: AbstractOSGiResolver.java From ant-ivy with Apache License 2.0 | 5 votes |
private MDResolvedResource buildResolvedCapabilityMd(DependencyDescriptor dd, ModuleDescriptor md) { String org = dd.getDependencyRevisionId().getOrganisation(); String name = dd.getDependencyRevisionId().getName(); String rev = md.getExtraInfoContentByTagName(BundleInfoAdapter.EXTRA_INFO_EXPORT_PREFIX + name); ModuleRevisionId capabilityRev = ModuleRevisionId.newInstance(org, name, rev, Collections.singletonMap(CAPABILITY_EXTRA_ATTR, md.getModuleRevisionId().toString())); DefaultModuleDescriptor capabilityMd = new DefaultModuleDescriptor(capabilityRev, getSettings().getStatusManager().getDefaultStatus(), new Date()); String useConf = BundleInfoAdapter.CONF_USE_PREFIX + dd.getDependencyRevisionId().getName(); capabilityMd.addConfiguration(BundleInfoAdapter.CONF_DEFAULT); capabilityMd.addConfiguration(BundleInfoAdapter.CONF_OPTIONAL); capabilityMd.addConfiguration(BundleInfoAdapter.CONF_TRANSITIVE_OPTIONAL); capabilityMd.addConfiguration(new Configuration(useConf)); DefaultDependencyDescriptor capabilityDD = new DefaultDependencyDescriptor( md.getModuleRevisionId(), false); capabilityDD.addDependencyConfiguration(BundleInfoAdapter.CONF_NAME_DEFAULT, BundleInfoAdapter.CONF_NAME_DEFAULT); capabilityDD.addDependencyConfiguration(BundleInfoAdapter.CONF_NAME_OPTIONAL, BundleInfoAdapter.CONF_NAME_OPTIONAL); capabilityDD.addDependencyConfiguration(BundleInfoAdapter.CONF_NAME_TRANSITIVE_OPTIONAL, BundleInfoAdapter.CONF_NAME_TRANSITIVE_OPTIONAL); capabilityDD.addDependencyConfiguration(useConf, useConf); capabilityMd.addDependency(capabilityDD); MetadataArtifactDownloadReport report = new MetadataArtifactDownloadReport(null); report.setDownloadStatus(DownloadStatus.NO); report.setSearched(true); ResolvedModuleRevision rmr = new ResolvedModuleRevision(this, this, capabilityMd, report); return new MDResolvedResource(null, capabilityMd.getRevision(), rmr); }
Example #28
Source File: AbstractOSGiResolver.java From ant-ivy with Apache License 2.0 | 5 votes |
public ResolvedResource[] findBundle(DependencyDescriptor dd, ResolveData data, Collection<ModuleDescriptor> mds) { ResolvedResource[] ret = new ResolvedResource[mds.size()]; int i = 0; for (ModuleDescriptor md : mds) { MetadataArtifactDownloadReport report = new MetadataArtifactDownloadReport(null); report.setDownloadStatus(DownloadStatus.NO); report.setSearched(true); ResolvedModuleRevision rmr = new ResolvedModuleRevision(this, this, md, report); MDResolvedResource mdrr = new MDResolvedResource(null, md.getRevision(), rmr); ret[i++] = mdrr; } return ret; }
Example #29
Source File: DownloadingRepositoryCacheManager.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public ResolvedModuleRevision cacheModuleDescriptor(DependencyResolver resolver, final ResolvedResource resolvedResource, DependencyDescriptor dd, Artifact moduleArtifact, ResourceDownloader downloader, CacheMetadataOptions options) throws ParseException { if (!moduleArtifact.isMetadata()) { return null; } ArtifactResourceResolver artifactResourceResolver = new ArtifactResourceResolver() { public ResolvedResource resolve(Artifact artifact) { return resolvedResource; } }; ArtifactDownloadReport report = download(moduleArtifact, artifactResourceResolver, downloader, new CacheDownloadOptions().setListener(options.getListener()).setForce(true)); if (report.getDownloadStatus() == DownloadStatus.FAILED) { LOGGER.warn("problem while downloading module descriptor: {}: {} ({} ms)", resolvedResource.getResource(), report.getDownloadDetails(), report.getDownloadTimeMillis()); return null; } ModuleDescriptor md = parseModuleDescriptor(resolver, moduleArtifact, options, report.getLocalFile(), resolvedResource.getResource()); LOGGER.debug("\t{}: parsed downloaded md file for {}; parsed={}" + getName(), moduleArtifact.getModuleRevisionId(), md.getModuleRevisionId()); MetadataArtifactDownloadReport madr = new MetadataArtifactDownloadReport(md.getMetadataArtifact()); madr.setSearched(true); madr.setDownloadStatus(report.getDownloadStatus()); madr.setDownloadDetails(report.getDownloadDetails()); madr.setArtifactOrigin(report.getArtifactOrigin()); madr.setDownloadTimeMillis(report.getDownloadTimeMillis()); madr.setOriginalLocalFile(report.getLocalFile()); madr.setSize(report.getSize()); return new ResolvedModuleRevision(resolver, resolver, md, madr); }
Example #30
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(); }