diff --git a/src/main/kotlin/com/beust/kobalt/ProjectGenerator.kt b/src/main/kotlin/com/beust/kobalt/ProjectGenerator.kt index 6b25c8d1..2a59027a 100644 --- a/src/main/kotlin/com/beust/kobalt/ProjectGenerator.kt +++ b/src/main/kotlin/com/beust/kobalt/ProjectGenerator.kt @@ -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 diff --git a/src/main/kotlin/com/beust/kobalt/api/Kobalt.kt b/src/main/kotlin/com/beust/kobalt/api/Kobalt.kt index 00049ea7..9873b3b0 100644 --- a/src/main/kotlin/com/beust/kobalt/api/Kobalt.kt +++ b/src/main/kotlin/com/beust/kobalt/api/Kobalt.kt @@ -41,7 +41,7 @@ public class Kobalt { val repos = ArrayList(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" diff --git a/src/main/kotlin/com/beust/kobalt/maven/Pom.kt b/src/main/kotlin/com/beust/kobalt/maven/Pom.kt index 0bfea321..fa8507a5 100644 --- a/src/main/kotlin/com/beust/kobalt/maven/Pom.kt +++ b/src/main/kotlin/com/beust/kobalt/maven/Pom.kt @@ -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() + var repos = listOf() 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) } diff --git a/src/main/resources/build-template.mustache b/src/main/resources/build-template.mustache index 663f032c..adde7a4e 100644 --- a/src/main/resources/build-template.mustache +++ b/src/main/resources/build-template.mustache @@ -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}}