Search in sources :

Example 11 with RepositoryCacheManager

use of org.apache.ivy.core.cache.RepositoryCacheManager in project ant-ivy by apache.

the class IvyArtifactReport method generateXml.

private void generateXml(IvyNode[] dependencies, Map<ModuleRevisionId, Set<ArtifactDownloadReport>> moduleRevToArtifactsMap, Map<ArtifactDownloadReport, Set<String>> artifactsToCopy) {
    try {
        try (FileOutputStream fileOutputStream = new FileOutputStream(tofile)) {
            TransformerHandler saxHandler = createTransformerHandler(fileOutputStream);
            saxHandler.startDocument();
            saxHandler.startElement(null, "modules", "modules", new AttributesImpl());
            for (IvyNode dependency : dependencies) {
                if (dependency.getModuleRevision() == null || dependency.isCompletelyEvicted()) {
                    continue;
                }
                startModule(saxHandler, dependency);
                Set<ArtifactDownloadReport> artifactsOfModuleRev = moduleRevToArtifactsMap.get(dependency.getModuleRevision().getId());
                if (artifactsOfModuleRev != null) {
                    for (ArtifactDownloadReport artifact : artifactsOfModuleRev) {
                        RepositoryCacheManager cache = dependency.getModuleRevision().getArtifactResolver().getRepositoryCacheManager();
                        startArtifact(saxHandler, artifact.getArtifact());
                        writeOriginLocationIfPresent(cache, saxHandler, artifact);
                        writeCacheLocationIfPresent(cache, saxHandler, artifact);
                        for (String artifactDestPath : artifactsToCopy.get(artifact)) {
                            writeRetrieveLocation(saxHandler, artifactDestPath);
                        }
                        saxHandler.endElement(null, "artifact", "artifact");
                    }
                }
                saxHandler.endElement(null, "module", "module");
            }
            saxHandler.endElement(null, "modules", "modules");
            saxHandler.endDocument();
        }
    } catch (SAXException | IOException | TransformerConfigurationException e) {
        throw new BuildException("impossible to generate report", e);
    }
}
Also used : TransformerHandler(javax.xml.transform.sax.TransformerHandler) RepositoryCacheManager(org.apache.ivy.core.cache.RepositoryCacheManager) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) ArtifactDownloadReport(org.apache.ivy.core.report.ArtifactDownloadReport) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException) AttributesImpl(org.xml.sax.helpers.AttributesImpl) FileOutputStream(java.io.FileOutputStream) BuildException(org.apache.tools.ant.BuildException) IvyNode(org.apache.ivy.core.resolve.IvyNode)

Example 12 with RepositoryCacheManager

use of org.apache.ivy.core.cache.RepositoryCacheManager in project ant-ivy by apache.

the class BasicResolver method download.

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;
}
Also used : DownloadReport(org.apache.ivy.core.report.DownloadReport) MetadataArtifactDownloadReport(org.apache.ivy.core.report.MetadataArtifactDownloadReport) ArtifactDownloadReport(org.apache.ivy.core.report.ArtifactDownloadReport) RepositoryCacheManager(org.apache.ivy.core.cache.RepositoryCacheManager) MetadataArtifactDownloadReport(org.apache.ivy.core.report.MetadataArtifactDownloadReport) ArtifactDownloadReport(org.apache.ivy.core.report.ArtifactDownloadReport) Artifact(org.apache.ivy.core.module.descriptor.Artifact)

Aggregations

RepositoryCacheManager (org.apache.ivy.core.cache.RepositoryCacheManager)12 File (java.io.File)8 Ivy (org.apache.ivy.Ivy)6 IvySettings (org.apache.ivy.core.settings.IvySettings)6 ResolveData (org.apache.ivy.core.resolve.ResolveData)5 ResolveOptions (org.apache.ivy.core.resolve.ResolveOptions)5 Before (org.junit.Before)5 IOException (java.io.IOException)4 ParseException (java.text.ParseException)3 Artifact (org.apache.ivy.core.module.descriptor.Artifact)3 ArtifactDownloadReport (org.apache.ivy.core.report.ArtifactDownloadReport)3 SAXException (org.xml.sax.SAXException)3 FileOutputStream (java.io.FileOutputStream)2 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)2 DefaultRepositoryCacheManager (org.apache.ivy.core.cache.DefaultRepositoryCacheManager)2 UpdateSiteResolver (org.apache.ivy.osgi.updatesite.UpdateSiteResolver)2 ResolvedResource (org.apache.ivy.plugins.resolver.util.ResolvedResource)2 BuildException (org.apache.tools.ant.BuildException)2 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1