Search in sources :

Example 6 with DependencyArtifactDescriptor

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

the class PomModuleDescriptorParserTest method testEjbType.

@Test
public void testEjbType() throws Exception {
    ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test-ejb-type.pom"), false);
    assertNotNull(md);
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org.apache", "test-ejb-type", "1.0");
    assertEquals(mrid, md.getModuleRevisionId());
    DependencyDescriptor[] deps = md.getDependencies();
    assertNotNull(deps);
    assertEquals(1, deps.length);
    DependencyArtifactDescriptor[] artifacts = deps[0].getAllDependencyArtifacts();
    assertNotNull(artifacts);
    assertEquals(1, artifacts.length);
    assertEquals("test", artifacts[0].getName());
    assertEquals("jar", artifacts[0].getExt());
    assertEquals("ejb", artifacts[0].getType());
}
Also used : DefaultModuleDescriptor(org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor) ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) DependencyArtifactDescriptor(org.apache.ivy.core.module.descriptor.DependencyArtifactDescriptor) DependencyDescriptor(org.apache.ivy.core.module.descriptor.DependencyDescriptor) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) XmlModuleDescriptorParserTest(org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParserTest) Test(org.junit.Test)

Example 7 with DependencyArtifactDescriptor

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

the class AbstractModuleDescriptorParserTester method assertDependencyArtifacts.

protected void assertDependencyArtifacts(DependencyDescriptor dd, String[] confs, String[] artifactsNames) {
    DependencyArtifactDescriptor[] dads = dd.getDependencyArtifacts(confs);
    assertNotNull(dads);
    assertEquals(artifactsNames.length, dads.length);
    for (String artifactsName : artifactsNames) {
        boolean found = false;
        for (DependencyArtifactDescriptor dad : dads) {
            assertNotNull(dad);
            if (dad.getName().equals(artifactsName)) {
                found = true;
                break;
            }
        }
        assertTrue("dependency artifact not found: " + artifactsName, found);
    }
}
Also used : DependencyArtifactDescriptor(org.apache.ivy.core.module.descriptor.DependencyArtifactDescriptor)

Example 8 with DependencyArtifactDescriptor

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

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

the class XmlModuleDescriptorWriter method printDependencyArtefacts.

private static void printDependencyArtefacts(ModuleDescriptor md, PrintWriter out, DependencyArtifactDescriptor[] depArtifacts) {
    if (depArtifacts.length > 0) {
        for (DependencyArtifactDescriptor depArtifact : depArtifacts) {
            out.print(String.format("\t\t\t<artifact name=\"%s\" type=\"%s\" ext=\"%s\"", XMLHelper.escape(depArtifact.getName()), XMLHelper.escape(depArtifact.getType()), XMLHelper.escape(depArtifact.getExt())));
            String[] dadConfs = depArtifact.getConfigurations();
            if (!Arrays.asList(dadConfs).equals(Arrays.asList(md.getConfigurationsNames()))) {
                out.print(listToPrefixedString(dadConfs, " conf=\""));
            }
            printExtraAttributes(depArtifact, out, " ");
            out.println("/>");
        }
    }
}
Also used : DependencyArtifactDescriptor(org.apache.ivy.core.module.descriptor.DependencyArtifactDescriptor)

Aggregations

DependencyArtifactDescriptor (org.apache.ivy.core.module.descriptor.DependencyArtifactDescriptor)9 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)5 ExcludeRule (org.apache.ivy.core.module.descriptor.ExcludeRule)4 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 Map (java.util.Map)2 DependencyDescriptor (org.apache.ivy.core.module.descriptor.DependencyDescriptor)2 IncludeRule (org.apache.ivy.core.module.descriptor.IncludeRule)2 MDArtifact (org.apache.ivy.core.module.descriptor.MDArtifact)2 Artifact (org.gradle.internal.component.external.descriptor.Artifact)2 DefaultExclude (org.gradle.internal.component.external.descriptor.DefaultExclude)2 DefaultIvyArtifactName (org.gradle.internal.component.model.DefaultIvyArtifactName)2 Exclude (org.gradle.internal.component.model.Exclude)2 IvyArtifactName (org.gradle.internal.component.model.IvyArtifactName)2 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 Artifact (org.apache.ivy.core.module.descriptor.Artifact)1 DefaultArtifact (org.apache.ivy.core.module.descriptor.DefaultArtifact)1 DefaultModuleDescriptor (org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor)1