如何从pom中删除项目依赖项?

时间:2014-07-17 15:36:08

标签: sbt

类似于:How to exclude library dependencies with explicit URL from generated pom?

我想从目标pom中删除项目依赖项,因为我使用fat jar将其合并。

我尝试projectDependencies in makePom := Nil,但看起来任务makePomroot/*:ivyModule获取其依赖关系:

makePom -> ivyModule -> moduleSettings -> allDependencies -> projectDependencies

1 个答案:

答案 0 :(得分:2)

您可以覆盖process类上的MakePomConfiguration字段,并提供一个功能,从生成的dependencies中删除pom.xml元素。

build.sbt

import xml.{NodeSeq, Node => XNode, Elem}
import xml.transform.{RuleTransformer, RewriteRule}

libraryDependencies += "org.apache.derby" % "derby" % "10.4.1.3"

def dependenciesFilter(n: XNode) = new RuleTransformer(new RewriteRule {
  override def transform(n: XNode): NodeSeq = n match {
    case e: Elem if e.label == "dependencies" => NodeSeq.Empty
    case other => other
  }
}).transform(n).head

makePomConfiguration := makePomConfiguration.value.copy(process = dependenciesFilter)