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:
parent
4b86f21810
commit
af8ad34ac3
6 changed files with 67 additions and 57 deletions
|
@ -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>
|
||||||
|
}
|
||||||
|
|
||||||
|
|
10
src/main/kotlin/com/beust/kobalt/api/IFactory.kt
Normal file
10
src/main/kotlin/com/beust/kobalt/api/IFactory.kt
Normal 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
|
||||||
|
}
|
||||||
|
|
22
src/main/kotlin/com/beust/kobalt/api/IInitContributor.kt
Normal file
22
src/main/kotlin/com/beust/kobalt/api/IInitContributor.kt
Normal 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)
|
||||||
|
}
|
||||||
|
|
11
src/main/kotlin/com/beust/kobalt/api/IProjectContributor.kt
Normal file
11
src/main/kotlin/com/beust/kobalt/api/IProjectContributor.kt
Normal 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>)
|
||||||
|
|
11
src/main/kotlin/com/beust/kobalt/api/IRepoContributor.kt
Normal file
11
src/main/kotlin/com/beust/kobalt/api/IRepoContributor.kt
Normal 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>
|
||||||
|
}
|
||||||
|
|
|
@ -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
|
||||||
//
|
//
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue