Skip to content

Instantly share code, notes, and snippets.

@Opalo
Created April 29, 2019 12:36
Show Gist options
  • Save Opalo/eb38837e712c1e40186639f50d653c19 to your computer and use it in GitHub Desktop.
Save Opalo/eb38837e712c1e40186639f50d653c19 to your computer and use it in GitHub Desktop.
pomPostProcess := { input: Node =>
new RuleTransformer(new RewriteRule {
override def transform(node: Node): NodeSeq = node match {
case e: Elem if e.label == "dependency" && isGeneratorDependency(findChild(e, "groupId"), findChild(e, "artifactId")) =>
def txt(label: String): String = "\"" + e.child.filter(_.label == label).flatMap(_.text).mkString + "\""
Comment(s""" Generator dependency ${txt("groupId")} % ${txt("artifactId")} % ${txt("version")} has been omitted """)
case _ => node
}
def isGeneratorDependency(organization: Option[Node], name: Option[Node]): Boolean = {
(for {
o <- organization
n <- name
v = generatorDependencies.exists(d => d.organization == o.text && (d.name == n.text || s"${d.name}_$scalaBinaryVersion" == n.text))
} yield v).getOrElse(false)
}
def findChild(e: Elem, lbl: String): Option[Node] = {
e.child.find(_.label == lbl)
}
}).transform(input).head
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment