mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 00:17:11 -07:00
Add compiler version and flags in KotlinConfig.
This commit is contained in:
parent
48bbdfd1ff
commit
816c609c17
6 changed files with 72 additions and 13 deletions
|
@ -11,6 +11,25 @@ import org.eclipse.aether.repository.Proxy
|
|||
import java.io.File
|
||||
import java.net.InetSocketAddress
|
||||
|
||||
var BUILD_SCRIPT_CONFIG : BuildScriptConfig? = null
|
||||
|
||||
class BuildScriptConfig {
|
||||
// var repos = listOf<String>()
|
||||
// var plugins = listOf<String>()
|
||||
|
||||
// The following settings are used to modify the compiler used to
|
||||
// compile the build file. Projects should use kotlinCompiler { compilerVersion } to configure
|
||||
// the Kotin compiler for their source files.
|
||||
var kobaltCompilerVersion : String? = null
|
||||
var kobaltCompilerRepo: String? = null
|
||||
var kobaltCompilerFlags: String? = null
|
||||
}
|
||||
|
||||
@Directive
|
||||
fun buildScript(init: BuildScriptConfig.() -> Unit) {
|
||||
BUILD_SCRIPT_CONFIG = BuildScriptConfig().apply { init() }
|
||||
}
|
||||
|
||||
@Directive
|
||||
fun homeDir(vararg dirs: String) : String = SystemProperties.homeDir +
|
||||
File.separator + dirs.toMutableList().joinToString(File.separator)
|
||||
|
|
|
@ -34,7 +34,7 @@ class JvmCompiler @Inject constructor(val dependencyManager: DependencyManager)
|
|||
val addedFlags = contributorFlags + ArrayList(info.compilerArgs)
|
||||
|
||||
validateClasspath(allDependencies.map { it.jarFile.get().absolutePath })
|
||||
return action.compile(project?.name, info.copy(dependencies = allDependencies, compilerArgs = addedFlags))
|
||||
return action.compile(project, info.copy(dependencies = allDependencies, compilerArgs = addedFlags))
|
||||
}
|
||||
|
||||
private fun validateClasspath(cp: List<String>) {
|
||||
|
@ -47,5 +47,5 @@ class JvmCompiler @Inject constructor(val dependencyManager: DependencyManager)
|
|||
}
|
||||
|
||||
interface ICompilerAction {
|
||||
fun compile(projectName: String?, info: CompilerActionInfo): TaskResult
|
||||
fun compile(project: Project?, info: CompilerActionInfo): TaskResult
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package com.beust.kobalt.internal
|
||||
|
||||
import com.beust.kobalt.BUILD_SCRIPT_CONFIG
|
||||
import com.beust.kobalt.Constants
|
||||
import com.beust.kobalt.ProxyConfig
|
||||
import com.beust.kobalt.homeDir
|
||||
|
@ -100,9 +101,32 @@ class KobaltSettings @Inject constructor(val xmlFile: KobaltSettingsXml) {
|
|||
}
|
||||
}
|
||||
|
||||
var kobaltCompilerVersion = xmlFile.kobaltCompilerVersion
|
||||
var kobaltCompilerRepo = xmlFile.kobaltCompilerRepo
|
||||
var kobaltCompilerFlags = xmlFile.kobaltCompilerFlags
|
||||
val kobaltCompilerVersion : String?
|
||||
get() {
|
||||
return if (BUILD_SCRIPT_CONFIG != null && BUILD_SCRIPT_CONFIG?.kobaltCompilerVersion != null) {
|
||||
BUILD_SCRIPT_CONFIG?.kobaltCompilerVersion
|
||||
} else {
|
||||
xmlFile.kobaltCompilerVersion
|
||||
}
|
||||
}
|
||||
|
||||
val kobaltCompilerRepo : String?
|
||||
get() {
|
||||
return if (BUILD_SCRIPT_CONFIG != null && BUILD_SCRIPT_CONFIG?.kobaltCompilerRepo != null) {
|
||||
BUILD_SCRIPT_CONFIG?.kobaltCompilerRepo
|
||||
} else {
|
||||
xmlFile.kobaltCompilerRepo
|
||||
}
|
||||
}
|
||||
|
||||
val kobaltCompilerFlags : String?
|
||||
get() {
|
||||
return if (BUILD_SCRIPT_CONFIG != null && BUILD_SCRIPT_CONFIG?.kobaltCompilerFlags != null) {
|
||||
BUILD_SCRIPT_CONFIG?.kobaltCompilerFlags
|
||||
} else {
|
||||
xmlFile.kobaltCompilerFlags
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
val SETTINGS_FILE_PATH = KFiles.joinDir(KFiles.HOME_KOBALT_DIR.absolutePath, "settings.xml")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue