1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 16:28:12 -07:00

Extract contributors in their own files.

This commit is contained in:
Cedric Beust 2015-11-07 19:48:51 -08:00
parent 4b86f21810
commit af8ad34ac3
6 changed files with 67 additions and 57 deletions

View file

@ -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<IClasspathDependency>
}

View file

@ -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 <T> instanceOf(c: Class<T>) : T
}

View file

@ -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)
}

View file

@ -0,0 +1,11 @@
package com.beust.kobalt.api
/**
* Plugins that create projects need to implement this interface.
*/
interface IProjectContributor {
fun projects() : List<ProjectDescription>
}
class ProjectDescription(val project: Project, val dependsOn: List<Project>)

View file

@ -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<URI>
}

View file

@ -1,48 +1,16 @@
package com.beust.kobalt.api package com.beust.kobalt.api
import com.beust.kobalt.maven.IClasspathDependency
import com.beust.kobalt.misc.log import com.beust.kobalt.misc.log
import java.io.ByteArrayInputStream import java.io.ByteArrayInputStream
import java.io.File
import java.io.InputStream import java.io.InputStream
import java.io.OutputStream
import java.net.URI
import javax.xml.bind.JAXBContext import javax.xml.bind.JAXBContext
import javax.xml.bind.annotation.XmlElement import javax.xml.bind.annotation.XmlElement
import javax.xml.bind.annotation.XmlRootElement 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<ProjectDescription>
}
class ProjectDescription(val project: Project, val dependsOn: List<Project>)
/**
* Plugins that export classpath entries need to implement this interface.
*/
interface IClasspathContributor {
fun entriesFor(project: Project?) : Collection<IClasspathDependency>
}
/**
* The factory function to use to instantiate all the contributors and other entities
* found in plugin.xml.
*/
interface IFactory {
fun <T> instanceOf(c: Class<T>) : T
}
/** /**
* If a plug-in didn't specify a factory, we use our own injector to instantiate all its components. * 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 <T> instanceOf(c: Class<T>) : T = Kobalt.INJECTOR.getInstance(c) override fun <T> instanceOf(c: Class<T>) : 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<URI>
}
///// /////
// XML parsing // XML parsing
// //