From 2585c57760a943a42b344462f1b292d72c291b4e Mon Sep 17 00:00:00 2001 From: Indrajit Raychaudhuri Date: Tue, 6 Sep 2011 17:29:42 +0530 Subject: [PATCH] Honor in when available --- ivy/IvyActions.scala | 2 +- ivy/MakePom.scala | 31 ++++++++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/ivy/IvyActions.scala b/ivy/IvyActions.scala index c1eef5913..3a40aadf0 100644 --- a/ivy/IvyActions.scala +++ b/ivy/IvyActions.scala @@ -68,7 +68,7 @@ object IvyActions { import configuration.{allRepositories, moduleInfo, configurations, extra, file, filterRepositories, process} module.withModule(log) { (ivy, md, default) => - (new MakePom).write(ivy, md, moduleInfo, configurations, extra, process, filterRepositories, allRepositories, file) + (new MakePom(log)).write(ivy, md, moduleInfo, configurations, extra, process, filterRepositories, allRepositories, file) log.info("Wrote " + file.getAbsolutePath) } } diff --git a/ivy/MakePom.scala b/ivy/MakePom.scala index dc31760b1..fc0a90c16 100644 --- a/ivy/MakePom.scala +++ b/ivy/MakePom.scala @@ -14,11 +14,11 @@ import Configurations.Optional import org.apache.ivy.{core, plugins, Ivy} import core.settings.IvySettings import core.module.{descriptor, id} -import descriptor.{DependencyDescriptor, License, ModuleDescriptor} +import descriptor.{DependencyDescriptor, License, ModuleDescriptor, ExcludeRule} import id.ModuleRevisionId import plugins.resolver.{ChainResolver, DependencyResolver, IBiblioResolver} -class MakePom +class MakePom(val log: Logger) { def encoding = "UTF-8" def write(ivy: Ivy, module: ModuleDescriptor, moduleInfo: ModuleInfo, configurations: Option[Iterable[Configuration]], extra: NodeSeq, process: XNode => XNode, filterRepositories: MavenRepository => Boolean, allRepositories: Boolean, output: File): Unit = @@ -123,11 +123,21 @@ class MakePom def makeDependency(dependency: DependencyDescriptor): NodeSeq = { val mrid = dependency.getDependencyRevisionId + val excl = dependency.getExcludeRules(dependency.getModuleConfigurations) {mrid.getOrganisation} {mrid.getName} {mrid.getRevision} - { scopeAndOptional(dependency)} + { scopeAndOptional(dependency) } + { + val (warns, excls) = List.separate(excl.map(makeExclusion)) + if(!warns.isEmpty) log.warn(warns.mkString(IO.Newline)) + if(excls.isEmpty) NodeSeq.Empty + else + + { excls } + + } } @@ -159,6 +169,21 @@ class MakePom (scope, !opt.isEmpty) } + def makeExclusion(exclRule: ExcludeRule): Either[String, NodeSeq] = + { + val m = exclRule.getId.getModuleId + val (g, a) = (m.getOrganisation, m.getName) + if(g == null || g.isEmpty || g == "*" || a.isEmpty || a == "*") + Left("Skipped generating '' for %s. Dependency exclusion should have both 'org' and 'module' to comply with Maven POM's schema.".format(m)) + else + Right( + + {g} + {a} + + ) + } + def makeRepositories(settings: IvySettings, includeAll: Boolean, filterRepositories: MavenRepository => Boolean) = { class MavenRepo(name: String, snapshots: Boolean, releases: Boolean)