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