Created
April 29, 2019 12:36
-
-
Save Opalo/eb38837e712c1e40186639f50d653c19 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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