mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 16:28:12 -07:00
Introducing project{}.
This commit is contained in:
parent
36aeb392ed
commit
a118d3680b
4 changed files with 28 additions and 25 deletions
|
@ -1,26 +1,9 @@
|
||||||
package com.beust.kobalt.internal
|
package com.beust.kobalt.internal
|
||||||
|
|
||||||
import com.beust.kobalt.api.*
|
import com.beust.kobalt.api.ConfigPlugin
|
||||||
|
import com.beust.kobalt.api.ICompilerFlagContributor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for JVM language plug-ins.
|
* Base class for JVM language plug-ins.
|
||||||
*/
|
*/
|
||||||
abstract class BaseJvmPlugin<T>: ConfigPlugin<T>(), IProjectContributor, ICompilerFlagContributor {
|
abstract class BaseJvmPlugin<T>: ConfigPlugin<T>(), ICompilerFlagContributor
|
||||||
|
|
||||||
override fun apply(project: Project, context: KobaltContext) {
|
|
||||||
super.apply(project, context)
|
|
||||||
project.projectProperties.put(JvmCompilerPlugin.DEPENDENT_PROJECTS, projects())
|
|
||||||
}
|
|
||||||
|
|
||||||
private val allProjects = arrayListOf<ProjectDescription>()
|
|
||||||
|
|
||||||
fun addDependentProjects(project: Project, dependents: List<Project>) {
|
|
||||||
project.projectExtra.dependsOn.addAll(dependents)
|
|
||||||
with(ProjectDescription(project, dependents)) {
|
|
||||||
allProjects.add(this)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// IProjectContributor
|
|
||||||
override fun projects() = allProjects
|
|
||||||
}
|
|
|
@ -4,6 +4,7 @@ import com.beust.kobalt.IncrementalTaskInfo
|
||||||
import com.beust.kobalt.KobaltException
|
import com.beust.kobalt.KobaltException
|
||||||
import com.beust.kobalt.TaskResult
|
import com.beust.kobalt.TaskResult
|
||||||
import com.beust.kobalt.api.*
|
import com.beust.kobalt.api.*
|
||||||
|
import com.beust.kobalt.api.annotation.Directive
|
||||||
import com.beust.kobalt.api.annotation.ExportedProjectProperty
|
import com.beust.kobalt.api.annotation.ExportedProjectProperty
|
||||||
import com.beust.kobalt.api.annotation.IncrementalTask
|
import com.beust.kobalt.api.annotation.IncrementalTask
|
||||||
import com.beust.kobalt.api.annotation.Task
|
import com.beust.kobalt.api.annotation.Task
|
||||||
|
@ -36,6 +37,8 @@ open class JvmCompilerPlugin @Inject constructor(
|
||||||
: BasePlugin(), ISourceDirectoryContributor, IProjectContributor, ITaskContributor by taskContributor {
|
: BasePlugin(), ISourceDirectoryContributor, IProjectContributor, ITaskContributor by taskContributor {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
val PLUGIN_NAME = "JvmCompiler"
|
||||||
|
|
||||||
@ExportedProjectProperty(doc = "Projects this project depends on", type = "List<ProjectDescription>")
|
@ExportedProjectProperty(doc = "Projects this project depends on", type = "List<ProjectDescription>")
|
||||||
const val DEPENDENT_PROJECTS = "dependentProjects"
|
const val DEPENDENT_PROJECTS = "dependentProjects"
|
||||||
|
|
||||||
|
@ -52,7 +55,7 @@ open class JvmCompilerPlugin @Inject constructor(
|
||||||
const val DOCS_DIRECTORY = "docs/javadoc"
|
const val DOCS_DIRECTORY = "docs/javadoc"
|
||||||
}
|
}
|
||||||
|
|
||||||
override val name: String = "JvmCompiler"
|
override val name: String = PLUGIN_NAME
|
||||||
|
|
||||||
override fun accept(project: Project) = true
|
override fun accept(project: Project) = true
|
||||||
|
|
||||||
|
@ -184,8 +187,13 @@ open class JvmCompilerPlugin @Inject constructor(
|
||||||
|
|
||||||
val allProjects = arrayListOf<ProjectDescription>()
|
val allProjects = arrayListOf<ProjectDescription>()
|
||||||
|
|
||||||
override fun projects() : List<ProjectDescription> {
|
override fun projects() = allProjects
|
||||||
return allProjects
|
|
||||||
|
fun addDependentProjects(project: Project, dependents: List<Project>) {
|
||||||
|
project.projectExtra.dependsOn.addAll(dependents)
|
||||||
|
with(ProjectDescription(project, dependents)) {
|
||||||
|
allProjects.add(this)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Task(name = "doc", description = "Generate the documentation for the project")
|
@Task(name = "doc", description = "Generate the documentation for the project")
|
||||||
|
@ -301,3 +309,11 @@ open class JvmCompilerPlugin @Inject constructor(
|
||||||
open val compiler: ICompilerContributor? = null
|
open val compiler: ICompilerContributor? = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Directive
|
||||||
|
public fun project(vararg projects: Project, init: Project.() -> Unit): Project {
|
||||||
|
return Project("").apply {
|
||||||
|
init()
|
||||||
|
(Kobalt.findPlugin(JvmCompilerPlugin.PLUGIN_NAME) as JvmCompilerPlugin)
|
||||||
|
.addDependentProjects(this, projects.toList())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.beust.kobalt.Variant
|
||||||
import com.beust.kobalt.api.*
|
import com.beust.kobalt.api.*
|
||||||
import com.beust.kobalt.api.annotation.Directive
|
import com.beust.kobalt.api.annotation.Directive
|
||||||
import com.beust.kobalt.internal.BaseJvmPlugin
|
import com.beust.kobalt.internal.BaseJvmPlugin
|
||||||
|
import com.beust.kobalt.internal.JvmCompilerPlugin
|
||||||
import com.beust.kobalt.misc.warn
|
import com.beust.kobalt.misc.warn
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -76,7 +77,8 @@ class JavaPlugin @Inject constructor(val javaCompiler: JavaCompiler)
|
||||||
public fun javaProject(vararg projects: Project, init: JavaProject.() -> Unit): JavaProject {
|
public fun javaProject(vararg projects: Project, init: JavaProject.() -> Unit): JavaProject {
|
||||||
return JavaProject().apply {
|
return JavaProject().apply {
|
||||||
init()
|
init()
|
||||||
(Kobalt.findPlugin(JavaPlugin.PLUGIN_NAME) as JavaPlugin).addDependentProjects(this, projects.toList())
|
(Kobalt.findPlugin(JvmCompilerPlugin.PLUGIN_NAME) as JvmCompilerPlugin)
|
||||||
|
.addDependentProjects(this, projects.toList())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.beust.kobalt.Variant
|
||||||
import com.beust.kobalt.api.*
|
import com.beust.kobalt.api.*
|
||||||
import com.beust.kobalt.api.annotation.Directive
|
import com.beust.kobalt.api.annotation.Directive
|
||||||
import com.beust.kobalt.internal.BaseJvmPlugin
|
import com.beust.kobalt.internal.BaseJvmPlugin
|
||||||
|
import com.beust.kobalt.internal.JvmCompilerPlugin
|
||||||
import com.beust.kobalt.maven.dependency.FileDependency
|
import com.beust.kobalt.maven.dependency.FileDependency
|
||||||
import com.beust.kobalt.maven.dependency.MavenDependency
|
import com.beust.kobalt.maven.dependency.MavenDependency
|
||||||
import com.beust.kobalt.misc.KobaltExecutors
|
import com.beust.kobalt.misc.KobaltExecutors
|
||||||
|
@ -142,7 +143,8 @@ class KotlinPlugin @Inject constructor(val executors: KobaltExecutors)
|
||||||
fun kotlinProject(vararg projects: Project, init: KotlinProject.() -> Unit): KotlinProject {
|
fun kotlinProject(vararg projects: Project, init: KotlinProject.() -> Unit): KotlinProject {
|
||||||
return KotlinProject().apply {
|
return KotlinProject().apply {
|
||||||
init()
|
init()
|
||||||
(Kobalt.findPlugin(KotlinPlugin.PLUGIN_NAME) as KotlinPlugin).addDependentProjects(this, projects.toList())
|
(Kobalt.findPlugin(JvmCompilerPlugin.PLUGIN_NAME) as JvmCompilerPlugin)
|
||||||
|
.addDependentProjects(this, projects.toList())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue