mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 00:17:11 -07:00
Merge pull request #327 from pabl0rg/master
standardize BuildScript directives
This commit is contained in:
commit
6b08856b7b
11 changed files with 79 additions and 66 deletions
|
@ -16,12 +16,15 @@ var BUILD_SCRIPT_CONFIG : BuildScriptConfig? = null
|
|||
|
||||
class BuildScriptConfig {
|
||||
/** The list of repos used to locate plug-ins. */
|
||||
@Directive
|
||||
fun repos(vararg r: String) = newRepos(*r)
|
||||
|
||||
/** The list of plug-ins to use for this build file. */
|
||||
@Directive
|
||||
fun plugins(vararg pl: String) = newPlugins(*pl)
|
||||
|
||||
/** The build file classpath. */
|
||||
@Directive
|
||||
fun buildFileClasspath(vararg bfc: String) = newBuildFileClasspath(*bfc)
|
||||
|
||||
// The following settings modify the compiler used to compile the build file.
|
||||
|
@ -31,11 +34,6 @@ class BuildScriptConfig {
|
|||
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)
|
||||
|
|
|
@ -14,3 +14,9 @@ fun project(vararg projects: Project, init: Project.() -> Unit): Project {
|
|||
}
|
||||
}
|
||||
|
||||
@Directive
|
||||
fun buildScript(init: BuildScriptConfig.() -> Unit): BuildScriptConfig {
|
||||
val buildScriptConfig = BuildScriptConfig().apply { init() }
|
||||
BUILD_SCRIPT_CONFIG = buildScriptConfig
|
||||
return buildScriptConfig
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package com.beust.kobalt
|
||||
|
||||
import com.beust.kobalt.api.Project
|
||||
import com.beust.kobalt.api.annotation.Directive
|
||||
|
||||
class TestConfig(val project: Project, val isDefault : Boolean = false) {
|
||||
val testArgs = arrayListOf<String>()
|
||||
val jvmArgs = arrayListOf<String>()
|
||||
val testIncludes = arrayListOf("**/*Test.class")
|
||||
val testExcludes = arrayListOf<String>()
|
||||
|
||||
@Directive
|
||||
var name: String = ""
|
||||
|
||||
@Directive
|
||||
fun args(vararg arg: String) {
|
||||
testArgs.addAll(arg)
|
||||
}
|
||||
|
||||
@Directive
|
||||
fun jvmArgs(vararg arg: String) {
|
||||
jvmArgs.addAll(arg)
|
||||
}
|
||||
|
||||
@Directive
|
||||
fun include(vararg arg: String) {
|
||||
testIncludes.apply {
|
||||
clear()
|
||||
addAll(arg)
|
||||
}
|
||||
}
|
||||
|
||||
@Directive
|
||||
fun exclude(vararg arg: String) {
|
||||
testExcludes.apply {
|
||||
clear()
|
||||
addAll(arg)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,43 +3,13 @@ package com.beust.kobalt
|
|||
import com.beust.kobalt.api.Project
|
||||
import com.beust.kobalt.api.annotation.Directive
|
||||
|
||||
class TestConfig(val project: Project, val isDefault : Boolean = false) {
|
||||
val testArgs = arrayListOf<String>()
|
||||
val jvmArgs = arrayListOf<String>()
|
||||
val testIncludes = arrayListOf("**/*Test.class")
|
||||
val testExcludes = arrayListOf<String>()
|
||||
|
||||
var name: String = ""
|
||||
|
||||
fun args(vararg arg: String) {
|
||||
testArgs.addAll(arg)
|
||||
}
|
||||
|
||||
fun jvmArgs(vararg arg: String) {
|
||||
jvmArgs.addAll(arg)
|
||||
}
|
||||
|
||||
fun include(vararg arg: String) {
|
||||
testIncludes.apply {
|
||||
clear()
|
||||
addAll(arg)
|
||||
}
|
||||
}
|
||||
|
||||
fun exclude(vararg arg: String) {
|
||||
testExcludes.apply {
|
||||
clear()
|
||||
addAll(arg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Directive
|
||||
fun Project.test(init: TestConfig.() -> Unit) = let { project ->
|
||||
fun Project.test(init: TestConfig.() -> Unit): TestConfig = let { project ->
|
||||
with(testConfigs) {
|
||||
val tf = TestConfig(project).apply { init() }
|
||||
if (! map { it.name }.contains(tf.name)) {
|
||||
add(tf)
|
||||
tf
|
||||
} else {
|
||||
throw KobaltException("Test configuration \"${tf.name}\" already exists, give it a different "
|
||||
+ "name with test { name = ... }")
|
||||
|
|
|
@ -142,7 +142,7 @@ abstract class GenericTestRunner: ITestRunnerContributor {
|
|||
*/
|
||||
@VisibleForTesting
|
||||
fun calculateAllJvmArgs(project: Project, context: KobaltContext,
|
||||
testConfig: TestConfig, classpath: List<IClasspathDependency>, pluginInfo: IPluginInfo) : List<String> {
|
||||
testConfig: TestConfig, classpath: List<IClasspathDependency>, pluginInfo: IPluginInfo) : List<String> {
|
||||
// Default JVM args
|
||||
val jvmFlags = arrayListOf<String>().apply {
|
||||
addAll(testConfig.jvmArgs)
|
||||
|
|
|
@ -29,8 +29,8 @@ class ApplicationConfig {
|
|||
}
|
||||
|
||||
@Directive
|
||||
fun Project.application(init: ApplicationConfig.() -> Unit) {
|
||||
ApplicationConfig().let { config ->
|
||||
fun Project.application(init: ApplicationConfig.() -> Unit): ApplicationConfig {
|
||||
return ApplicationConfig().also { config ->
|
||||
config.init()
|
||||
(Plugins.findPlugin(ApplicationPlugin.PLUGIN_NAME) as ApplicationPlugin).addConfiguration(this, config)
|
||||
}
|
||||
|
|
|
@ -44,8 +44,8 @@ class GroovyConfig(val project: Project) {
|
|||
}
|
||||
|
||||
@Directive
|
||||
fun Project.groovyCompiler(init: GroovyConfig.() -> Unit) = let {
|
||||
val config = GroovyConfig(it)
|
||||
config.init()
|
||||
(Kobalt.findPlugin(GroovyPlugin.PLUGIN_NAME) as GroovyPlugin).addConfiguration(this, config)
|
||||
}
|
||||
fun Project.groovyCompiler(init: GroovyConfig.() -> Unit) =
|
||||
GroovyConfig(this).also { config ->
|
||||
config.init()
|
||||
(Kobalt.findPlugin(GroovyPlugin.PLUGIN_NAME) as GroovyPlugin).addConfiguration(this, config)
|
||||
}
|
||||
|
|
|
@ -84,8 +84,8 @@ class JavaConfig(val project: Project) {
|
|||
}
|
||||
|
||||
@Directive
|
||||
fun Project.javaCompiler(init: JavaConfig.() -> Unit) = let {
|
||||
val config = JavaConfig(it)
|
||||
config.init()
|
||||
(Kobalt.findPlugin(JavaPlugin.PLUGIN_NAME) as JavaPlugin).addConfiguration(this, config)
|
||||
}
|
||||
fun Project.javaCompiler(init: JavaConfig.() -> Unit) =
|
||||
JavaConfig(this).also { config ->
|
||||
config.init()
|
||||
(Kobalt.findPlugin(JavaPlugin.PLUGIN_NAME) as JavaPlugin).addConfiguration(this, config)
|
||||
}
|
|
@ -149,15 +149,16 @@ class KotlinConfig(val project: Project) {
|
|||
fun args(vararg options: String) = args.addAll(options)
|
||||
|
||||
/** The version of the Kotlin compiler */
|
||||
@Directive
|
||||
var version: String? = null
|
||||
}
|
||||
|
||||
@Directive
|
||||
fun Project.kotlinCompiler(init: KotlinConfig.() -> Unit) = let {
|
||||
val config = KotlinConfig(it)
|
||||
config.init()
|
||||
(Kobalt.findPlugin(KotlinPlugin.PLUGIN_NAME) as KotlinPlugin).addConfiguration(this, config)
|
||||
}
|
||||
fun Project.kotlinCompiler(init: KotlinConfig.() -> Unit) =
|
||||
KotlinConfig(this).also { config ->
|
||||
config.init()
|
||||
(Kobalt.findPlugin(KotlinPlugin.PLUGIN_NAME) as KotlinPlugin).addConfiguration(this, config)
|
||||
}
|
||||
|
||||
//class SourceLinkMapItem {
|
||||
// var dir: String = ""
|
||||
|
|
|
@ -171,7 +171,7 @@ fun Project.install(init: InstallConfig.() -> Unit) {
|
|||
class InstallConfig(var libDir : String = "libs")
|
||||
|
||||
@Directive
|
||||
fun Project.assemble(init: PackageConfig.(p: Project) -> Unit) = let {
|
||||
fun Project.assemble(init: PackageConfig.(p: Project) -> Unit): PackageConfig = let {
|
||||
PackageConfig(this).apply { init(it) }
|
||||
}
|
||||
|
||||
|
|
|
@ -206,12 +206,11 @@ data class GithubConfig(val project: Project) {
|
|||
}
|
||||
|
||||
@Directive
|
||||
fun Project.github(init: GithubConfig.() -> Unit) {
|
||||
with(GithubConfig(this)) {
|
||||
init()
|
||||
(Kobalt.findPlugin(PublishPlugin.PLUGIN_NAME) as PublishPlugin).addGithubConfiguration(name, this)
|
||||
fun Project.github(init: GithubConfig.() -> Unit): GithubConfig =
|
||||
GithubConfig(this).also { config ->
|
||||
config.init()
|
||||
(Kobalt.findPlugin(PublishPlugin.PLUGIN_NAME) as PublishPlugin).addGithubConfiguration(name, config)
|
||||
}
|
||||
}
|
||||
|
||||
data class BintrayConfig(val project: Project) {
|
||||
/**
|
||||
|
@ -245,9 +244,8 @@ data class BintrayConfig(val project: Project) {
|
|||
}
|
||||
|
||||
@Directive
|
||||
fun Project.bintray(init: BintrayConfig.() -> Unit) {
|
||||
with(BintrayConfig(this)) {
|
||||
init()
|
||||
(Kobalt.findPlugin(PublishPlugin.PLUGIN_NAME) as PublishPlugin).addBintrayConfiguration(name, this)
|
||||
fun Project.bintray(init: BintrayConfig.() -> Unit) =
|
||||
BintrayConfig(this).also { config ->
|
||||
config.init()
|
||||
(Kobalt.findPlugin(PublishPlugin.PLUGIN_NAME) as PublishPlugin).addBintrayConfiguration(name, config)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue