mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Add <kobalt-compiler-version> and -repo to settings.
This commit is contained in:
parent
7bea179d69
commit
e51664edea
4 changed files with 27 additions and 7 deletions
|
@ -22,16 +22,25 @@ class Kobalt {
|
|||
val repos : Set<HostConfig>
|
||||
get() {
|
||||
val settingsRepos = Kobalt.context?.settings?.defaultRepos ?: emptyList()
|
||||
// Repos from <default-repos> in the settings
|
||||
val result = ArrayList(
|
||||
(if (settingsRepos.isEmpty()) Constants.DEFAULT_REPOS
|
||||
else settingsRepos)
|
||||
.map { HostConfig(it) })
|
||||
|
||||
// Repo from <kobalt-compiler-repo> in the settings
|
||||
Kobalt.context?.settings?.kobaltCompilerRepo?.let {
|
||||
result.add(HostConfig(it))
|
||||
}
|
||||
|
||||
// Repos from the repo contributors
|
||||
Kobalt.context?.pluginInfo?.repoContributors?.forEach {
|
||||
result.addAll(it.reposFor(null))
|
||||
}
|
||||
|
||||
// Repos from the build file
|
||||
result.addAll(reposFromBuildFiles)
|
||||
|
||||
return result.toHashSet()
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,12 @@ class KobaltSettingsXml {
|
|||
|
||||
@XmlElement(name = "default-repos") @JvmField
|
||||
var defaultRepos: DefaultReposXml? = null
|
||||
|
||||
@XmlElement(name = "kobalt-compiler-version") @JvmField
|
||||
var kobaltCompilerVersion: String = "1.0.0"
|
||||
|
||||
@XmlElement(name = "kobalt-compiler-repo") @JvmField
|
||||
var kobaltCompilerRepo: String? = null
|
||||
}
|
||||
|
||||
class DefaultReposXml {
|
||||
|
@ -40,6 +46,9 @@ class KobaltSettings @Inject constructor(val xmlFile: KobaltSettingsXml) {
|
|||
|
||||
val defaultRepos = xmlFile.defaultRepos?.repo
|
||||
|
||||
var kobaltCompilerVersion = xmlFile.kobaltCompilerVersion
|
||||
var kobaltCompilerRepo = xmlFile.kobaltCompilerRepo
|
||||
|
||||
companion object {
|
||||
val SETTINGS_FILE_PATH = KFiles.joinDir(KFiles.HOME_KOBALT_DIR.absolutePath, "settings.xml")
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.beust.kobalt.TaskResult
|
|||
import com.beust.kobalt.api.*
|
||||
import com.beust.kobalt.internal.ICompilerAction
|
||||
import com.beust.kobalt.internal.JvmCompiler
|
||||
import com.beust.kobalt.internal.KobaltSettings
|
||||
import com.beust.kobalt.kotlin.ParentLastClassLoader
|
||||
import com.beust.kobalt.maven.DependencyManager
|
||||
import com.beust.kobalt.maven.dependency.FileDependency
|
||||
|
@ -32,14 +33,13 @@ class KotlinCompiler @Inject constructor(
|
|||
val files: KFiles,
|
||||
val dependencyManager: DependencyManager,
|
||||
val executors: KobaltExecutors,
|
||||
val settings: KobaltSettings,
|
||||
val jvmCompiler: JvmCompiler) {
|
||||
companion object {
|
||||
val KOTLIN_VERSION = "1.0.0"
|
||||
}
|
||||
|
||||
val compilerAction = object: ICompilerAction {
|
||||
override fun compile(projectName: String?, info: CompilerActionInfo): TaskResult {
|
||||
log(1, " Kotlin compiling " + Strings.pluralizeAll("file", info.sourceFiles.size))
|
||||
val version = settings.kobaltCompilerVersion
|
||||
log(1, " Kotlin $version compiling " + Strings.pluralizeAll("file", info.sourceFiles.size))
|
||||
val cp = compilerFirst(info.dependencies.map {it.jarFile.get()})
|
||||
val infoDir = info.directory
|
||||
val outputDir = if (infoDir != null) {
|
||||
|
@ -134,7 +134,8 @@ class KotlinCompiler @Inject constructor(
|
|||
otherClasspath: List<String>, sourceFiles: List<String>, outputDir: File, args: List<String>) : TaskResult {
|
||||
|
||||
val executor = executors.newExecutor("KotlinCompiler", 10)
|
||||
val compilerDep = dependencyManager.create("org.jetbrains.kotlin:kotlin-compiler-embeddable:$KOTLIN_VERSION")
|
||||
val compilerVersion = settings.kobaltCompilerVersion
|
||||
val compilerDep = dependencyManager.create("org.jetbrains.kotlin:kotlin-compiler-embeddable:$compilerVersion")
|
||||
val deps = dependencyManager.transitiveClosure(listOf(compilerDep))
|
||||
|
||||
// Force a download of the compiler dependencies
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.beust.kobalt.api.*
|
|||
import com.beust.kobalt.api.annotation.Directive
|
||||
import com.beust.kobalt.internal.BaseJvmPlugin
|
||||
import com.beust.kobalt.internal.JvmCompilerPlugin
|
||||
import com.beust.kobalt.internal.KobaltSettings
|
||||
import com.beust.kobalt.maven.DependencyManager
|
||||
import com.beust.kobalt.maven.dependency.FileDependency
|
||||
import com.beust.kobalt.misc.KFiles
|
||||
|
@ -18,7 +19,7 @@ import javax.inject.Singleton
|
|||
|
||||
@Singleton
|
||||
class KotlinPlugin @Inject constructor(val executors: KobaltExecutors, val dependencyManager: DependencyManager,
|
||||
override val configActor: ConfigActor<KotlinConfig>)
|
||||
val settings: KobaltSettings, override val configActor: ConfigActor<KotlinConfig>)
|
||||
: BaseJvmPlugin<KotlinConfig>(configActor), IDocContributor, IClasspathContributor, ICompilerContributor, IBuildConfigContributor {
|
||||
|
||||
companion object {
|
||||
|
@ -93,7 +94,7 @@ class KotlinPlugin @Inject constructor(val executors: KobaltExecutors, val depen
|
|||
}
|
||||
|
||||
private fun getKotlinCompilerJar(name: String): String {
|
||||
val id = "org.jetbrains.kotlin:$name:${KotlinCompiler.KOTLIN_VERSION}"
|
||||
val id = "org.jetbrains.kotlin:$name:${settings.kobaltCompilerVersion}"
|
||||
val dep = dependencyManager.create(id)
|
||||
val result = dep.jarFile.get().absolutePath
|
||||
return result
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue