Search in sources :

Example 11 with ExcludeRule

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

the class AbstractModuleDescriptorParserTester method assertDependencyArtifactExcludeRules.

protected void assertDependencyArtifactExcludeRules(DependencyDescriptor dd, String[] confs, String[] artifactsNames) {
    ExcludeRule[] rules = dd.getExcludeRules(confs);
    assertNotNull(rules);
    assertEquals(artifactsNames.length, rules.length);
    for (String artifactsName : artifactsNames) {
        boolean found = false;
        for (ExcludeRule rule : rules) {
            assertNotNull(rule);
            if (rule.getId().getName().equals(artifactsName)) {
                found = true;
                break;
            }
        }
        assertTrue("dependency exclude not found: " + artifactsName, found);
    }
}
Also used : ExcludeRule(org.apache.ivy.core.module.descriptor.ExcludeRule)

Example 12 with ExcludeRule

use of org.apache.ivy.core.module.descriptor.ExcludeRule 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 13 with ExcludeRule

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

the class XmlModuleDescriptorWriter method printAllExcludes.

private static void printAllExcludes(ModuleDescriptor md, PrintWriter out) {
    ExcludeRule[] excludes = md.getAllExcludeRules();
    if (excludes.length > 0) {
        for (ExcludeRule exclude : excludes) {
            out.print(String.format("\t\t<exclude org=\"%s\" module=\"%s\" artifact=\"%s\" type=\"%s\" ext=\"%s\"", XMLHelper.escape(exclude.getId().getModuleId().getOrganisation()), XMLHelper.escape(exclude.getId().getModuleId().getName()), XMLHelper.escape(exclude.getId().getName()), XMLHelper.escape(exclude.getId().getType()), XMLHelper.escape(exclude.getId().getExt())));
            String[] ruleConfs = exclude.getConfigurations();
            if (!Arrays.asList(ruleConfs).equals(Arrays.asList(md.getConfigurationsNames()))) {
                out.print(listToPrefixedString(ruleConfs, " conf=\""));
            }
            out.print(" matcher=\"" + XMLHelper.escape(exclude.getMatcher().getName()) + "\"");
            out.println("/>");
        }
    }
}
Also used : ExcludeRule(org.apache.ivy.core.module.descriptor.ExcludeRule)

Example 14 with ExcludeRule

use of org.apache.ivy.core.module.descriptor.ExcludeRule 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)

Example 15 with ExcludeRule

use of org.apache.ivy.core.module.descriptor.ExcludeRule in project walkmod-core by walkmod.

the class IvyConfigurationProvider method addArtifact.

public void addArtifact(String groupId, String artifactId, String version) throws Exception {
    artifacts.add(groupId + ":" + artifactId + ":" + version);
    String[] dep = null;
    dep = new String[] { groupId, artifactId, version };
    if (md == null) {
        md = DefaultModuleDescriptor.newDefaultInstance(ModuleRevisionId.newInstance(dep[0], dep[1] + "-caller", "working"));
    }
    DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(md, ModuleRevisionId.newInstance(dep[0], dep[1], dep[2]), false, false, true);
    md.addDependency(dd);
    ExcludeRule er = new DefaultExcludeRule(new ArtifactId(new ModuleId("org.walkmod", "walkmod-core"), PatternMatcher.ANY_EXPRESSION, PatternMatcher.ANY_EXPRESSION, PatternMatcher.ANY_EXPRESSION), ExactPatternMatcher.INSTANCE, null);
    dd.addExcludeRule(null, er);
}
Also used : DefaultExcludeRule(org.apache.ivy.core.module.descriptor.DefaultExcludeRule) ModuleId(org.apache.ivy.core.module.id.ModuleId) ArtifactId(org.apache.ivy.core.module.id.ArtifactId) DefaultDependencyDescriptor(org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor) ExcludeRule(org.apache.ivy.core.module.descriptor.ExcludeRule) DefaultExcludeRule(org.apache.ivy.core.module.descriptor.DefaultExcludeRule)

Aggregations

ExcludeRule (org.apache.ivy.core.module.descriptor.ExcludeRule)15 DependencyDescriptor (org.apache.ivy.core.module.descriptor.DependencyDescriptor)5 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)5 DependencyArtifactDescriptor (org.apache.ivy.core.module.descriptor.DependencyArtifactDescriptor)4 ModuleDescriptor (org.apache.ivy.core.module.descriptor.ModuleDescriptor)3 Test (org.junit.Test)3 IOException (java.io.IOException)2 ParseException (java.text.ParseException)2 List (java.util.List)2 Map (java.util.Map)2 Configuration (org.apache.ivy.core.module.descriptor.Configuration)2 DefaultDependencyDescriptor (org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor)2 DefaultModuleDescriptor (org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor)2 License (org.apache.ivy.core.module.descriptor.License)2 ModuleId (org.apache.ivy.core.module.id.ModuleId)2 ResolveData (org.apache.ivy.core.resolve.ResolveData)2 ResolvedModuleRevision (org.apache.ivy.core.resolve.ResolvedModuleRevision)2 XmlModuleDescriptorParserTest (org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParserTest)2 MockResolver (org.apache.ivy.plugins.resolver.MockResolver)2 Artifact (org.gradle.internal.component.external.descriptor.Artifact)2