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());
}
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);
}
}
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>");
}
}
}
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("/>");
}
}
}
Aggregations