1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-25 07:57:12 -07:00

import repositories from maven

make sure repository urls end with "/"
This commit is contained in:
evanchooly 2015-10-07 22:06:29 -04:00
parent 1f3fb8f3eb
commit 8ea8599189
4 changed files with 12 additions and 4 deletions

View file

@ -22,7 +22,7 @@ public class ProjectGenerator : KobaltLogger {
fun run(args: Args) {
if (File(args.buildFile).exists()) {
log(1, "Build file ${args.buildFile} already exists, not overwriting it")
return
// return
}
val compilerInfos = detect(File("."))
@ -74,6 +74,7 @@ public class ProjectGenerator : KobaltLogger {
put("artifactId", pom.artifactId ?: "com.example")
put("version", pom.version ?: "0.1")
put("name", pom.name ?: pom.artifactId)
put("repositories", pom.repos.map({ "\"${it}\"" }).join(","))
}
val properties = pom.properties

View file

@ -41,7 +41,7 @@ public class Kobalt {
val repos = ArrayList<String>(DEFAULT_REPOS)
fun addRepo(repo: String) = repos.add(repo)
fun addRepo(repo: String) = repos.add(if (repo.endsWith("/")) repo else repo + "/")
private val PROPERTY_KOBALT_VERSION = "kobalt.version"
private val KOBALT_PROPERTIES = "kobalt.properties"

View file

@ -19,6 +19,7 @@ public class Pom @javax.inject.Inject constructor(@Assisted val id: String,
var version: String? = null
var name: String? = null
var properties = sortedMapOf<String, String>()
var repos = listOf<String>()
public interface IFactory {
fun create(@Assisted id: String, @Assisted documentFile : java.io.File) : Pom
@ -62,9 +63,13 @@ public class Pom @javax.inject.Inject constructor(@Assisted val id: String,
artifactId = XPATH.compile("/project/artifactId").evaluate(document)
version = XPATH.compile("/project/version").evaluate(document)
name = XPATH.compile("/project/name").evaluate(document)
var list = XPATH.compile("/project/properties").evaluate(document, XPathConstants.NODESET) as NodeList
var list = XPATH.compile("/project/repositories").evaluate(document, XPathConstants.NODESET) as NodeList
var elem = list.item(0) as Element?
repos = elem.childElements()
.map({ it.getElementsByTagName("url").item(0).textContent })
list = XPATH.compile("/project/properties").evaluate(document, XPathConstants.NODESET) as NodeList
elem = list.item(0) as Element?
elem.childElements().forEach {
properties.put(it.nodeName, it.textContent)
}

View file

@ -2,6 +2,8 @@ import com.beust.kobalt.*
import com.beust.kobalt.plugin.packaging.assemble
{{imports}}
val repos = repos({{{repositories}}})
{{#properties}}
val {{first}} = "{{second}}"
{{/properties}}