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

Added buildFileClasspat().

This commit is contained in:
Cedric Beust 2016-06-24 04:14:08 -08:00
parent c06e92b679
commit 25b97dd21f
4 changed files with 22 additions and 0 deletions

View file

@ -57,6 +57,11 @@ fun repos(vararg repos : String) {
repos.forEach { Kobalt.addRepo(HostConfig(it)) } repos.forEach { Kobalt.addRepo(HostConfig(it)) }
} }
@Directive
fun buildFileClasspath(vararg deps: String) {
deps.forEach { Kobalt.addBuildFileClasspath(it) }
}
@Directive @Directive
fun authRepos(vararg repos : HostConfig) { fun authRepos(vararg repos : HostConfig) {
repos.forEach { Kobalt.addRepo(it) } repos.forEach { Kobalt.addRepo(it) }

View file

@ -4,6 +4,7 @@ import com.beust.kobalt.Constants
import com.beust.kobalt.HostConfig import com.beust.kobalt.HostConfig
import com.beust.kobalt.Plugins import com.beust.kobalt.Plugins
import com.beust.kobalt.internal.PluginInfo import com.beust.kobalt.internal.PluginInfo
import com.beust.kobalt.maven.DependencyManager
import com.google.inject.Guice import com.google.inject.Guice
import com.google.inject.Injector import com.google.inject.Injector
import com.google.inject.Module import com.google.inject.Module
@ -65,6 +66,13 @@ class Kobalt {
if (repo.url.endsWith("/")) repo if (repo.url.endsWith("/")) repo
else repo.copy(url = (repo.url + "/"))) else repo.copy(url = (repo.url + "/")))
val buildFileClasspath = arrayListOf<IClasspathDependency>()
fun addBuildFileClasspath(dep: String) {
val dependencyManager = Kobalt.INJECTOR.getInstance(DependencyManager::class.java)
buildFileClasspath.add(dependencyManager.create(dep))
}
private val KOBALT_PROPERTIES = "kobalt.properties" private val KOBALT_PROPERTIES = "kobalt.properties"
private val PROPERTY_KOBALT_VERSION = "kobalt.version" private val PROPERTY_KOBALT_VERSION = "kobalt.version"
private val PROPERTY_KOBALT_VERSION_CHECK_TIMEOUT = "kobalt.version.checkTimeout" // ISO-8601 private val PROPERTY_KOBALT_VERSION_CHECK_TIMEOUT = "kobalt.version.checkTimeout" // ISO-8601

View file

@ -121,9 +121,11 @@ public class BuildFileCompiler @Inject constructor(@Assisted("buildFiles") val b
log(2, " Need to recompile ${buildFile.name}") log(2, " Need to recompile ${buildFile.name}")
buildScriptJarFile.delete() buildScriptJarFile.delete()
val buildFileClasspath = Kobalt.buildFileClasspath.map { it.jarFile.get() }.map { it.absolutePath }
val result = kotlinCompilePrivate { val result = kotlinCompilePrivate {
classpath(files.kobaltJar) classpath(files.kobaltJar)
classpath(pluginUrls.map { it.file }) classpath(pluginUrls.map { it.file })
classpath(buildFileClasspath)
sourceFiles(listOf(buildFile.realPath.toFile().absolutePath)) sourceFiles(listOf(buildFile.realPath.toFile().absolutePath))
output = buildScriptJarFile output = buildScriptJarFile
}.compile(context = context) }.compile(context = context)

View file

@ -22,6 +22,7 @@ class ParsedBuildFile(val buildFile: BuildFile, val context: KobaltContext, val
val dependencyManager: DependencyManager, val files: KFiles) { val dependencyManager: DependencyManager, val files: KFiles) {
val pluginList = arrayListOf<String>() val pluginList = arrayListOf<String>()
val repos = arrayListOf<String>() val repos = arrayListOf<String>()
val buildFileClasspath = arrayListOf<String>()
val profileLines = arrayListOf<String>() val profileLines = arrayListOf<String>()
val pluginUrls = arrayListOf<URL>() val pluginUrls = arrayListOf<URL>()
val projects = arrayListOf<Project>() val projects = arrayListOf<Project>()
@ -51,6 +52,11 @@ class ParsedBuildFile(val buildFile: BuildFile, val context: KobaltContext, val
index = line.indexOf("repos(") index = line.indexOf("repos(")
if (index >= 0) { if (index >= 0) {
current = repos current = repos
} else {
index = line.indexOf("buildFileClasspath(")
if (index >= 0) {
current = buildFileClasspath
}
} }
} }
} }
@ -91,6 +97,7 @@ class ParsedBuildFile(val buildFile: BuildFile, val context: KobaltContext, val
repos.forEach { preBuildScript.add(it) } repos.forEach { preBuildScript.add(it) }
pluginList.forEach { preBuildScript.add(it) } pluginList.forEach { preBuildScript.add(it) }
buildFileClasspath.forEach { preBuildScript.add(it) }
} }
private fun initPluginUrls() { private fun initPluginUrls() {