mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-27 00:38:11 -07:00
import repositories from maven
make sure repository urls end with "/"
This commit is contained in:
parent
1f3fb8f3eb
commit
8ea8599189
4 changed files with 12 additions and 4 deletions
|
@ -22,7 +22,7 @@ public class ProjectGenerator : KobaltLogger {
|
||||||
fun run(args: Args) {
|
fun run(args: Args) {
|
||||||
if (File(args.buildFile).exists()) {
|
if (File(args.buildFile).exists()) {
|
||||||
log(1, "Build file ${args.buildFile} already exists, not overwriting it")
|
log(1, "Build file ${args.buildFile} already exists, not overwriting it")
|
||||||
return
|
// return
|
||||||
}
|
}
|
||||||
|
|
||||||
val compilerInfos = detect(File("."))
|
val compilerInfos = detect(File("."))
|
||||||
|
@ -74,6 +74,7 @@ public class ProjectGenerator : KobaltLogger {
|
||||||
put("artifactId", pom.artifactId ?: "com.example")
|
put("artifactId", pom.artifactId ?: "com.example")
|
||||||
put("version", pom.version ?: "0.1")
|
put("version", pom.version ?: "0.1")
|
||||||
put("name", pom.name ?: pom.artifactId)
|
put("name", pom.name ?: pom.artifactId)
|
||||||
|
put("repositories", pom.repos.map({ "\"${it}\"" }).join(","))
|
||||||
}
|
}
|
||||||
|
|
||||||
val properties = pom.properties
|
val properties = pom.properties
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class Kobalt {
|
||||||
|
|
||||||
val repos = ArrayList<String>(DEFAULT_REPOS)
|
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 PROPERTY_KOBALT_VERSION = "kobalt.version"
|
||||||
private val KOBALT_PROPERTIES = "kobalt.properties"
|
private val KOBALT_PROPERTIES = "kobalt.properties"
|
||||||
|
|
|
@ -19,6 +19,7 @@ public class Pom @javax.inject.Inject constructor(@Assisted val id: String,
|
||||||
var version: String? = null
|
var version: String? = null
|
||||||
var name: String? = null
|
var name: String? = null
|
||||||
var properties = sortedMapOf<String, String>()
|
var properties = sortedMapOf<String, String>()
|
||||||
|
var repos = listOf<String>()
|
||||||
|
|
||||||
public interface IFactory {
|
public interface IFactory {
|
||||||
fun create(@Assisted id: String, @Assisted documentFile : java.io.File) : Pom
|
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)
|
artifactId = XPATH.compile("/project/artifactId").evaluate(document)
|
||||||
version = XPATH.compile("/project/version").evaluate(document)
|
version = XPATH.compile("/project/version").evaluate(document)
|
||||||
name = XPATH.compile("/project/name").evaluate(document)
|
name = XPATH.compile("/project/name").evaluate(document)
|
||||||
|
var list = XPATH.compile("/project/repositories").evaluate(document, XPathConstants.NODESET) as NodeList
|
||||||
var list = XPATH.compile("/project/properties").evaluate(document, XPathConstants.NODESET) as NodeList
|
|
||||||
var elem = list.item(0) as Element?
|
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 {
|
elem.childElements().forEach {
|
||||||
properties.put(it.nodeName, it.textContent)
|
properties.put(it.nodeName, it.textContent)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@ import com.beust.kobalt.*
|
||||||
import com.beust.kobalt.plugin.packaging.assemble
|
import com.beust.kobalt.plugin.packaging.assemble
|
||||||
{{imports}}
|
{{imports}}
|
||||||
|
|
||||||
|
val repos = repos({{{repositories}}})
|
||||||
|
|
||||||
{{#properties}}
|
{{#properties}}
|
||||||
val {{first}} = "{{second}}"
|
val {{first}} = "{{second}}"
|
||||||
{{/properties}}
|
{{/properties}}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue