mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 16:28:12 -07:00
New build syntax.
This commit is contained in:
parent
70c4a3960f
commit
fded2800b6
6 changed files with 62 additions and 57 deletions
|
@ -86,6 +86,10 @@ open public class Project(
|
|||
|
||||
val testDependencies : ArrayList<IClasspathDependency> = arrayListOf()
|
||||
val testProvidedDependencies : ArrayList<IClasspathDependency> = arrayListOf()
|
||||
|
||||
/** Used to disambiguate various name properties */
|
||||
@Directive
|
||||
val projectName: String get() = name!!
|
||||
}
|
||||
|
||||
public class Sources(val project: Project, val sources: ArrayList<String>) {
|
||||
|
|
|
@ -14,7 +14,7 @@ import javax.inject.Inject
|
|||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
abstract public class JvmCompilerPlugin @Inject constructor(
|
||||
abstract class JvmCompilerPlugin @Inject constructor(
|
||||
open val localRepo: LocalRepo,
|
||||
open val files: KFiles,
|
||||
open val depFactory: DepFactory,
|
||||
|
@ -121,15 +121,15 @@ abstract public class JvmCompilerPlugin @Inject constructor(
|
|||
}
|
||||
|
||||
|
||||
public class TestConfig(val project: Project) {
|
||||
class TestConfig(val project: Project) {
|
||||
fun args(vararg arg: String) {
|
||||
project.testArgs.addAll(arg)
|
||||
}
|
||||
}
|
||||
|
||||
@Directive
|
||||
public fun test(project: Project, init: TestConfig.() -> Unit) : TestConfig {
|
||||
val result = TestConfig(project)
|
||||
fun Project.test(init: TestConfig.() -> Unit) : TestConfig {
|
||||
val result = TestConfig(this)
|
||||
result.init()
|
||||
return result
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import javax.inject.Inject
|
|||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
public class KotlinPlugin @Inject constructor(
|
||||
class KotlinPlugin @Inject constructor(
|
||||
override val localRepo: LocalRepo,
|
||||
override val files: KFiles,
|
||||
override val depFactory: DepFactory,
|
||||
|
@ -98,7 +98,7 @@ public class KotlinPlugin @Inject constructor(
|
|||
* @param project: the list of projects that need to be built before this one.
|
||||
*/
|
||||
@Directive
|
||||
public fun kotlinProject(vararg project: Project, init: KotlinProject.() -> Unit): KotlinProject {
|
||||
fun kotlinProject(vararg project: Project, init: KotlinProject.() -> Unit): KotlinProject {
|
||||
with(KotlinProject()) {
|
||||
init()
|
||||
Kobalt.declareProjectDependencies(this, project)
|
||||
|
@ -113,7 +113,7 @@ class KotlinCompilerConfig {
|
|||
}
|
||||
|
||||
@Directive
|
||||
fun kotlinCompiler(init: KotlinCompilerConfig.() -> Unit) : KotlinCompilerConfig {
|
||||
fun Project.kotlinCompiler(init: KotlinCompilerConfig.() -> Unit) : KotlinCompilerConfig {
|
||||
with (KotlinCompilerConfig()) {
|
||||
init()
|
||||
return this
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
package com.beust.kobalt.plugin.packaging
|
||||
|
||||
import com.beust.kobalt.IFileSpec
|
||||
import com.beust.kobalt.IFileSpec.FileSpec
|
||||
import com.beust.kobalt.IFileSpec.Glob
|
||||
import com.beust.kobalt.IFileSpec
|
||||
import com.beust.kobalt.Plugins
|
||||
import com.beust.kobalt.api.BasePlugin
|
||||
import com.beust.kobalt.api.Kobalt
|
||||
import com.beust.kobalt.api.Project
|
||||
|
@ -29,14 +28,14 @@ import javax.inject.Inject
|
|||
import javax.inject.Singleton
|
||||
|
||||
@Directive
|
||||
public fun assemble(project: Project, init: Package.(p: Project) -> Unit): Package {
|
||||
val pd = Package(project)
|
||||
pd.init(project)
|
||||
fun Project.assemble(init: Package.(p: Project) -> Unit): Package {
|
||||
val pd = Package(this)
|
||||
pd.init(this)
|
||||
return pd
|
||||
}
|
||||
|
||||
@Singleton
|
||||
public class PackagingPlugin @Inject constructor(val dependencyManager : DependencyManager,
|
||||
class PackagingPlugin @Inject constructor(val dependencyManager : DependencyManager,
|
||||
val executors: KobaltExecutors, val localRepo: LocalRepo) : BasePlugin() {
|
||||
|
||||
companion object {
|
||||
|
@ -67,7 +66,7 @@ public class PackagingPlugin @Inject constructor(val dependencyManager : Depende
|
|||
}
|
||||
ex.forEach {
|
||||
if (it.matches(Paths.get(file.name))) {
|
||||
log(2, "Excluding ${file}")
|
||||
log(2, "Excluding $file")
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
@ -175,7 +174,7 @@ public class PackagingPlugin @Inject constructor(val dependencyManager : Depende
|
|||
if (File(fromPath).exists()) {
|
||||
spec.toFiles(fromPath).forEach { file ->
|
||||
if (!File(fromPath, file.path).exists()) {
|
||||
throw AssertionError("File should exist: ${file}")
|
||||
throw AssertionError("File should exist: $file")
|
||||
}
|
||||
|
||||
if (!isExcluded(file, excludes)) {
|
||||
|
@ -186,11 +185,11 @@ public class PackagingPlugin @Inject constructor(val dependencyManager : Depende
|
|||
|
||||
}
|
||||
} else {
|
||||
warn("Directory ${fromPath} doesn't exist, not including it in the jar")
|
||||
warn("Directory $fromPath doesn't exist, not including it in the jar")
|
||||
}
|
||||
}
|
||||
if (includedSpecs.size > 0) {
|
||||
log(3, "Including specs ${includedSpecs}")
|
||||
log(3, "Including specs $includedSpecs")
|
||||
result.add(IncludedFile(From(includedFile.from), To(includedFile.to), includedSpecs))
|
||||
}
|
||||
}
|
||||
|
@ -213,12 +212,12 @@ public class PackagingPlugin @Inject constructor(val dependencyManager : Depende
|
|||
val fullArchiveName = archiveName ?: arrayListOf(project.name!!, project.version!!).joinToString("-") + suffix
|
||||
val result = File(archiveDir.path, fullArchiveName)
|
||||
val outStream = outputStreamFactory(FileOutputStream(result))
|
||||
log(2, "Creating ${result}")
|
||||
log(2, "Creating $result")
|
||||
JarUtils.addFiles(project.directory, includedFiles, outStream, expandJarFiles)
|
||||
log(2, "Added ${includedFiles.size} files to ${result}")
|
||||
log(2, text = "Added ${includedFiles.size} files to $result")
|
||||
outStream.flush()
|
||||
outStream.close()
|
||||
log(1, " Created ${result}")
|
||||
log(1, " Created $result")
|
||||
return result
|
||||
}
|
||||
|
||||
|
|
|
@ -114,10 +114,9 @@ data class JCenterConfiguration(val project: Project) {
|
|||
}
|
||||
|
||||
@Directive
|
||||
public fun jcenter(project: Project, ini: JCenterConfiguration.() -> Unit)
|
||||
: JCenterConfiguration {
|
||||
val pd = JCenterConfiguration(project)
|
||||
public fun Project.jcenter(ini: JCenterConfiguration.() -> Unit) : JCenterConfiguration {
|
||||
val pd = JCenterConfiguration(this)
|
||||
pd.ini()
|
||||
(Kobalt.findPlugin("publish") as PublishPlugin).addConfiguration(project.name!!, pd)
|
||||
(Kobalt.findPlugin("publish") as PublishPlugin).addConfiguration(name!!, pd)
|
||||
return pd
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue