Search in sources :

Example 96 with DependencyDescriptor

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

the class PomModuleDescriptorWriter method printDependencies.

private static void printDependencies(ModuleDescriptor md, PrintWriter out, PomWriterOptions options, int indent, boolean printDependencies) {
    List<ExtraDependency> extraDeps = options.getExtraDependencies();
    DependencyDescriptor[] dds = getDependencies(md, options);
    if (!extraDeps.isEmpty() || (dds.length > 0)) {
        if (printDependencies) {
            indent(out, indent);
            out.println("<dependencies>");
        }
        // print the extra dependencies first
        for (ExtraDependency dep : extraDeps) {
            String groupId = dep.getGroup();
            if (groupId == null) {
                groupId = md.getModuleRevisionId().getOrganisation();
            }
            String version = dep.getVersion();
            if (version == null) {
                version = md.getModuleRevisionId().getRevision();
            }
            printDependency(out, indent, groupId, dep.getArtifact(), version, dep.getType(), dep.getClassifier(), dep.getScope(), dep.isOptional(), true, null);
        }
        // now print the dependencies listed in the ModuleDescriptor
        ConfigurationScopeMapping mapping = options.getMapping();
        if (mapping == null) {
            mapping = DEFAULT_MAPPING;
        }
        for (DependencyDescriptor dd : dds) {
            ModuleRevisionId mrid = dd.getDependencyRevisionId();
            ExcludeRule[] excludes = null;
            if (dd.canExclude()) {
                excludes = dd.getAllExcludeRules();
            }
            DependencyArtifactDescriptor[] dads = dd.getAllDependencyArtifacts();
            if (dads.length > 0) {
                for (DependencyArtifactDescriptor dad : dads) {
                    String type = dad.getType();
                    String classifier = dad.getExtraAttribute("classifier");
                    String scope = mapping.getScope(dd.getModuleConfigurations());
                    boolean optional = mapping.isOptional(dd.getModuleConfigurations());
                    printDependency(out, indent, mrid.getOrganisation(), mrid.getName(), mrid.getRevision(), type, classifier, scope, optional, dd.isTransitive(), excludes);
                }
            } else {
                String scope = mapping.getScope(dd.getModuleConfigurations());
                boolean optional = mapping.isOptional(dd.getModuleConfigurations());
                final String classifier = dd.getExtraAttribute("classifier");
                printDependency(out, indent, mrid.getOrganisation(), mrid.getName(), mrid.getRevision(), null, classifier, scope, optional, dd.isTransitive(), excludes);
            }
        }
        if (printDependencies) {
            indent(out, indent);
            out.println("</dependencies>");
        }
    }
}
Also used : ConfigurationScopeMapping(org.apache.ivy.plugins.parser.m2.PomWriterOptions.ConfigurationScopeMapping) DependencyArtifactDescriptor(org.apache.ivy.core.module.descriptor.DependencyArtifactDescriptor) DependencyDescriptor(org.apache.ivy.core.module.descriptor.DependencyDescriptor) ExtraDependency(org.apache.ivy.plugins.parser.m2.PomWriterOptions.ExtraDependency) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) ExcludeRule(org.apache.ivy.core.module.descriptor.ExcludeRule)

Example 97 with DependencyDescriptor

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

the class PomModuleDescriptorWriter method getDependencies.

private static DependencyDescriptor[] getDependencies(ModuleDescriptor md, PomWriterOptions options) {
    String[] confs = ConfigurationUtils.replaceWildcards(options.getConfs(), md);
    List<DependencyDescriptor> result = new ArrayList<>();
    for (DependencyDescriptor dd : md.getDependencies()) {
        String[] depConfs = dd.getDependencyConfigurations(confs);
        if (depConfs != null && depConfs.length > 0) {
            result.add(dd);
        }
    }
    return result.toArray(new DependencyDescriptor[result.size()]);
}
Also used : DependencyDescriptor(org.apache.ivy.core.module.descriptor.DependencyDescriptor) ArrayList(java.util.ArrayList)

Example 98 with DependencyDescriptor

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

the class XmlModuleDescriptorWriter method printDependencies.

private static void printDependencies(ModuleDescriptor md, PrintWriter out) {
    DependencyDescriptor[] dds = md.getDependencies();
    if (dds.length > 0) {
        out.println("\t<dependencies>");
        for (DependencyDescriptor dep : dds) {
            out.print("\t\t");
            printDependency(md, dep, out);
        }
        printAllExcludes(md, out);
        printAllMediators(md, out);
        out.println("\t</dependencies>");
    }
}
Also used : DependencyDescriptor(org.apache.ivy.core.module.descriptor.DependencyDescriptor)

Example 99 with DependencyDescriptor

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

the class BasicResolver method parse.

public ResolvedModuleRevision parse(final ResolvedResource mdRef, DependencyDescriptor dd, ResolveData data) throws ParseException {
    DependencyDescriptor nsDd = dd;
    dd = toSystem(nsDd);
    ModuleRevisionId mrid = dd.getDependencyRevisionId();
    ModuleDescriptorParser parser = ModuleDescriptorParserRegistry.getInstance().getParser(mdRef.getResource());
    if (parser == null) {
        Message.warn("no module descriptor parser available for " + mdRef.getResource());
        return null;
    }
    Message.verbose("\t" + getName() + ": found md file for " + mrid);
    Message.verbose("\t\t=> " + mdRef);
    Message.debug("\tparser = " + parser);
    ModuleRevisionId resolvedMrid = mrid;
    // first check if this dependency has not yet been resolved
    if (getSettings().getVersionMatcher().isDynamic(mrid)) {
        resolvedMrid = ModuleRevisionId.newInstance(mrid, mdRef.getRevision());
        IvyNode node = data.getNode(resolvedMrid);
        if (node != null && node.getModuleRevision() != null) {
            // this revision has already be resolved : return it
            if (node.getDescriptor() == null || !node.getDescriptor().isDefault()) {
                Message.verbose("\t" + getName() + ": revision already resolved: " + resolvedMrid);
                node.getModuleRevision().getReport().setSearched(true);
                return node.getModuleRevision();
            }
            Message.verbose("\t" + getName() + ": found already resolved revision: " + resolvedMrid + ": but it's a default one, maybe we can find a better one");
        }
    }
    Artifact moduleArtifact = parser.getMetadataArtifact(resolvedMrid, mdRef.getResource());
    return getRepositoryCacheManager().cacheModuleDescriptor(this, mdRef, dd, moduleArtifact, downloader, getCacheOptions(data));
}
Also used : DependencyDescriptor(org.apache.ivy.core.module.descriptor.DependencyDescriptor) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) ModuleDescriptorParser(org.apache.ivy.plugins.parser.ModuleDescriptorParser) IvyNode(org.apache.ivy.core.resolve.IvyNode) Artifact(org.apache.ivy.core.module.descriptor.Artifact)

Example 100 with DependencyDescriptor

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

the class AbstractWorkspaceResolver method createWorkspaceMd.

protected WorkspaceModuleDescriptor createWorkspaceMd(ModuleDescriptor md) {
    DefaultWorkspaceModuleDescriptor newMd = new DefaultWorkspaceModuleDescriptor(md.getModuleRevisionId(), "release", null, true);
    newMd.addConfiguration(new Configuration(ModuleDescriptor.DEFAULT_CONFIGURATION));
    newMd.setLastModified(System.currentTimeMillis());
    newMd.setDescription(md.getDescription());
    newMd.setHomePage(md.getHomePage());
    newMd.setLastModified(md.getLastModified());
    newMd.setPublicationDate(md.getPublicationDate());
    newMd.setResolvedPublicationDate(md.getResolvedPublicationDate());
    newMd.setStatus(md.getStatus());
    Configuration[] allConfs = md.getConfigurations();
    for (Artifact af : createWorkspaceArtifacts(md)) {
        if (allConfs.length == 0) {
            newMd.addArtifact(ModuleDescriptor.DEFAULT_CONFIGURATION, af);
        } else {
            for (Configuration conf : allConfs) {
                newMd.addConfiguration(conf);
                newMd.addArtifact(conf.getName(), af);
            }
        }
    }
    for (DependencyDescriptor dependency : md.getDependencies()) {
        newMd.addDependency(dependency);
    }
    for (ExcludeRule excludeRule : md.getAllExcludeRules()) {
        newMd.addExcludeRule(excludeRule);
    }
    newMd.getExtraInfos().addAll(md.getExtraInfos());
    for (License license : md.getLicenses()) {
        newMd.addLicense(license);
    }
    return newMd;
}
Also used : DefaultWorkspaceModuleDescriptor(org.apache.ivy.core.module.descriptor.DefaultWorkspaceModuleDescriptor) Configuration(org.apache.ivy.core.module.descriptor.Configuration) DependencyDescriptor(org.apache.ivy.core.module.descriptor.DependencyDescriptor) License(org.apache.ivy.core.module.descriptor.License) ExcludeRule(org.apache.ivy.core.module.descriptor.ExcludeRule) Artifact(org.apache.ivy.core.module.descriptor.Artifact) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact)

Aggregations

DependencyDescriptor (org.apache.ivy.core.module.descriptor.DependencyDescriptor)101 ModuleDescriptor (org.apache.ivy.core.module.descriptor.ModuleDescriptor)80 Test (org.junit.Test)75 DefaultDependencyDescriptor (org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor)35 DefaultModuleDescriptor (org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor)33 File (java.io.File)26 XmlModuleDescriptorParserTest (org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParserTest)26 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)25 ResolvedModuleRevision (org.apache.ivy.core.resolve.ResolvedModuleRevision)18 IvySettings (org.apache.ivy.core.settings.IvySettings)17 Configuration (org.apache.ivy.core.module.descriptor.Configuration)15 Artifact (org.apache.ivy.core.module.descriptor.Artifact)13 ParseException (java.text.ParseException)12 IOException (java.io.IOException)11 ResolveData (org.apache.ivy.core.resolve.ResolveData)11 MockResolver (org.apache.ivy.plugins.resolver.MockResolver)9 JarFile (java.util.jar.JarFile)7 GregorianCalendar (java.util.GregorianCalendar)6 ModuleId (org.apache.ivy.core.module.id.ModuleId)6 ResolveReport (org.apache.ivy.core.report.ResolveReport)6