mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-27 08:38:13 -07:00
New simplified scheme for kobalt-plugin.xml.
This commit is contained in:
parent
c23b2f9c1b
commit
ddef4069bc
4 changed files with 61 additions and 129 deletions
|
@ -0,0 +1,14 @@
|
||||||
|
package com.beust.kobalt.api
|
||||||
|
|
||||||
|
import com.beust.kobalt.TaskResult
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plugins that can run a project (task "run" or "test") should implement this interface.
|
||||||
|
*/
|
||||||
|
interface ITestRunnerContributor : IContributor, IAffinity {
|
||||||
|
/**
|
||||||
|
* Run the project.
|
||||||
|
*/
|
||||||
|
fun run(project: Project, context: KobaltContext, classpath: List<IClasspathDependency>) : TaskResult
|
||||||
|
}
|
||||||
|
|
|
@ -3,16 +3,16 @@ package com.beust.kobalt.internal
|
||||||
import com.beust.kobalt.JavaInfo
|
import com.beust.kobalt.JavaInfo
|
||||||
import com.beust.kobalt.SystemProperties
|
import com.beust.kobalt.SystemProperties
|
||||||
import com.beust.kobalt.TaskResult
|
import com.beust.kobalt.TaskResult
|
||||||
import com.beust.kobalt.api.IRunnerContributor
|
import com.beust.kobalt.api.IClasspathDependency
|
||||||
|
import com.beust.kobalt.api.ITestRunnerContributor
|
||||||
import com.beust.kobalt.api.KobaltContext
|
import com.beust.kobalt.api.KobaltContext
|
||||||
import com.beust.kobalt.api.Project
|
import com.beust.kobalt.api.Project
|
||||||
import com.beust.kobalt.api.IClasspathDependency
|
|
||||||
import com.beust.kobalt.misc.KFiles
|
import com.beust.kobalt.misc.KFiles
|
||||||
import com.beust.kobalt.misc.log
|
import com.beust.kobalt.misc.log
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.net.URLClassLoader
|
import java.net.URLClassLoader
|
||||||
|
|
||||||
abstract class GenericTestRunner : IRunnerContributor {
|
abstract class GenericTestRunner : ITestRunnerContributor {
|
||||||
abstract val mainClass: String
|
abstract val mainClass: String
|
||||||
abstract fun args(project: Project, classpath: List<IClasspathDependency>) : List<String>
|
abstract fun args(project: Project, classpath: List<IClasspathDependency>) : List<String>
|
||||||
|
|
||||||
|
|
|
@ -32,50 +32,11 @@ class KobaltPluginXml {
|
||||||
@XmlElement @JvmField
|
@XmlElement @JvmField
|
||||||
var name: String? = null
|
var name: String? = null
|
||||||
|
|
||||||
@XmlElement(name = "plugins") @JvmField
|
@XmlElement(name = "plugin-actors") @JvmField
|
||||||
var plugins : ClassNameXml? = null
|
var pluginActors : ClassNameXml? = null
|
||||||
|
|
||||||
@XmlElement(name = "factory-class-name") @JvmField
|
@XmlElement(name = "factory-class-name") @JvmField
|
||||||
var factoryClassName: String? = null
|
var factoryClassName: String? = null
|
||||||
|
|
||||||
@XmlElement(name = "classpath-contributors") @JvmField
|
|
||||||
var classpathContributors: ClassNameXml? = null
|
|
||||||
|
|
||||||
@XmlElement(name = "project-contributors") @JvmField
|
|
||||||
var projectContributors: ClassNameXml? = null
|
|
||||||
|
|
||||||
@XmlElement(name = "init-contributors") @JvmField
|
|
||||||
var initContributors: ClassNameXml? = null
|
|
||||||
|
|
||||||
@XmlElement(name = "repo-contributors") @JvmField
|
|
||||||
var repoContributors: ClassNameXml? = null
|
|
||||||
|
|
||||||
@XmlElement(name = "compiler-flag-contributors") @JvmField
|
|
||||||
var compilerFlagContributors: ClassNameXml? = null
|
|
||||||
|
|
||||||
@XmlElement(name = "compiler-interceptors") @JvmField
|
|
||||||
var compilerInterceptors: ClassNameXml? = null
|
|
||||||
|
|
||||||
@XmlElement(name = "source-directories-interceptors") @JvmField
|
|
||||||
var sourceDirectoriesInterceptors: ClassNameXml? = null
|
|
||||||
|
|
||||||
@XmlElement(name = "build-directory-interceptors") @JvmField
|
|
||||||
var buildDirectoryInterceptors: ClassNameXml? = null
|
|
||||||
|
|
||||||
@XmlElement(name = "runner-contributors") @JvmField
|
|
||||||
var runnerContributors: ClassNameXml? = null
|
|
||||||
|
|
||||||
@XmlElement(name = "test-runner-contributors") @JvmField
|
|
||||||
var testRunnerContributors: ClassNameXml? = null
|
|
||||||
|
|
||||||
@XmlElement(name = "classpath-interceptors") @JvmField
|
|
||||||
var classpathInterceptors: ClassNameXml? = null
|
|
||||||
|
|
||||||
@XmlElement(name = "compiler-contributors") @JvmField
|
|
||||||
var compilerContributors: ClassNameXml? = null
|
|
||||||
|
|
||||||
@XmlElement(name = "doc-contributors") @JvmField
|
|
||||||
var docContributors: ClassNameXml? = null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class ContributorXml {
|
class ContributorXml {
|
||||||
|
@ -104,7 +65,7 @@ class PluginInfo(val xml: KobaltPluginXml, val classLoader: ClassLoader?) {
|
||||||
val sourceDirectoriesInterceptors = arrayListOf<ISourceDirectoriesIncerceptor>()
|
val sourceDirectoriesInterceptors = arrayListOf<ISourceDirectoriesIncerceptor>()
|
||||||
val buildDirectoryInterceptors = arrayListOf<IBuildDirectoryIncerceptor>()
|
val buildDirectoryInterceptors = arrayListOf<IBuildDirectoryIncerceptor>()
|
||||||
val runnerContributors = arrayListOf<IRunnerContributor>()
|
val runnerContributors = arrayListOf<IRunnerContributor>()
|
||||||
val testRunnerContributors = arrayListOf<IRunnerContributor>()
|
val testRunnerContributors = arrayListOf<ITestRunnerContributor>()
|
||||||
val classpathInterceptors = arrayListOf<IClasspathInterceptor>()
|
val classpathInterceptors = arrayListOf<IClasspathInterceptor>()
|
||||||
val compilerContributors = arrayListOf<ICompilerContributor>()
|
val compilerContributors = arrayListOf<ICompilerContributor>()
|
||||||
val docContributors = arrayListOf<IDocContributor>()
|
val docContributors = arrayListOf<IDocContributor>()
|
||||||
|
@ -154,50 +115,32 @@ class PluginInfo(val xml: KobaltPluginXml, val classLoader: ClassLoader?) {
|
||||||
if (classLoader != null) classLoader.loadClass(className)
|
if (classLoader != null) classLoader.loadClass(className)
|
||||||
else Class.forName(className)
|
else Class.forName(className)
|
||||||
|
|
||||||
xml.plugins?.className?.forEach {
|
//
|
||||||
plugins.add(factory.instanceOf(forName(it)) as IPlugin)
|
// Populate pluginInfo with what was found in Kobalt's own kobalt-plugin.xml
|
||||||
|
//
|
||||||
|
xml.pluginActors?.className?.forEach {
|
||||||
|
with(factory.instanceOf(forName(it))) {
|
||||||
|
if (this is IPlugin) plugins.add(this)
|
||||||
|
if (this is IClasspathContributor) classpathContributors.add(this)
|
||||||
|
if (this is IProjectContributor) projectContributors.add(this)
|
||||||
|
if (this is IInitContributor) initContributors.add(this)
|
||||||
|
if (this is IRepoContributor) repoContributors.add(this)
|
||||||
|
if (this is ICompilerContributor) compilerContributors.add(this)
|
||||||
|
if (this is ICompilerInterceptor) compilerInterceptors.add(this)
|
||||||
|
if (this is ISourceDirectoriesIncerceptor) sourceDirectoriesInterceptors.add(this)
|
||||||
|
if (this is IBuildDirectoryIncerceptor) buildDirectoryInterceptors.add(this)
|
||||||
|
if (this is IRunnerContributor) runnerContributors.add(this)
|
||||||
|
if (this is ITestRunnerContributor) testRunnerContributors.add(this)
|
||||||
|
if (this is IClasspathInterceptor) classpathInterceptors.add(this)
|
||||||
|
if (this is ICompilerContributor) compilerContributors.add(this)
|
||||||
|
if (this is IDocContributor) docContributors.add(this)
|
||||||
}
|
}
|
||||||
xml.classpathContributors?.className?.forEach {
|
|
||||||
classpathContributors.add(factory.instanceOf(forName(it)) as IClasspathContributor)
|
|
||||||
}
|
|
||||||
xml.projectContributors?.className?.forEach {
|
|
||||||
projectContributors.add(factory.instanceOf(forName(it)) as IProjectContributor)
|
|
||||||
}
|
|
||||||
xml.initContributors?.className?.forEach {
|
|
||||||
initContributors.add(factory.instanceOf(forName(it)) as IInitContributor)
|
|
||||||
}
|
|
||||||
xml.repoContributors?.className?.forEach {
|
|
||||||
repoContributors.add(factory.instanceOf(forName(it)) as IRepoContributor)
|
|
||||||
}
|
|
||||||
xml.compilerFlagContributors?.className?.forEach {
|
|
||||||
compilerFlagContributors.add(factory.instanceOf(forName(it)) as ICompilerFlagContributor)
|
|
||||||
}
|
|
||||||
xml.compilerInterceptors?.className?.forEach {
|
|
||||||
compilerInterceptors.add(factory.instanceOf(forName(it)) as ICompilerInterceptor)
|
|
||||||
}
|
|
||||||
xml.sourceDirectoriesInterceptors?.className?.forEach {
|
|
||||||
sourceDirectoriesInterceptors.add(factory.instanceOf(forName(it)) as ISourceDirectoriesIncerceptor)
|
|
||||||
}
|
|
||||||
xml.buildDirectoryInterceptors?.className?.forEach {
|
|
||||||
buildDirectoryInterceptors.add(factory.instanceOf(forName(it)) as IBuildDirectoryIncerceptor)
|
|
||||||
}
|
|
||||||
xml.runnerContributors?.className?.forEach {
|
|
||||||
runnerContributors.add(factory.instanceOf(forName(it)) as IRunnerContributor)
|
|
||||||
}
|
|
||||||
xml.testRunnerContributors?.className?.forEach {
|
|
||||||
testRunnerContributors.add(factory.instanceOf(forName(it)) as IRunnerContributor)
|
|
||||||
}
|
|
||||||
xml.classpathInterceptors?.className?.forEach {
|
|
||||||
classpathInterceptors.add(factory.instanceOf(forName(it)) as IClasspathInterceptor)
|
|
||||||
}
|
|
||||||
xml.compilerContributors?.className?.forEach {
|
|
||||||
compilerContributors.add(factory.instanceOf(forName(it)) as ICompilerContributor)
|
|
||||||
}
|
|
||||||
xml.docContributors?.className?.forEach {
|
|
||||||
docContributors.add(factory.instanceOf(forName(it)) as IDocContributor)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Populate pluginInfo with what was found in the plug-in's kobalt-plugin.xml
|
||||||
|
*/
|
||||||
fun addPluginInfo(pluginInfo: PluginInfo) {
|
fun addPluginInfo(pluginInfo: PluginInfo) {
|
||||||
log(2, "Found new plug-in, adding it to pluginInfo: $pluginInfo")
|
log(2, "Found new plug-in, adding it to pluginInfo: $pluginInfo")
|
||||||
|
|
||||||
|
@ -206,6 +149,14 @@ class PluginInfo(val xml: KobaltPluginXml, val classLoader: ClassLoader?) {
|
||||||
projectContributors.addAll(pluginInfo.projectContributors)
|
projectContributors.addAll(pluginInfo.projectContributors)
|
||||||
initContributors.addAll(pluginInfo.initContributors)
|
initContributors.addAll(pluginInfo.initContributors)
|
||||||
repoContributors.addAll(pluginInfo.repoContributors)
|
repoContributors.addAll(pluginInfo.repoContributors)
|
||||||
|
compilerInterceptors.addAll(pluginInfo.compilerInterceptors)
|
||||||
|
sourceDirectoriesInterceptors.addAll(pluginInfo.sourceDirectoriesInterceptors)
|
||||||
|
buildDirectoryInterceptors.addAll(pluginInfo.buildDirectoryInterceptors)
|
||||||
|
runnerContributors.addAll(pluginInfo.runnerContributors)
|
||||||
|
testRunnerContributors.addAll(pluginInfo.testRunnerContributors)
|
||||||
|
classpathInterceptors.addAll(pluginInfo.classpathInterceptors)
|
||||||
|
compilerContributors.addAll(pluginInfo.compilerContributors)
|
||||||
|
docContributors.addAll(pluginInfo.docContributors)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,58 +1,25 @@
|
||||||
<kobalt-plugin>
|
<kobalt-plugin>
|
||||||
<name>kobalt</name>
|
<name>kobalt</name>
|
||||||
<factory-class-name>com.beust.kobalt.internal.GuiceFactory</factory-class-name>
|
<factory-class-name>com.beust.kobalt.internal.GuiceFactory</factory-class-name>
|
||||||
<plugins>
|
<plugin-actors>
|
||||||
|
<!-- Classes within this tag are instantiated and the introspected by Kobalt. Whenever they -->
|
||||||
|
<!-- are found to implement one of IPluginActor's interfaces, they are added as such -->
|
||||||
|
<class-name>com.beust.kobalt.plugin.java.JavaPlugin</class-name>
|
||||||
<class-name>com.beust.kobalt.plugin.android.AndroidPlugin</class-name>
|
<class-name>com.beust.kobalt.plugin.android.AndroidPlugin</class-name>
|
||||||
<class-name>com.beust.kobalt.plugin.application.ApplicationPlugin</class-name>
|
<class-name>com.beust.kobalt.plugin.application.ApplicationPlugin</class-name>
|
||||||
<class-name>com.beust.kobalt.plugin.KobaltPlugin</class-name>
|
<class-name>com.beust.kobalt.plugin.KobaltPlugin</class-name>
|
||||||
<class-name>com.beust.kobalt.plugin.java.JavaPlugin</class-name>
|
|
||||||
<class-name>com.beust.kobalt.plugin.kotlin.KotlinPlugin</class-name>
|
<class-name>com.beust.kobalt.plugin.kotlin.KotlinPlugin</class-name>
|
||||||
<class-name>com.beust.kobalt.plugin.packaging.PackagingPlugin</class-name>
|
<class-name>com.beust.kobalt.plugin.packaging.PackagingPlugin</class-name>
|
||||||
<class-name>com.beust.kobalt.plugin.publish.PublishPlugin</class-name>
|
<class-name>com.beust.kobalt.plugin.publish.PublishPlugin</class-name>
|
||||||
<class-name>com.beust.kobalt.plugin.apt.AptPlugin</class-name>
|
<class-name>com.beust.kobalt.plugin.apt.AptPlugin</class-name>
|
||||||
</plugins>
|
|
||||||
<classpath-contributors>
|
<!-- These classes manage -init for Java and Kotlin -->
|
||||||
<class-name>com.beust.kobalt.plugin.android.AndroidPlugin</class-name>
|
|
||||||
<class-name>com.beust.kobalt.plugin.kotlin.KotlinPlugin</class-name>
|
|
||||||
</classpath-contributors>
|
|
||||||
<project-contributors>
|
|
||||||
<class-name>com.beust.kobalt.plugin.java.JavaPlugin</class-name>
|
|
||||||
<class-name>com.beust.kobalt.plugin.kotlin.KotlinPlugin</class-name>
|
|
||||||
</project-contributors>
|
|
||||||
<init-contributors>
|
|
||||||
<class-name>com.beust.kobalt.plugin.java.JavaBuildGenerator</class-name>
|
<class-name>com.beust.kobalt.plugin.java.JavaBuildGenerator</class-name>
|
||||||
<class-name>com.beust.kobalt.plugin.kotlin.KotlinBuildGenerator</class-name>
|
<class-name>com.beust.kobalt.plugin.kotlin.KotlinBuildGenerator</class-name>
|
||||||
</init-contributors>
|
|
||||||
<repo-contributors>
|
<!-- These classes run TestNG or JUnit depending on which one the user picked -->
|
||||||
<class-name>com.beust.kobalt.plugin.android.AndroidPlugin</class-name>
|
|
||||||
</repo-contributors>
|
|
||||||
<compiler-flag-contributors>
|
|
||||||
<class-name>com.beust.kobalt.plugin.android.AndroidPlugin</class-name>
|
|
||||||
<class-name>com.beust.kobalt.plugin.apt.AptPlugin</class-name>
|
|
||||||
</compiler-flag-contributors>
|
|
||||||
<build-directory-interceptors>
|
|
||||||
<class-name>com.beust.kobalt.plugin.android.AndroidPlugin</class-name>
|
|
||||||
</build-directory-interceptors>
|
|
||||||
<compiler-interceptors>
|
|
||||||
<class-name>com.beust.kobalt.plugin.android.AndroidPlugin</class-name>
|
|
||||||
</compiler-interceptors>
|
|
||||||
<runner-contributors>
|
|
||||||
<class-name>com.beust.kobalt.plugin.application.ApplicationPlugin</class-name>
|
|
||||||
<class-name>com.beust.kobalt.plugin.android.AndroidPlugin</class-name>
|
|
||||||
</runner-contributors>
|
|
||||||
<test-runner-contributors>
|
|
||||||
<class-name>com.beust.kobalt.internal.JUnitRunner</class-name>
|
<class-name>com.beust.kobalt.internal.JUnitRunner</class-name>
|
||||||
<class-name>com.beust.kobalt.internal.TestNgRunner</class-name>
|
<class-name>com.beust.kobalt.internal.TestNgRunner</class-name>
|
||||||
</test-runner-contributors>
|
|
||||||
<classpath-interceptors>
|
</plugin-actors>
|
||||||
<class-name>com.beust.kobalt.plugin.android.AndroidPlugin</class-name>
|
|
||||||
</classpath-interceptors>
|
|
||||||
<compiler-contributors>
|
|
||||||
<class-name>com.beust.kobalt.plugin.java.JavaPlugin</class-name>
|
|
||||||
<class-name>com.beust.kobalt.plugin.kotlin.KotlinPlugin</class-name>
|
|
||||||
</compiler-contributors>
|
|
||||||
<doc-contributors>
|
|
||||||
<class-name>com.beust.kobalt.plugin.java.JavaPlugin</class-name>
|
|
||||||
<class-name>com.beust.kobalt.plugin.kotlin.KotlinPlugin</class-name>
|
|
||||||
</doc-contributors>
|
|
||||||
</kobalt-plugin>
|
</kobalt-plugin>
|
Loading…
Add table
Add a link
Reference in a new issue