Search in sources :

Example 11 with ModuleDescriptor

use of org.apache.ivy.core.module.descriptor.ModuleDescriptor in project ant-ivy by apache.

the class IvyPostResolveTask method getConfsToResolve.

protected String[] getConfsToResolve(String org, String module, String conf, boolean strict) {
    ModuleDescriptor reference = getResolvedDescriptor(org, module, strict);
    String[] rconfs = getResolvedConfigurations(org, module, strict);
    return getConfsToResolve(reference, conf, rconfs);
}
Also used : ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor)

Example 12 with ModuleDescriptor

use of org.apache.ivy.core.module.descriptor.ModuleDescriptor in project ant-ivy by apache.

the class IvyRepositoryReport method doExecute.

public void doExecute() throws BuildException {
    Ivy ivy = getIvyInstance();
    IvySettings settings = ivy.getSettings();
    if (xsl && xslFile == null) {
        throw new BuildException("xsl file is mandatory when using xsl generation");
    }
    if (module == null && PatternMatcher.EXACT.equals(matcher)) {
        throw new BuildException("no module name provided for ivy repository graph task: " + "It can either be set explicitly via the attribute 'module' or " + "via 'ivy.module' property or a prior call to <resolve/>");
    } else if (module == null && !PatternMatcher.EXACT.equals(matcher)) {
        module = PatternMatcher.ANY_EXPRESSION;
    }
    ModuleRevisionId moduleRevisionId = ModuleRevisionId.newInstance(organisation, module, revision);
    try {
        ModuleRevisionId criteria = (revision == null) || settings.getVersionMatcher().isDynamic(moduleRevisionId) ? new ModuleRevisionId(new ModuleId(organisation, module), branch, "*") : new ModuleRevisionId(new ModuleId(organisation, module), branch, revision);
        ModuleRevisionId[] mrids = ivy.listModules(criteria, settings.getMatcher(matcher));
        // replace all found revisions with the original requested revision
        Set<ModuleRevisionId> modules = new HashSet<>();
        for (ModuleRevisionId mrid : mrids) {
            modules.add(ModuleRevisionId.newInstance(mrid, revision));
        }
        mrids = modules.toArray(new ModuleRevisionId[modules.size()]);
        ModuleDescriptor md = DefaultModuleDescriptor.newCallerInstance(mrids, true, false);
        String resolveId = ResolveOptions.getDefaultResolveId(md);
        ResolveReport report = ivy.resolve(md, new ResolveOptions().setResolveId(resolveId).setValidate(doValidate(settings)));
        ResolutionCacheManager cacheMgr = getIvyInstance().getResolutionCacheManager();
        new XmlReportOutputter().output(report, cacheMgr, new ResolveOptions());
        if (graph) {
            gengraph(cacheMgr, md.getModuleRevisionId().getOrganisation(), md.getModuleRevisionId().getName());
        }
        if (dot) {
            gendot(cacheMgr, md.getModuleRevisionId().getOrganisation(), md.getModuleRevisionId().getName());
        }
        if (xml) {
            FileUtil.copy(cacheMgr.getConfigurationResolveReportInCache(resolveId, "default"), new File(getTodir(), outputname + ".xml"), null);
        }
        if (xsl) {
            genreport(cacheMgr, md.getModuleRevisionId().getOrganisation(), md.getModuleRevisionId().getName());
        }
    } catch (Exception e) {
        throw new BuildException("impossible to generate graph for " + moduleRevisionId + ": " + e, e);
    }
}
Also used : ResolutionCacheManager(org.apache.ivy.core.cache.ResolutionCacheManager) IvySettings(org.apache.ivy.core.settings.IvySettings) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) Ivy(org.apache.ivy.Ivy) IOException(java.io.IOException) BuildException(org.apache.tools.ant.BuildException) ModuleId(org.apache.ivy.core.module.id.ModuleId) DefaultModuleDescriptor(org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor) ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) XmlReportOutputter(org.apache.ivy.plugins.report.XmlReportOutputter) ResolveReport(org.apache.ivy.core.report.ResolveReport) BuildException(org.apache.tools.ant.BuildException) ResolveOptions(org.apache.ivy.core.resolve.ResolveOptions) File(java.io.File) HashSet(java.util.HashSet)

Example 13 with ModuleDescriptor

use of org.apache.ivy.core.module.descriptor.ModuleDescriptor in project ant-ivy by apache.

the class IvyTask method setResolved.

protected void setResolved(ResolveReport report, boolean keep) {
    ModuleDescriptor md = report.getModuleDescriptor();
    String[] confs = report.getConfigurations();
    if (keep) {
        getProject().addReference("ivy.resolved.report", report);
        getProject().addReference("ivy.resolved.configurations.ref", confs);
        getProject().addReference("ivy.resolved.descriptor", md);
    }
    String suffix = md.getModuleRevisionId().getModuleId().getOrganisation() + "." + md.getModuleRevisionId().getModuleId().getName();
    getProject().addReference("ivy.resolved.report." + suffix, report);
    getProject().addReference("ivy.resolved.descriptor." + suffix, md);
    getProject().addReference("ivy.resolved.configurations.ref." + suffix, confs);
}
Also used : ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor)

Example 14 with ModuleDescriptor

use of org.apache.ivy.core.module.descriptor.ModuleDescriptor in project ant-ivy by apache.

the class IvyTask method setResolved.

protected void setResolved(ResolveReport report, String resolveId, boolean keep) {
    setResolved(report, keep);
    if (resolveId == null) {
        return;
    }
    ModuleDescriptor md = report.getModuleDescriptor();
    String[] confs = report.getConfigurations();
    getProject().addReference("ivy.resolved.report." + resolveId, report);
    getProject().addReference("ivy.resolved.descriptor." + resolveId, md);
    getProject().addReference("ivy.resolved.configurations.ref." + resolveId, confs);
}
Also used : ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor)

Example 15 with ModuleDescriptor

use of org.apache.ivy.core.module.descriptor.ModuleDescriptor in project ant-ivy by apache.

the class IvyDependencyUpdateChecker method doExecute.

public void doExecute() throws BuildException {
    prepareAndCheck();
    ModuleDescriptor originalModuleDescriptor = getResolvedReport().getModuleDescriptor();
    // clone module descriptor
    DefaultModuleDescriptor latestModuleDescriptor = new DefaultModuleDescriptor(originalModuleDescriptor.getModuleRevisionId(), originalModuleDescriptor.getStatus(), originalModuleDescriptor.getPublicationDate());
    // copy configurations
    for (Configuration configuration : originalModuleDescriptor.getConfigurations()) {
        latestModuleDescriptor.addConfiguration(configuration);
    }
    // clone dependency and add new one with the requested revisionToCheck
    for (DependencyDescriptor dependencyDescriptor : originalModuleDescriptor.getDependencies()) {
        ModuleRevisionId upToDateMrid = ModuleRevisionId.newInstance(dependencyDescriptor.getDependencyRevisionId(), revisionToCheck);
        latestModuleDescriptor.addDependency(dependencyDescriptor.clone(upToDateMrid));
    }
    // resolve
    ResolveOptions resolveOptions = new ResolveOptions();
    resolveOptions.setDownload(isDownload());
    resolveOptions.setLog(getLog());
    resolveOptions.setConfs(splitToArray(getConf()));
    resolveOptions.setCheckIfChanged(checkIfChanged);
    ResolveReport latestReport;
    try {
        latestReport = getIvyInstance().getResolveEngine().resolve(latestModuleDescriptor, resolveOptions);
        displayDependencyUpdates(getResolvedReport(), latestReport);
        if (showTransitive) {
            displayNewDependencyOnLatest(getResolvedReport(), latestReport);
            displayMissingDependencyOnLatest(getResolvedReport(), latestReport);
        }
    } catch (ParseException | IOException e) {
        throw new BuildException("impossible to resolve dependencies:\n\t" + e, e);
    }
}
Also used : DefaultModuleDescriptor(org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor) ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) ResolveReport(org.apache.ivy.core.report.ResolveReport) Configuration(org.apache.ivy.core.module.descriptor.Configuration) DependencyDescriptor(org.apache.ivy.core.module.descriptor.DependencyDescriptor) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) ParseException(java.text.ParseException) IOException(java.io.IOException) BuildException(org.apache.tools.ant.BuildException) DefaultModuleDescriptor(org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor) ResolveOptions(org.apache.ivy.core.resolve.ResolveOptions)

Aggregations

ModuleDescriptor (org.apache.ivy.core.module.descriptor.ModuleDescriptor)284 Test (org.junit.Test)233 File (java.io.File)143 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)114 ResolveReport (org.apache.ivy.core.report.ResolveReport)94 DependencyDescriptor (org.apache.ivy.core.module.descriptor.DependencyDescriptor)80 JarFile (java.util.jar.JarFile)76 ConfigurationResolveReport (org.apache.ivy.core.report.ConfigurationResolveReport)76 DefaultModuleDescriptor (org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor)69 IvySettings (org.apache.ivy.core.settings.IvySettings)60 XmlModuleDescriptorParserTest (org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParserTest)44 Configuration (org.apache.ivy.core.module.descriptor.Configuration)30 Artifact (org.apache.ivy.core.module.descriptor.Artifact)28 DefaultDependencyDescriptor (org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor)27 IOException (java.io.IOException)24 ParseException (java.text.ParseException)23 Ivy (org.apache.ivy.Ivy)23 BufferedReader (java.io.BufferedReader)19 FileReader (java.io.FileReader)19 ResolvedModuleRevision (org.apache.ivy.core.resolve.ResolvedModuleRevision)17