Created
April 10, 2026 03:32
-
-
Save xuwei-k/00cad0a6ea1688563ed3e48272f5b43e 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
| @transient | |
| val validatePom = taskKey[Unit]("") | |
| def checkPom(pom: scala.xml.Node): List[String] = { | |
| List( | |
| "modelVersion", | |
| "groupId", | |
| "artifactId", | |
| "version", | |
| "packaging", | |
| "name", | |
| "description", | |
| "url", | |
| "licenses", | |
| "developers" | |
| ).flatMap { tag => | |
| if ((pom \ tag).isEmpty) List("<" + tag + ">") else Nil | |
| } ::: List(("scm", "url"), ("scm", "connection")).flatMap { case (tag1, tag2) => | |
| if ((pom \ tag1 \ tag2).isEmpty) List("<" + tag1 + "><" + tag2 + ">") else Nil | |
| } | |
| } | |
| validatePom := { | |
| val s = streams.value | |
| if ((publish / skip).value) { | |
| s.log.info(s"[name = ${name.value}][base = ${baseDirectory.value}] skip validatePom task") | |
| None | |
| } else { | |
| makePom.?.value.map { ff => | |
| val f = fileConverter.value.toPath(ff).toFile | |
| val errors = checkPom(scala.xml.XML.loadFile(f)) | |
| errors.foreach { e => | |
| s.log.error("missing tag " + e) | |
| } | |
| if (errors.isEmpty) { | |
| s.log.info(s"[name = ${name.value}][base = ${baseDirectory.value}] success validatePom") | |
| } | |
| errors.isEmpty | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment