summaryrefslogtreecommitdiff
path: root/scalalib
diff options
context:
space:
mode:
authorAndres Pipicello <andres.pipicello@olx.com>2019-05-24 22:14:57 -0300
committerTobias Roeser <le.petit.fou@web.de>2019-06-28 08:37:39 +0200
commit8b77cf6cec10d5f573f56283eca4302029b49d42 (patch)
treeaa862bfe074a91eed641d46484aa6d7e4cca9a50 /scalalib
parentc3474360661b2cf87b3bc7cf8446b8ea78d7927f (diff)
downloadmill-8b77cf6cec10d5f573f56283eca4302029b49d42.tar.gz
mill-8b77cf6cec10d5f573f56283eca4302029b49d42.tar.bz2
mill-8b77cf6cec10d5f573f56283eca4302029b49d42.zip
Using coursier for reading poms instead of ad-hoc xml parsing
Diffstat (limited to 'scalalib')
-rwxr-xr-xscalalib/src/GenIdeaImpl.scala14
1 files changed, 6 insertions, 8 deletions
diff --git a/scalalib/src/GenIdeaImpl.scala b/scalalib/src/GenIdeaImpl.scala
index 2db28327..a9eefc65 100755
--- a/scalalib/src/GenIdeaImpl.scala
+++ b/scalalib/src/GenIdeaImpl.scala
@@ -1,6 +1,8 @@
package mill.scalalib
import ammonite.runtime.SpecialClassLoader
+import coursier.core.compatibility.xmlParseDom
+import coursier.maven.Pom
import coursier.{LocalRepositories, Repositories}
import mill.api.Ctx.{Home, Log}
import mill.api.Strict.Agg
@@ -207,19 +209,15 @@ object GenIdeaImpl {
// Hack so that Intellij does not complain about unresolved magic
// imports in build.sc when in fact they are resolved
- def sbtLibraryNameFromPom(pom : os.Path) : String = {
- val xml = scala.xml.XML.loadFile(pom.toIO)
-
- val parent = xml \ "parent"
- val artifactId = (xml \ "artifactId").text
- val groupId = Some(xml \ "groupId").filter(_.nonEmpty).getOrElse(parent \ "groupId").text
- val version = Some(xml \ "version").filter(_.nonEmpty).getOrElse(parent \ "version").text
+ def sbtLibraryNameFromPom(pomPath : os.Path) : String = {
+ val pom = xmlParseDom(os.read(pomPath)).flatMap(Pom.project).right.get
+ val artifactId = pom.module.name.value
val artifactWithScalaVersion = artifactId.substring(artifactId.length - 5) match {
case "_2.10" | "_2.11" | "_2.12" => artifactId
case _ => artifactId + "_2.12"
}
- s"SBT: $groupId:$artifactWithScalaVersion:$version:jar"
+ s"SBT: ${pom.module.organization.value}:$artifactWithScalaVersion:${pom.version}:jar"
}
def libraryNames(resolvedJar: ResolvedLibrary) : Seq[String] = resolvedJar match {