Examples of ArtifactDownloadReport


Examples of org.apache.ivy.core.report.ArtifactDownloadReport

        // normal resolve, the file goes in the cache
        ResolveReport report = ivy.resolve(url, options);
        assertFalse(report.hasError());

        ArtifactDownloadReport adr = report.getAllArtifactsReports()[0];
        File cacheDir = ivy.getSettings().getDefaultRepositoryCacheBasedir();
        assertEquals(new File(cacheDir, "packaging/module2/jars/module2-1.0.jar"),
            adr.getLocalFile());
        assertEquals(new File(cacheDir, "packaging/module2/jar_unpackeds/module2-1.0"),
            adr.getUnpackedLocalFile());

        File[] jarContents = adr.getUnpackedLocalFile().listFiles();
        Arrays.sort(jarContents);
        assertEquals(new File(adr.getUnpackedLocalFile(), "META-INF"), jarContents[0]);
        assertEquals(new File(adr.getUnpackedLocalFile(), "test.txt"), jarContents[1]);
        assertEquals(new File(adr.getUnpackedLocalFile(), "META-INF/MANIFEST.MF"),
            jarContents[0].listFiles()[0]);
    }
View Full Code Here

Examples of org.apache.ivy.core.report.ArtifactDownloadReport

        }
        try {
            Path path = new Path(getProject());
            getProject().addReference(pathid, path);
            for (Iterator iter = getArtifactReports().iterator(); iter.hasNext();) {
                ArtifactDownloadReport a = (ArtifactDownloadReport) iter.next();
                File f = a.getLocalFile();
                if (a.getUnpackedLocalFile() != null) {
                    f = a.getUnpackedLocalFile();
                }
                addToPath(path, f);
            }
        } catch (Exception ex) {
            throw new BuildException("impossible to build ivy path: " + ex, ex);
View Full Code Here

Examples of org.apache.ivy.core.report.ArtifactDownloadReport

            DownloadReport report = resolver.download(new Artifact[] {artifact}, downloadOptions());
            assertNotNull(report);

            assertEquals(1, report.getArtifactsReports().length);

            ArtifactDownloadReport ar = report.getArtifactReport(artifact);
            System.out.println("downloaddetails: " + 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);
        }
    }
View Full Code Here

Examples of org.apache.ivy.core.report.ArtifactDownloadReport

    }

    public DownloadReport download(Artifact[] artifacts, DownloadOptions options) {
        DownloadReport dr = new DownloadReport();
        for (int i = 0; i < artifacts.length; i++) {
            dr.addArtifactReport(new ArtifactDownloadReport(artifacts[i]));
        }
        return dr;
    }
View Full Code Here

Examples of org.apache.ivy.core.report.ArtifactDownloadReport

        InputStream readIn = null; // the input stream from which the xml should be read

        URL contentUrl = repoUri.resolve(baseName + ".jar").toURL();
        URLResource res = new URLResource(contentUrl);

        ArtifactDownloadReport report = repositoryCacheManager.downloadRepositoryResource(res,
            baseName, baseName, "jar", options, urlRepository);

        if (report.getDownloadStatus() == DownloadStatus.FAILED) {
            // no jar file, try the xml one
            contentUrl = repoUri.resolve(baseName + ".xml").toURL();
            res = new URLResource(contentUrl);

            report = repositoryCacheManager.downloadRepositoryResource(res, baseName, baseName,
                "xml", options, urlRepository);

            if (report.getDownloadStatus() == DownloadStatus.FAILED) {
                // no xml either
                return false;
            }

            readIn = new FileInputStream(report.getLocalFile());
        } else {
            InputStream in = new FileInputStream(report.getLocalFile());

            try {
                // compressed, let's get the pointer on the actual xml
                readIn = findEntry(in, baseName + ".xml");
                if (readIn == null) {
View Full Code Here

Examples of org.apache.ivy.core.report.ArtifactDownloadReport

    private UpdateSite loadSite(URI repoUri) throws IOException, ParseException, SAXException {
        URI siteUri = normalizeSiteUri(repoUri, null);
        URL u = siteUri.resolve("site.xml").toURL();

        URLResource res = new URLResource(u);
        ArtifactDownloadReport report = repositoryCacheManager.downloadRepositoryResource(res,
            "site", "updatesite", "xml", options, urlRepository);
        if (report.getDownloadStatus() == DownloadStatus.FAILED) {
            return null;
        }
        InputStream in = new FileInputStream(report.getLocalFile());
        try {
            UpdateSite site = EclipseUpdateSiteParser.parse(in);
            site.setUri(normalizeSiteUri(site.getUri(), siteUri));
            return site;
        } finally {
View Full Code Here

Examples of org.apache.ivy.core.report.ArtifactDownloadReport

        }
        URL digest = digestBaseUri.resolve("digest.zip").toURL();
        Message.verbose("\tReading " + digest);

        URLResource res = new URLResource(digest);
        ArtifactDownloadReport report = repositoryCacheManager.downloadRepositoryResource(res,
            "digest", "digest", "zip", options, urlRepository);
        if (report.getDownloadStatus() == DownloadStatus.FAILED) {
            return null;
        }
        InputStream in = new FileInputStream(report.getLocalFile());
        try {
            ZipInputStream zipped = findEntry(in, "digest.xml");
            if (zipped == null) {
                return null;
            }
View Full Code Here

Examples of org.apache.ivy.core.report.ArtifactDownloadReport

        for (EclipseFeature feature : site.getFeatures()) {
            URL url = site.getUri().resolve(feature.getUrl()).toURL();

            URLResource res = new URLResource(url);
            ArtifactDownloadReport report = repositoryCacheManager.downloadRepositoryResource(res,
                feature.getId(), "feature", "jar", options, urlRepository);
            if (report.getDownloadStatus() == DownloadStatus.FAILED) {
                return null;
            }
            InputStream in = new FileInputStream(report.getLocalFile());
            try {
                ZipInputStream zipped = findEntry(in, "feature.xml");
                if (zipped == null) {
                    return null;
                }
View Full Code Here

Examples of org.apache.ivy.core.report.ArtifactDownloadReport

        public boolean hasNext() {
            while (next == null && it.hasNext()) {
                ModuleRevisionId mrid = it.next();
                List<ArtifactDownloadReport> reports = artifactReports.get(mrid);
                ArtifactDownloadReport jar = null;
                ArtifactDownloadReport source = null;
                for (ArtifactDownloadReport report : reports) {
                    if (sourceTypes != null && sourceTypes.contains(report.getArtifact().getType())) {
                        source = report;
                    } else {
                        jar = report;
                    }
                }
                if (jar == null) {
                    // didn't found any suitable jar
                    continue;
                }
                URI sourceURI = null;
                if (source != null) {
                    if (source.getUnpackedLocalFile() != null) {
                        sourceURI = source.getUnpackedLocalFile().toURI();
                    } else {
                        sourceURI = source.getLocalFile().toURI();
                    }
                }
                if (jar.getUnpackedLocalFile() != null && jar.getUnpackedLocalFile().isDirectory()) {
                    FileInputStream in = null;
                    try {
View Full Code Here

Examples of org.apache.ivy.core.report.ArtifactDownloadReport

        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());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.