use of org.apache.ivy.core.module.descriptor.DependencyDescriptor 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.DependencyDescriptor in project ant-ivy by apache.
the class PomModuleDescriptorWriter method getDependencies.
private static DependencyDescriptor[] getDependencies(ModuleDescriptor md, PomWriterOptions options) {
String[] confs = ConfigurationUtils.replaceWildcards(options.getConfs(), md);
List<DependencyDescriptor> result = new ArrayList<>();
for (DependencyDescriptor dd : md.getDependencies()) {
String[] depConfs = dd.getDependencyConfigurations(confs);
if (depConfs != null && depConfs.length > 0) {
result.add(dd);
}
}
return result.toArray(new DependencyDescriptor[result.size()]);
}
use of org.apache.ivy.core.module.descriptor.DependencyDescriptor in project ant-ivy by apache.
the class XmlModuleDescriptorWriter method printDependencies.
private static void printDependencies(ModuleDescriptor md, PrintWriter out) {
DependencyDescriptor[] dds = md.getDependencies();
if (dds.length > 0) {
out.println("\t<dependencies>");
for (DependencyDescriptor dep : dds) {
out.print("\t\t");
printDependency(md, dep, out);
}
printAllExcludes(md, out);
printAllMediators(md, out);
out.println("\t</dependencies>");
}
}
use of org.apache.ivy.core.module.descriptor.DependencyDescriptor in project ant-ivy by apache.
the class BasicResolver method parse.
public ResolvedModuleRevision parse(final ResolvedResource mdRef, DependencyDescriptor dd, ResolveData data) throws ParseException {
DependencyDescriptor nsDd = dd;
dd = toSystem(nsDd);
ModuleRevisionId mrid = dd.getDependencyRevisionId();
ModuleDescriptorParser parser = ModuleDescriptorParserRegistry.getInstance().getParser(mdRef.getResource());
if (parser == null) {
Message.warn("no module descriptor parser available for " + mdRef.getResource());
return null;
}
Message.verbose("\t" + getName() + ": found md file for " + mrid);
Message.verbose("\t\t=> " + mdRef);
Message.debug("\tparser = " + parser);
ModuleRevisionId resolvedMrid = mrid;
// first check if this dependency has not yet been resolved
if (getSettings().getVersionMatcher().isDynamic(mrid)) {
resolvedMrid = ModuleRevisionId.newInstance(mrid, mdRef.getRevision());
IvyNode node = data.getNode(resolvedMrid);
if (node != null && node.getModuleRevision() != null) {
// this revision has already be resolved : return it
if (node.getDescriptor() == null || !node.getDescriptor().isDefault()) {
Message.verbose("\t" + getName() + ": revision already resolved: " + resolvedMrid);
node.getModuleRevision().getReport().setSearched(true);
return node.getModuleRevision();
}
Message.verbose("\t" + getName() + ": found already resolved revision: " + resolvedMrid + ": but it's a default one, maybe we can find a better one");
}
}
Artifact moduleArtifact = parser.getMetadataArtifact(resolvedMrid, mdRef.getResource());
return getRepositoryCacheManager().cacheModuleDescriptor(this, mdRef, dd, moduleArtifact, downloader, getCacheOptions(data));
}
use of org.apache.ivy.core.module.descriptor.DependencyDescriptor 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;
}
Aggregations