From af8ad34ac3c9e46dedfe807c05340fadc265618e Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Sat, 7 Nov 2015 19:48:51 -0800 Subject: [PATCH] Extract contributors in their own files. --- .../beust/kobalt/api/IClasspathContributor.kt | 12 ++++ .../kotlin/com/beust/kobalt/api/IFactory.kt | 10 ++++ .../com/beust/kobalt/api/IInitContributor.kt | 22 +++++++ .../beust/kobalt/api/IProjectContributor.kt | 11 ++++ .../com/beust/kobalt/api/IRepoContributor.kt | 11 ++++ .../com/beust/kobalt/api/KobaltPluginXml.kt | 58 +------------------ 6 files changed, 67 insertions(+), 57 deletions(-) create mode 100644 src/main/kotlin/com/beust/kobalt/api/IClasspathContributor.kt create mode 100644 src/main/kotlin/com/beust/kobalt/api/IFactory.kt create mode 100644 src/main/kotlin/com/beust/kobalt/api/IInitContributor.kt create mode 100644 src/main/kotlin/com/beust/kobalt/api/IProjectContributor.kt create mode 100644 src/main/kotlin/com/beust/kobalt/api/IRepoContributor.kt diff --git a/src/main/kotlin/com/beust/kobalt/api/IClasspathContributor.kt b/src/main/kotlin/com/beust/kobalt/api/IClasspathContributor.kt new file mode 100644 index 00000000..e6b495bc --- /dev/null +++ b/src/main/kotlin/com/beust/kobalt/api/IClasspathContributor.kt @@ -0,0 +1,12 @@ +package com.beust.kobalt.api + +import com.beust.kobalt.maven.IClasspathDependency + +/** + * Plugins that export classpath entries need to implement this interface. + */ +interface IClasspathContributor { + fun entriesFor(project: Project?) : Collection +} + + diff --git a/src/main/kotlin/com/beust/kobalt/api/IFactory.kt b/src/main/kotlin/com/beust/kobalt/api/IFactory.kt new file mode 100644 index 00000000..bce9cb1a --- /dev/null +++ b/src/main/kotlin/com/beust/kobalt/api/IFactory.kt @@ -0,0 +1,10 @@ +package com.beust.kobalt.api + +/** + * The factory function to use to instantiate all the contributors and other entities + * found in plugin.xml. + */ +interface IFactory { + fun instanceOf(c: Class) : T +} + diff --git a/src/main/kotlin/com/beust/kobalt/api/IInitContributor.kt b/src/main/kotlin/com/beust/kobalt/api/IInitContributor.kt new file mode 100644 index 00000000..f2d991b1 --- /dev/null +++ b/src/main/kotlin/com/beust/kobalt/api/IInitContributor.kt @@ -0,0 +1,22 @@ +package com.beust.kobalt.api + +import java.io.File +import java.io.OutputStream + +/** + * Plugins that want to participate in the --init process (they can generate files to initialize + * a new project). + */ +interface IInitContributor { + /** + * How many files your plug-in understands in the given directory. The contributor with the + * highest number will be asked to generate the build file. + */ + fun filesManaged(dir: File): Int + + /** + * Generate the Build.kt file into the given OutputStream. + */ + fun generateBuildFile(os: OutputStream) +} + diff --git a/src/main/kotlin/com/beust/kobalt/api/IProjectContributor.kt b/src/main/kotlin/com/beust/kobalt/api/IProjectContributor.kt new file mode 100644 index 00000000..9c76e85f --- /dev/null +++ b/src/main/kotlin/com/beust/kobalt/api/IProjectContributor.kt @@ -0,0 +1,11 @@ +package com.beust.kobalt.api + +/** + * Plugins that create projects need to implement this interface. + */ +interface IProjectContributor { + fun projects() : List +} + +class ProjectDescription(val project: Project, val dependsOn: List) + diff --git a/src/main/kotlin/com/beust/kobalt/api/IRepoContributor.kt b/src/main/kotlin/com/beust/kobalt/api/IRepoContributor.kt new file mode 100644 index 00000000..b14942d5 --- /dev/null +++ b/src/main/kotlin/com/beust/kobalt/api/IRepoContributor.kt @@ -0,0 +1,11 @@ +package com.beust.kobalt.api + +import java.net.URI + +/** + * Plugins that add their own repos. + */ +interface IRepoContributor { + fun reposFor(project: Project?) : List +} + diff --git a/src/main/kotlin/com/beust/kobalt/api/KobaltPluginXml.kt b/src/main/kotlin/com/beust/kobalt/api/KobaltPluginXml.kt index dae3a3c2..e7d283f2 100644 --- a/src/main/kotlin/com/beust/kobalt/api/KobaltPluginXml.kt +++ b/src/main/kotlin/com/beust/kobalt/api/KobaltPluginXml.kt @@ -1,48 +1,16 @@ package com.beust.kobalt.api -import com.beust.kobalt.maven.IClasspathDependency import com.beust.kobalt.misc.log import java.io.ByteArrayInputStream -import java.io.File import java.io.InputStream -import java.io.OutputStream -import java.net.URI import javax.xml.bind.JAXBContext import javax.xml.bind.annotation.XmlElement import javax.xml.bind.annotation.XmlRootElement // -// Operations related to the parsing of plugin.xml: contributors, XML mapping, etc... +// Operations related to the parsing of plugin.xml: XML parsing, PluginInfo, etc... // -///// -// Contributors -// - -/** - * Plugins that create project need to implement this interface. - */ -interface IProjectContributor { - fun projects() : List -} - -class ProjectDescription(val project: Project, val dependsOn: List) - -/** - * Plugins that export classpath entries need to implement this interface. - */ -interface IClasspathContributor { - fun entriesFor(project: Project?) : Collection -} - -/** - * The factory function to use to instantiate all the contributors and other entities - * found in plugin.xml. - */ -interface IFactory { - fun instanceOf(c: Class) : T -} - /** * If a plug-in didn't specify a factory, we use our own injector to instantiate all its components. */ @@ -50,30 +18,6 @@ class GuiceFactory : IFactory { override fun instanceOf(c: Class) : T = Kobalt.INJECTOR.getInstance(c) } -/** - * Plugins that want to participate in the --init process (they can generate files to initialize - * a new project). - */ -interface IInitContributor { - /** - * How many files your plug-in understands in the given directory. The contributor with the - * highest number will be asked to generate the build file. - */ - fun filesManaged(dir: File): Int - - /** - * Generate the Build.kt file into the given OutputStream. - */ - fun generateBuildFile(os: OutputStream) -} - -/** - * Plugins that add their own repos. - */ -interface IRepoContributor { - fun reposFor(project: Project?) : List -} - ///// // XML parsing //