mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 16:28:12 -07:00
Remove dependency on kotlinx.dom.
This commit is contained in:
parent
7ae8f190b1
commit
a83e1f4a7d
2 changed files with 19 additions and 8 deletions
|
@ -67,8 +67,7 @@ val kobaltPluginApi = project {
|
||||||
developerConnection = "git@github.com:cbeust/kobalt.git")
|
developerConnection = "git@github.com:cbeust/kobalt.git")
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile("org.jetbrains.kotlinx:kotlinx.dom:0.0.10",
|
compile(
|
||||||
|
|
||||||
"com.google.inject:guice:4.0",
|
"com.google.inject:guice:4.0",
|
||||||
"com.google.inject.extensions:guice-assistedinject:4.0",
|
"com.google.inject.extensions:guice-assistedinject:4.0",
|
||||||
"javax.inject:javax.inject:1",
|
"javax.inject:javax.inject:1",
|
||||||
|
|
|
@ -3,11 +3,9 @@ package com.beust.kobalt.maven
|
||||||
import com.beust.kobalt.misc.toString
|
import com.beust.kobalt.misc.toString
|
||||||
import com.beust.kobalt.misc.warn
|
import com.beust.kobalt.misc.warn
|
||||||
import com.google.inject.assistedinject.Assisted
|
import com.google.inject.assistedinject.Assisted
|
||||||
import kotlinx.dom.childElements
|
|
||||||
import org.w3c.dom.Element
|
import org.w3c.dom.Element
|
||||||
import org.w3c.dom.NodeList
|
import org.w3c.dom.NodeList
|
||||||
import org.xml.sax.InputSource
|
import javax.xml.parsers.DocumentBuilderFactory
|
||||||
import java.io.FileReader
|
|
||||||
import javax.xml.xpath.XPathConstants
|
import javax.xml.xpath.XPathConstants
|
||||||
|
|
||||||
class Pom @javax.inject.Inject constructor(@Assisted val id: String,
|
class Pom @javax.inject.Inject constructor(@Assisted val id: String,
|
||||||
|
@ -66,8 +64,8 @@ class Pom @javax.inject.Inject constructor(@Assisted val id: String,
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val DEPENDENCIES = XPATH.compile("/project/dependencies/dependency")
|
val DEPENDENCIES = XPATH.compile("/project/dependencies/dependency")
|
||||||
|
val document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(documentFile)
|
||||||
|
|
||||||
val document = kotlinx.dom.parseXml(InputSource(FileReader(documentFile)))
|
|
||||||
groupId = XPATH.compile("/project/groupId").evaluate(document)
|
groupId = XPATH.compile("/project/groupId").evaluate(document)
|
||||||
artifactId = XPATH.compile("/project/artifactId").evaluate(document)
|
artifactId = XPATH.compile("/project/artifactId").evaluate(document)
|
||||||
version = XPATH.compile("/project/version").evaluate(document)
|
version = XPATH.compile("/project/version").evaluate(document)
|
||||||
|
@ -75,11 +73,12 @@ class Pom @javax.inject.Inject constructor(@Assisted val id: String,
|
||||||
var repositoriesList = XPATH.compile("/project/repositories").evaluate(document, XPathConstants.NODESET)
|
var repositoriesList = XPATH.compile("/project/repositories").evaluate(document, XPathConstants.NODESET)
|
||||||
as NodeList
|
as NodeList
|
||||||
var repoElem = repositoriesList.item(0) as Element?
|
var repoElem = repositoriesList.item(0) as Element?
|
||||||
repositories = repoElem.childElements().map({ it.getElementsByTagName("url").item(0).textContent })
|
repositories = childElements(repoElem).map({ it.getElementsByTagName("url").item(0)
|
||||||
|
.textContent })
|
||||||
|
|
||||||
val propertiesList = XPATH.compile("/project/properties").evaluate(document, XPathConstants.NODESET) as NodeList
|
val propertiesList = XPATH.compile("/project/properties").evaluate(document, XPathConstants.NODESET) as NodeList
|
||||||
var propsElem = propertiesList.item(0) as Element?
|
var propsElem = propertiesList.item(0) as Element?
|
||||||
propsElem.childElements().forEach {
|
childElements(propsElem).forEach {
|
||||||
properties.put(it.nodeName, it.textContent)
|
properties.put(it.nodeName, it.textContent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,5 +110,18 @@ class Pom @javax.inject.Inject constructor(@Assisted val id: String,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun childElements(repoElem: Element?): List<Element> {
|
||||||
|
val result = arrayListOf<Element>()
|
||||||
|
if (repoElem != null) {
|
||||||
|
for (i in 0..repoElem.childNodes.length - 1) {
|
||||||
|
val elem = repoElem.childNodes.item(i)
|
||||||
|
if (elem is Element) {
|
||||||
|
result.add(elem)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
override fun toString() = toString("Pom", "id", id)
|
override fun toString() = toString("Pom", "id", id)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue