mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -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 {
|
class BuildScriptConfig {
|
||||||
/** The list of repos used to locate plug-ins. */
|
/** The list of repos used to locate plug-ins. */
|
||||||
|
@Directive
|
||||||
fun repos(vararg r: String) = newRepos(*r)
|
fun repos(vararg r: String) = newRepos(*r)
|
||||||
|
|
||||||
/** The list of plug-ins to use for this build file. */
|
/** The list of plug-ins to use for this build file. */
|
||||||
|
@Directive
|
||||||
fun plugins(vararg pl: String) = newPlugins(*pl)
|
fun plugins(vararg pl: String) = newPlugins(*pl)
|
||||||
|
|
||||||
/** The build file classpath. */
|
/** The build file classpath. */
|
||||||
|
@Directive
|
||||||
fun buildFileClasspath(vararg bfc: String) = newBuildFileClasspath(*bfc)
|
fun buildFileClasspath(vararg bfc: String) = newBuildFileClasspath(*bfc)
|
||||||
|
|
||||||
// The following settings modify the compiler used to compile the build file.
|
// The following settings modify the compiler used to compile the build file.
|
||||||
|
@ -31,11 +34,6 @@ class BuildScriptConfig {
|
||||||
var kobaltCompilerFlags: String? = null
|
var kobaltCompilerFlags: String? = null
|
||||||
}
|
}
|
||||||
|
|
||||||
@Directive
|
|
||||||
fun buildScript(init: BuildScriptConfig.() -> Unit) {
|
|
||||||
BUILD_SCRIPT_CONFIG = BuildScriptConfig().apply { init() }
|
|
||||||
}
|
|
||||||
|
|
||||||
@Directive
|
@Directive
|
||||||
fun homeDir(vararg dirs: String) : String = SystemProperties.homeDir +
|
fun homeDir(vararg dirs: String) : String = SystemProperties.homeDir +
|
||||||
File.separator + dirs.toMutableList().joinToString(File.separator)
|
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.Project
|
||||||
import com.beust.kobalt.api.annotation.Directive
|
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
|
@Directive
|
||||||
fun Project.test(init: TestConfig.() -> Unit) = let { project ->
|
fun Project.test(init: TestConfig.() -> Unit): TestConfig = let { project ->
|
||||||
with(testConfigs) {
|
with(testConfigs) {
|
||||||
val tf = TestConfig(project).apply { init() }
|
val tf = TestConfig(project).apply { init() }
|
||||||
if (! map { it.name }.contains(tf.name)) {
|
if (! map { it.name }.contains(tf.name)) {
|
||||||
add(tf)
|
add(tf)
|
||||||
|
tf
|
||||||
} else {
|
} else {
|
||||||
throw KobaltException("Test configuration \"${tf.name}\" already exists, give it a different "
|
throw KobaltException("Test configuration \"${tf.name}\" already exists, give it a different "
|
||||||
+ "name with test { name = ... }")
|
+ "name with test { name = ... }")
|
||||||
|
|
|
@ -142,7 +142,7 @@ abstract class GenericTestRunner: ITestRunnerContributor {
|
||||||
*/
|
*/
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
fun calculateAllJvmArgs(project: Project, context: KobaltContext,
|
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
|
// Default JVM args
|
||||||
val jvmFlags = arrayListOf<String>().apply {
|
val jvmFlags = arrayListOf<String>().apply {
|
||||||
addAll(testConfig.jvmArgs)
|
addAll(testConfig.jvmArgs)
|
||||||
|
|
|
@ -29,8 +29,8 @@ class ApplicationConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Directive
|
@Directive
|
||||||
fun Project.application(init: ApplicationConfig.() -> Unit) {
|
fun Project.application(init: ApplicationConfig.() -> Unit): ApplicationConfig {
|
||||||
ApplicationConfig().let { config ->
|
return ApplicationConfig().also { config ->
|
||||||
config.init()
|
config.init()
|
||||||
(Plugins.findPlugin(ApplicationPlugin.PLUGIN_NAME) as ApplicationPlugin).addConfiguration(this, config)
|
(Plugins.findPlugin(ApplicationPlugin.PLUGIN_NAME) as ApplicationPlugin).addConfiguration(this, config)
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,8 +44,8 @@ class GroovyConfig(val project: Project) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Directive
|
@Directive
|
||||||
fun Project.groovyCompiler(init: GroovyConfig.() -> Unit) = let {
|
fun Project.groovyCompiler(init: GroovyConfig.() -> Unit) =
|
||||||
val config = GroovyConfig(it)
|
GroovyConfig(this).also { config ->
|
||||||
config.init()
|
config.init()
|
||||||
(Kobalt.findPlugin(GroovyPlugin.PLUGIN_NAME) as GroovyPlugin).addConfiguration(this, config)
|
(Kobalt.findPlugin(GroovyPlugin.PLUGIN_NAME) as GroovyPlugin).addConfiguration(this, config)
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,8 +84,8 @@ class JavaConfig(val project: Project) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Directive
|
@Directive
|
||||||
fun Project.javaCompiler(init: JavaConfig.() -> Unit) = let {
|
fun Project.javaCompiler(init: JavaConfig.() -> Unit) =
|
||||||
val config = JavaConfig(it)
|
JavaConfig(this).also { config ->
|
||||||
config.init()
|
config.init()
|
||||||
(Kobalt.findPlugin(JavaPlugin.PLUGIN_NAME) as JavaPlugin).addConfiguration(this, config)
|
(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)
|
fun args(vararg options: String) = args.addAll(options)
|
||||||
|
|
||||||
/** The version of the Kotlin compiler */
|
/** The version of the Kotlin compiler */
|
||||||
|
@Directive
|
||||||
var version: String? = null
|
var version: String? = null
|
||||||
}
|
}
|
||||||
|
|
||||||
@Directive
|
@Directive
|
||||||
fun Project.kotlinCompiler(init: KotlinConfig.() -> Unit) = let {
|
fun Project.kotlinCompiler(init: KotlinConfig.() -> Unit) =
|
||||||
val config = KotlinConfig(it)
|
KotlinConfig(this).also { config ->
|
||||||
config.init()
|
config.init()
|
||||||
(Kobalt.findPlugin(KotlinPlugin.PLUGIN_NAME) as KotlinPlugin).addConfiguration(this, config)
|
(Kobalt.findPlugin(KotlinPlugin.PLUGIN_NAME) as KotlinPlugin).addConfiguration(this, config)
|
||||||
}
|
}
|
||||||
|
|
||||||
//class SourceLinkMapItem {
|
//class SourceLinkMapItem {
|
||||||
// var dir: String = ""
|
// var dir: String = ""
|
||||||
|
|
|
@ -171,7 +171,7 @@ fun Project.install(init: InstallConfig.() -> Unit) {
|
||||||
class InstallConfig(var libDir : String = "libs")
|
class InstallConfig(var libDir : String = "libs")
|
||||||
|
|
||||||
@Directive
|
@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) }
|
PackageConfig(this).apply { init(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -206,12 +206,11 @@ data class GithubConfig(val project: Project) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Directive
|
@Directive
|
||||||
fun Project.github(init: GithubConfig.() -> Unit) {
|
fun Project.github(init: GithubConfig.() -> Unit): GithubConfig =
|
||||||
with(GithubConfig(this)) {
|
GithubConfig(this).also { config ->
|
||||||
init()
|
config.init()
|
||||||
(Kobalt.findPlugin(PublishPlugin.PLUGIN_NAME) as PublishPlugin).addGithubConfiguration(name, this)
|
(Kobalt.findPlugin(PublishPlugin.PLUGIN_NAME) as PublishPlugin).addGithubConfiguration(name, config)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
data class BintrayConfig(val project: Project) {
|
data class BintrayConfig(val project: Project) {
|
||||||
/**
|
/**
|
||||||
|
@ -245,9 +244,8 @@ data class BintrayConfig(val project: Project) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Directive
|
@Directive
|
||||||
fun Project.bintray(init: BintrayConfig.() -> Unit) {
|
fun Project.bintray(init: BintrayConfig.() -> Unit) =
|
||||||
with(BintrayConfig(this)) {
|
BintrayConfig(this).also { config ->
|
||||||
init()
|
config.init()
|
||||||
(Kobalt.findPlugin(PublishPlugin.PLUGIN_NAME) as PublishPlugin).addBintrayConfiguration(name, this)
|
(Kobalt.findPlugin(PublishPlugin.PLUGIN_NAME) as PublishPlugin).addBintrayConfiguration(name, config)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue