Search in sources :

Example 61 with ArtifactDownloadReport

use of org.apache.ivy.core.report.ArtifactDownloadReport 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)

Example 62 with ArtifactDownloadReport

use of org.apache.ivy.core.report.ArtifactDownloadReport in project ant-ivy by apache.

the class ChainResolver method download.

@Override
public ArtifactDownloadReport download(ArtifactOrigin artifact, DownloadOptions options) {
    for (DependencyResolver resolver : chain) {
        ArtifactDownloadReport adr = resolver.download(artifact, options);
        if (adr.getDownloadStatus() != DownloadStatus.FAILED) {
            return adr;
        }
    }
    ArtifactDownloadReport adr = new ArtifactDownloadReport(artifact.getArtifact());
    adr.setDownloadStatus(DownloadStatus.FAILED);
    return adr;
}
Also used : ArtifactDownloadReport(org.apache.ivy.core.report.ArtifactDownloadReport)

Example 63 with ArtifactDownloadReport

use of org.apache.ivy.core.report.ArtifactDownloadReport in project ant-ivy by apache.

the class AbstractResolver method locate.

/**
 * 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();
}
Also used : DownloadReport(org.apache.ivy.core.report.DownloadReport) MetadataArtifactDownloadReport(org.apache.ivy.core.report.MetadataArtifactDownloadReport) ArtifactDownloadReport(org.apache.ivy.core.report.ArtifactDownloadReport) DownloadOptions(org.apache.ivy.core.resolve.DownloadOptions) CacheDownloadOptions(org.apache.ivy.core.cache.CacheDownloadOptions) MetadataArtifactDownloadReport(org.apache.ivy.core.report.MetadataArtifactDownloadReport) ArtifactDownloadReport(org.apache.ivy.core.report.ArtifactDownloadReport)

Example 64 with ArtifactDownloadReport

use of org.apache.ivy.core.report.ArtifactDownloadReport in project ant-ivy by apache.

the class XmlReportWriter method outputArtifacts.

private void outputArtifacts(ConfigurationResolveReport report, PrintWriter out, IvyNode dep) {
    out.println("\t\t\t\t<artifacts>");
    for (ArtifactDownloadReport adr : report.getDownloadReports(dep.getResolvedId())) {
        out.print("\t\t\t\t\t<artifact name=\"" + XMLHelper.escape(adr.getName()) + "\" type=\"" + XMLHelper.escape(adr.getType()) + "\" ext=\"" + XMLHelper.escape(adr.getExt()) + "\"");
        out.print(extraToString(adr.getArtifact().getExtraAttributes(), SEPARATOR));
        out.print(" status=\"" + XMLHelper.escape(adr.getDownloadStatus().toString()) + "\"");
        out.print(" details=\"" + XMLHelper.escape(adr.getDownloadDetails()) + "\"");
        out.print(" size=\"" + adr.getSize() + "\"");
        out.print(" time=\"" + adr.getDownloadTimeMillis() + "\"");
        if (adr.getLocalFile() != null) {
            out.print(" location=\"" + XMLHelper.escape(adr.getLocalFile().getAbsolutePath()) + "\"");
        }
        if (adr.getUnpackedLocalFile() != null) {
            out.print(" unpackedFile=\"" + XMLHelper.escape(adr.getUnpackedLocalFile().getAbsolutePath()) + "\"");
        }
        ArtifactOrigin origin = adr.getArtifactOrigin();
        if (origin != null) {
            out.println(">");
            out.println("\t\t\t\t\t\t<origin-location is-local=\"" + String.valueOf(origin.isLocal()) + "\"" + " location=\"" + XMLHelper.escape(origin.getLocation()) + "\"/>");
            out.println("\t\t\t\t\t</artifact>");
        } else {
            out.println("/>");
        }
    }
    out.println("\t\t\t\t</artifacts>");
}
Also used : MetadataArtifactDownloadReport(org.apache.ivy.core.report.MetadataArtifactDownloadReport) ArtifactDownloadReport(org.apache.ivy.core.report.ArtifactDownloadReport) ArtifactOrigin(org.apache.ivy.core.cache.ArtifactOrigin)

Aggregations

ArtifactDownloadReport (org.apache.ivy.core.report.ArtifactDownloadReport)64 File (java.io.File)33 Artifact (org.apache.ivy.core.module.descriptor.Artifact)29 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)26 Test (org.junit.Test)25 DownloadReport (org.apache.ivy.core.report.DownloadReport)23 DefaultDependencyDescriptor (org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor)18 ResolvedModuleRevision (org.apache.ivy.core.resolve.ResolvedModuleRevision)18 DefaultArtifact (org.apache.ivy.core.module.descriptor.DefaultArtifact)17 ResolveReport (org.apache.ivy.core.report.ResolveReport)15 ConfigurationResolveReport (org.apache.ivy.core.report.ConfigurationResolveReport)11 IOException (java.io.IOException)10 DownloadOptions (org.apache.ivy.core.resolve.DownloadOptions)10 URL (java.net.URL)8 JarFile (java.util.jar.JarFile)8 Date (java.util.Date)7 MetadataArtifactDownloadReport (org.apache.ivy.core.report.MetadataArtifactDownloadReport)7 URLResource (org.apache.ivy.plugins.repository.url.URLResource)7 ArtifactOrigin (org.apache.ivy.core.cache.ArtifactOrigin)6 MalformedURLException (java.net.MalformedURLException)5