use of org.apache.ivy.core.module.descriptor.ExcludeRule in project gradle by gradle.
the class IvyModuleDescriptorConverter method addDependency.
private void addDependency(List<IvyDependencyMetadata> result, DependencyDescriptor dependencyDescriptor) {
ModuleRevisionId revisionId = dependencyDescriptor.getDependencyRevisionId();
ModuleVersionSelector requested = DefaultModuleVersionSelector.newSelector(revisionId.getOrganisation(), revisionId.getName(), revisionId.getRevision());
ListMultimap<String, String> configMappings = ArrayListMultimap.create();
for (Map.Entry<String, List<String>> entry : readConfigMappings(dependencyDescriptor).entrySet()) {
configMappings.putAll(entry.getKey(), entry.getValue());
}
List<Artifact> artifacts = Lists.newArrayList();
for (DependencyArtifactDescriptor ivyArtifact : dependencyDescriptor.getAllDependencyArtifacts()) {
IvyArtifactName ivyArtifactName = new DefaultIvyArtifactName(ivyArtifact.getName(), ivyArtifact.getType(), ivyArtifact.getExt(), (String) ivyArtifact.getExtraAttributes().get(CLASSIFIER));
artifacts.add(new Artifact(ivyArtifactName, Sets.newHashSet(ivyArtifact.getConfigurations())));
}
List<Exclude> excludes = Lists.newArrayList();
for (ExcludeRule excludeRule : dependencyDescriptor.getAllExcludeRules()) {
excludes.add(forIvyExclude(excludeRule));
}
result.add(new IvyDependencyMetadata(requested, dependencyDescriptor.getDynamicConstraintDependencyRevisionId().getRevision(), false, dependencyDescriptor.isChanging(), dependencyDescriptor.isTransitive(), configMappings, artifacts, excludes));
}
use of org.apache.ivy.core.module.descriptor.ExcludeRule in project ant-ivy by apache.
the class PomModuleDescriptorWriter method printExclusions.
private static void printExclusions(ExcludeRule[] exclusions, PrintWriter out, int indent) {
indent(out, indent * 3);
out.println("<exclusions>");
for (ExcludeRule exclusion : exclusions) {
indent(out, indent * 4);
out.println("<exclusion>");
indent(out, indent * 5);
out.println("<groupId>" + exclusion.getId().getModuleId().getOrganisation() + "</groupId>");
indent(out, indent * 5);
out.println("<artifactId>" + exclusion.getId().getModuleId().getName() + "</artifactId>");
indent(out, indent * 4);
out.println("</exclusion>");
}
indent(out, indent * 3);
out.println("</exclusions>");
}
use of org.apache.ivy.core.module.descriptor.ExcludeRule in project ant-ivy by apache.
the class XmlModuleDescriptorWriter method printDependency.
protected static void printDependency(ModuleDescriptor md, DependencyDescriptor dep, PrintWriter out) {
final ModuleRevisionId dependencyRevisionId = dep.getDependencyRevisionId();
out.print(String.format("<dependency org=\"%s\" name=\"%s\"", XMLHelper.escape(dependencyRevisionId.getOrganisation()), XMLHelper.escape(dependencyRevisionId.getName())));
if (dependencyRevisionId.getBranch() != null) {
out.print(" branch=\"" + XMLHelper.escape(dependencyRevisionId.getBranch()) + "\"");
}
out.print(" rev=\"" + XMLHelper.escape(dependencyRevisionId.getRevision()) + "\"");
final ModuleRevisionId dynamicConstraintDependencyRevisionId = dep.getDynamicConstraintDependencyRevisionId();
if (!dynamicConstraintDependencyRevisionId.equals(dependencyRevisionId)) {
if (dynamicConstraintDependencyRevisionId.getBranch() != null) {
out.print(" branchConstraint=\"" + XMLHelper.escape(dynamicConstraintDependencyRevisionId.getBranch()) + "\"");
}
out.print(" revConstraint=\"" + XMLHelper.escape(dynamicConstraintDependencyRevisionId.getRevision()) + "\"");
}
if (dep.isForce()) {
out.print(" force=\"" + dep.isForce() + "\"");
}
if (dep.isChanging()) {
out.print(" changing=\"" + dep.isChanging() + "\"");
}
if (!dep.isTransitive()) {
out.print(" transitive=\"" + dep.isTransitive() + "\"");
}
StringBuilder sb = new StringBuilder();
for (String modConf : dep.getModuleConfigurations()) {
if (sb.length() > 0) {
sb.append(";");
}
sb.append(XMLHelper.escape(modConf)).append(listToPrefixedString(dep.getDependencyConfigurations(modConf), "->"));
}
out.print(" conf=\"" + sb + "\"");
printExtraAttributes(dep, out, " ");
DependencyArtifactDescriptor[] depArtifacts = dep.getAllDependencyArtifacts();
if (depArtifacts.length > 0) {
out.println(">");
}
printDependencyArtefacts(md, out, depArtifacts);
IncludeRule[] includes = dep.getAllIncludeRules();
if (includes.length > 0 && depArtifacts.length == 0) {
out.println(">");
}
printDependencyIncludeRules(md, out, includes);
ExcludeRule[] excludes = dep.getAllExcludeRules();
if (excludes.length > 0 && includes.length == 0 && depArtifacts.length == 0) {
out.println(">");
}
printDependencyExcludeRules(md, out, excludes);
if (includes.length + excludes.length + depArtifacts.length == 0) {
out.println("/>");
} else {
out.println("\t\t</dependency>");
}
}
use of org.apache.ivy.core.module.descriptor.ExcludeRule in project ant-ivy by apache.
the class XmlModuleDescriptorWriter method printDependencyExcludeRules.
private static void printDependencyExcludeRules(ModuleDescriptor md, PrintWriter out, ExcludeRule[] excludes) {
if (excludes.length > 0) {
for (ExcludeRule exclude : excludes) {
out.print(String.format("\t\t\t<exclude org=\"%s\" module=\"%s\" name=\"%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("/>");
}
}
}
use of org.apache.ivy.core.module.descriptor.ExcludeRule in project ant-ivy by apache.
the class PomModuleDescriptorParserTest method testOverrideParentVersionPropertyDependencyMgt.
@Test
public void testOverrideParentVersionPropertyDependencyMgt() throws ParseException, IOException {
settings.setDictatorResolver(new MockResolver() {
public ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data) throws ParseException {
try {
ModuleDescriptor moduleDescriptor = PomModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test-versionPropertyDependencyMgt.pom"), false);
return new ResolvedModuleRevision(null, null, moduleDescriptor, null);
} catch (IOException e) {
throw new AssertionError(e);
}
}
});
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test-overrideParentVersionPropertyDependencyMgt.pom"), false);
assertNotNull(md);
assertEquals(ModuleRevisionId.newInstance("org.apache", "test-parentdep", "1.0"), md.getModuleRevisionId());
DependencyDescriptor[] dds = md.getDependencies();
assertNotNull(dds);
assertEquals(2, dds.length);
assertEquals(ModuleRevisionId.newInstance("commons-collections", "commons-collections", "3.2.1"), dds[0].getDependencyRevisionId());
assertEquals(ModuleRevisionId.newInstance("commons-logging", "commons-logging", "1.1.1"), dds[1].getDependencyRevisionId());
ExcludeRule[] excludes = dds[0].getAllExcludeRules();
assertNotNull(excludes);
assertEquals(2, excludes.length);
assertEquals("javax.mail", excludes[0].getId().getModuleId().getOrganisation());
assertEquals("mail", excludes[0].getId().getModuleId().getName());
assertEquals("javax.jms", excludes[1].getId().getModuleId().getOrganisation());
assertEquals("jms", excludes[1].getId().getModuleId().getName());
}
Aggregations