mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-27 00:38:11 -07:00
Clean up plugin-names.
This commit is contained in:
parent
bf1b827324
commit
e1c3ea1298
11 changed files with 42 additions and 37 deletions
|
@ -10,7 +10,7 @@ import com.beust.kobalt.maven.LocalRepo
|
||||||
import com.beust.kobalt.misc.KFiles
|
import com.beust.kobalt.misc.KFiles
|
||||||
import com.beust.kobalt.misc.KobaltExecutors
|
import com.beust.kobalt.misc.KobaltExecutors
|
||||||
import com.beust.kobalt.misc.log
|
import com.beust.kobalt.misc.log
|
||||||
import com.beust.kobalt.plugin.KobaltDefaultPlugin
|
import com.beust.kobalt.plugin.KobaltPlugin
|
||||||
import com.beust.kobalt.plugin.packaging.JarUtils
|
import com.beust.kobalt.plugin.packaging.JarUtils
|
||||||
import com.google.inject.Provider
|
import com.google.inject.Provider
|
||||||
import java.lang.reflect.Method
|
import java.lang.reflect.Method
|
||||||
|
@ -43,7 +43,7 @@ public class Plugins @Inject constructor (val taskManagerProvider : Provider<Tas
|
||||||
*/
|
*/
|
||||||
val dynamicPlugins : ArrayList<IClasspathDependency> = arrayListOf()
|
val dynamicPlugins : ArrayList<IClasspathDependency> = arrayListOf()
|
||||||
|
|
||||||
val defaultPlugin : IPlugin get() = findPlugin(KobaltDefaultPlugin.NAME)!!
|
val defaultPlugin : IPlugin get() = findPlugin(KobaltPlugin.PLUGIN_NAME)!!
|
||||||
|
|
||||||
fun findPlugin(name: String) : IPlugin? = pluginMap[name]
|
fun findPlugin(name: String) : IPlugin? = pluginMap[name]
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,7 +106,8 @@ class Variant(val initialProductFlavor: ProductFlavorConfig? = null,
|
||||||
val buildConfigs = findBuildConfigs(project, context.variant)
|
val buildConfigs = findBuildConfigs(project, context.variant)
|
||||||
|
|
||||||
if (buildConfigs.size > 0) {
|
if (buildConfigs.size > 0) {
|
||||||
val androidConfig = (Kobalt.findPlugin("android") as AndroidPlugin).configurationFor(project)
|
val androidConfig = (Kobalt.findPlugin(AndroidPlugin.PLUGIN_NAME) as AndroidPlugin)
|
||||||
|
.configurationFor(project)
|
||||||
val pkg = androidConfig?.applicationId ?: project.packageName ?: project.group
|
val pkg = androidConfig?.applicationId ?: project.packageName ?: project.group
|
||||||
?: throw KobaltException(
|
?: throw KobaltException(
|
||||||
"packageName needs to be defined on the project in order to generate BuildConfig")
|
"packageName needs to be defined on the project in order to generate BuildConfig")
|
||||||
|
|
|
@ -7,10 +7,10 @@ import javax.inject.Singleton
|
||||||
* This plugin is used to gather tasks defined in build files, since these tasks don't really belong to any plugin.
|
* This plugin is used to gather tasks defined in build files, since these tasks don't really belong to any plugin.
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class KobaltDefaultPlugin : BasePlugin() {
|
public class KobaltPlugin : BasePlugin() {
|
||||||
companion object {
|
companion object {
|
||||||
public val NAME = "Kobalt default"
|
public val PLUGIN_NAME = "Kobalt"
|
||||||
}
|
}
|
||||||
|
|
||||||
override val name: String get() = NAME
|
override val name: String get() = PLUGIN_NAME
|
||||||
}
|
}
|
|
@ -31,7 +31,7 @@ class AndroidConfig(var compileSdkVersion : String = "23",
|
||||||
fun Project.android(init: AndroidConfig.() -> Unit) : AndroidConfig {
|
fun Project.android(init: AndroidConfig.() -> Unit) : AndroidConfig {
|
||||||
val pd = AndroidConfig()
|
val pd = AndroidConfig()
|
||||||
pd.init()
|
pd.init()
|
||||||
(Kobalt.findPlugin("android") as AndroidPlugin).addConfiguration(this, pd)
|
(Kobalt.findPlugin(AndroidPlugin.PLUGIN_NAME) as AndroidPlugin).addConfiguration(this, pd)
|
||||||
return pd
|
return pd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,13 @@ fun Project.android(init: AndroidConfig.() -> Unit) : AndroidConfig {
|
||||||
public class AndroidPlugin @Inject constructor(val javaCompiler: JavaCompiler, val merger: Merger)
|
public class AndroidPlugin @Inject constructor(val javaCompiler: JavaCompiler, val merger: Merger)
|
||||||
: ConfigPlugin<AndroidConfig>(), IClasspathContributor, IRepoContributor, ICompilerFlagContributor,
|
: ConfigPlugin<AndroidConfig>(), IClasspathContributor, IRepoContributor, ICompilerFlagContributor,
|
||||||
ICompilerInterceptor, IBuildDirectoryIncerceptor, IRunContributor {
|
ICompilerInterceptor, IBuildDirectoryIncerceptor, IRunContributor {
|
||||||
override val name = "android"
|
|
||||||
|
companion object {
|
||||||
|
const val PLUGIN_NAME = "Android"
|
||||||
|
const val TASK_GENERATE_DEX = "generateDex"
|
||||||
|
}
|
||||||
|
|
||||||
|
override val name = PLUGIN_NAME
|
||||||
|
|
||||||
fun isAndroid(project: Project) = configurationFor(project) != null
|
fun isAndroid(project: Project) = configurationFor(project) != null
|
||||||
|
|
||||||
|
@ -237,10 +243,6 @@ public class AndroidPlugin @Inject constructor(val javaCompiler: JavaCompiler, v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
|
||||||
const val TASK_GENERATE_DEX = "generateDex"
|
|
||||||
}
|
|
||||||
|
|
||||||
@Task(name = TASK_GENERATE_DEX, description = "Generate the dex file", runBefore = arrayOf("assemble"),
|
@Task(name = TASK_GENERATE_DEX, description = "Generate the dex file", runBefore = arrayOf("assemble"),
|
||||||
runAfter = arrayOf("compile"))
|
runAfter = arrayOf("compile"))
|
||||||
fun taskGenerateDex(project: Project): TaskResult {
|
fun taskGenerateDex(project: Project): TaskResult {
|
||||||
|
|
|
@ -27,7 +27,7 @@ class ApplicationConfig {
|
||||||
fun Project.application(init: ApplicationConfig.() -> Unit) {
|
fun Project.application(init: ApplicationConfig.() -> Unit) {
|
||||||
ApplicationConfig().let { config ->
|
ApplicationConfig().let { config ->
|
||||||
config.init()
|
config.init()
|
||||||
(Plugins.findPlugin(ApplicationPlugin.NAME) as ApplicationPlugin).addConfiguration(this, config)
|
(Plugins.findPlugin(ApplicationPlugin.PLUGIN_NAME) as ApplicationPlugin).addConfiguration(this, config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,10 +36,10 @@ class ApplicationPlugin @Inject constructor(val executors: KobaltExecutors,
|
||||||
val dependencyManager: DependencyManager) : ConfigPlugin<ApplicationConfig>(), IRunContributor {
|
val dependencyManager: DependencyManager) : ConfigPlugin<ApplicationConfig>(), IRunContributor {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val NAME = "application"
|
const val PLUGIN_NAME = "Application"
|
||||||
}
|
}
|
||||||
|
|
||||||
override val name = NAME
|
override val name = PLUGIN_NAME
|
||||||
|
|
||||||
override fun apply(project: Project, context: KobaltContext) {
|
override fun apply(project: Project, context: KobaltContext) {
|
||||||
super.apply(project, context)
|
super.apply(project, context)
|
||||||
|
|
|
@ -20,11 +20,10 @@ import javax.inject.Singleton
|
||||||
public class AptPlugin @Inject constructor(val depFactory: DepFactory, val executors: KobaltExecutors)
|
public class AptPlugin @Inject constructor(val depFactory: DepFactory, val executors: KobaltExecutors)
|
||||||
: ConfigPlugin<AptConfig>(), ICompilerFlagContributor {
|
: ConfigPlugin<AptConfig>(), ICompilerFlagContributor {
|
||||||
companion object {
|
companion object {
|
||||||
const val TASK_APT: String = "runApt"
|
const val PLUGIN_NAME = "Apt"
|
||||||
const val NAME = "apt"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override val name = NAME
|
override val name = PLUGIN_NAME
|
||||||
|
|
||||||
// ICompilerFlagContributor
|
// ICompilerFlagContributor
|
||||||
override fun flagsFor(project: Project, currentFlags: List<String>) : List<String> {
|
override fun flagsFor(project: Project, currentFlags: List<String>) : List<String> {
|
||||||
|
@ -56,13 +55,13 @@ class AptConfig(var outputDir: String = "generated/sources/apt")
|
||||||
public fun Project.apt(init: AptConfig.() -> Unit) {
|
public fun Project.apt(init: AptConfig.() -> Unit) {
|
||||||
AptConfig().let {
|
AptConfig().let {
|
||||||
it.init()
|
it.init()
|
||||||
(Kobalt.findPlugin(AptPlugin.NAME) as AptPlugin).addConfiguration(this, it)
|
(Kobalt.findPlugin(AptPlugin.PLUGIN_NAME) as AptPlugin).addConfiguration(this, it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Directive
|
@Directive
|
||||||
fun Dependencies.apt(vararg dep: String) {
|
fun Dependencies.apt(vararg dep: String) {
|
||||||
dep.forEach {
|
dep.forEach {
|
||||||
(Kobalt.findPlugin(AptPlugin.NAME) as AptPlugin).addAptDependency(this, it)
|
(Kobalt.findPlugin(AptPlugin.PLUGIN_NAME) as AptPlugin).addAptDependency(this, it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ class DokkaPlugin : ConfigsPlugin<DokkaConfig>() {
|
||||||
override val name = PLUGIN_NAME
|
override val name = PLUGIN_NAME
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val PLUGIN_NAME = "dokka"
|
const val PLUGIN_NAME = "Dokka"
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -22,7 +22,7 @@ import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class JavaPlugin @Inject constructor(
|
class JavaPlugin @Inject constructor(
|
||||||
override val localRepo: LocalRepo,
|
override val localRepo: LocalRepo,
|
||||||
override val files: KFiles,
|
override val files: KFiles,
|
||||||
override val depFactory: DepFactory,
|
override val depFactory: DepFactory,
|
||||||
|
@ -32,12 +32,13 @@ public class JavaPlugin @Inject constructor(
|
||||||
override val jvmCompiler: JvmCompiler)
|
override val jvmCompiler: JvmCompiler)
|
||||||
: JvmCompilerPlugin(localRepo, files, depFactory, dependencyManager, executors, jvmCompiler) {
|
: JvmCompilerPlugin(localRepo, files, depFactory, dependencyManager, executors, jvmCompiler) {
|
||||||
companion object {
|
companion object {
|
||||||
public const val TASK_COMPILE : String = "compile"
|
const val PLUGIN_NAME = "Java"
|
||||||
public const val TASK_JAVADOC : String = "javadoc"
|
const val TASK_COMPILE = "compile"
|
||||||
public const val TASK_COMPILE_TEST: String = "compileTest"
|
const val TASK_JAVADOC = "javadoc"
|
||||||
|
const val TASK_COMPILE_TEST = "compileTest"
|
||||||
}
|
}
|
||||||
|
|
||||||
override val name = "java"
|
override val name = PLUGIN_NAME
|
||||||
|
|
||||||
override fun accept(project: Project) = project is JavaProject
|
override fun accept(project: Project) = project is JavaProject
|
||||||
|
|
||||||
|
@ -95,13 +96,13 @@ public class JavaPlugin @Inject constructor(
|
||||||
public fun javaProject(vararg project: Project, init: JavaProject.() -> Unit): JavaProject {
|
public fun javaProject(vararg project: Project, init: JavaProject.() -> Unit): JavaProject {
|
||||||
return JavaProject().apply {
|
return JavaProject().apply {
|
||||||
init()
|
init()
|
||||||
(Kobalt.findPlugin("java") as BasePlugin).addProject(this, project)
|
(Kobalt.findPlugin(JavaPlugin.PLUGIN_NAME) as BasePlugin).addProject(this, project)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class JavaCompilerConfig(val project: Project) {
|
class JavaCompilerConfig(val project: Project) {
|
||||||
fun args(vararg options: String) {
|
fun args(vararg options: String) {
|
||||||
(Kobalt.findPlugin("java") as JvmCompilerPlugin).addCompilerArgs(project, *options)
|
(Kobalt.findPlugin(JavaPlugin.PLUGIN_NAME) as JvmCompilerPlugin).addCompilerArgs(project, *options)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,11 +30,12 @@ class KotlinPlugin @Inject constructor(
|
||||||
IClasspathContributor {
|
IClasspathContributor {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
public const val TASK_COMPILE: String = "compile"
|
const val PLUGIN_NAME = "Kotlin"
|
||||||
public const val TASK_COMPILE_TEST: String = "compileTest"
|
const val TASK_COMPILE: String = "compile"
|
||||||
|
const val TASK_COMPILE_TEST: String = "compileTest"
|
||||||
}
|
}
|
||||||
|
|
||||||
override val name = "kotlin"
|
override val name = PLUGIN_NAME
|
||||||
|
|
||||||
override fun accept(project: Project) = project is KotlinProject
|
override fun accept(project: Project) = project is KotlinProject
|
||||||
|
|
||||||
|
@ -116,13 +117,13 @@ class KotlinPlugin @Inject constructor(
|
||||||
fun kotlinProject(vararg project: Project, init: KotlinProject.() -> Unit): KotlinProject {
|
fun kotlinProject(vararg project: Project, init: KotlinProject.() -> Unit): KotlinProject {
|
||||||
return KotlinProject().apply {
|
return KotlinProject().apply {
|
||||||
init()
|
init()
|
||||||
(Kobalt.findPlugin("kotlin") as BasePlugin).addProject(this, project)
|
(Kobalt.findPlugin(KotlinPlugin.PLUGIN_NAME) as BasePlugin).addProject(this, project)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class KotlinCompilerConfig(val project: Project) {
|
class KotlinCompilerConfig(val project: Project) {
|
||||||
fun args(vararg options: String) {
|
fun args(vararg options: String) {
|
||||||
(Kobalt.findPlugin("kotlin") as JvmCompilerPlugin).addCompilerArgs(project, *options)
|
(Kobalt.findPlugin(KotlinPlugin.PLUGIN_NAME) as JvmCompilerPlugin).addCompilerArgs(project, *options)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ class PackagingPlugin @Inject constructor(val dependencyManager : DependencyMana
|
||||||
val executors: KobaltExecutors, val localRepo: LocalRepo) : ConfigPlugin<InstallConfig>() {
|
val executors: KobaltExecutors, val localRepo: LocalRepo) : ConfigPlugin<InstallConfig>() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val PLUGIN_NAME = "packaging"
|
const val PLUGIN_NAME = "Packaging"
|
||||||
|
|
||||||
@ExportedProjectProperty(doc = "Where the libraries are saved", type = "String")
|
@ExportedProjectProperty(doc = "Where the libraries are saved", type = "String")
|
||||||
const val LIBS_DIR = "libsDir"
|
const val LIBS_DIR = "libsDir"
|
||||||
|
|
|
@ -18,9 +18,10 @@ public class PublishPlugin @Inject constructor(val files: KFiles, val factory: P
|
||||||
val jcenterFactory: JCenterApi.IFactory, val github: GithubApi, val localProperties: LocalProperties)
|
val jcenterFactory: JCenterApi.IFactory, val github: GithubApi, val localProperties: LocalProperties)
|
||||||
: BasePlugin() {
|
: BasePlugin() {
|
||||||
|
|
||||||
override val name = "publish"
|
override val name = PLUGIN_NAME
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
const val PLUGIN_NAME = "Publish"
|
||||||
private const val TASK_UPLOAD_JCENTER = "uploadJcenter"
|
private const val TASK_UPLOAD_JCENTER = "uploadJcenter"
|
||||||
private const val TASK_UPLOAD_GITHUB = "uploadGithub"
|
private const val TASK_UPLOAD_GITHUB = "uploadGithub"
|
||||||
private const val TASK_GENERATE_POM = "generatePom"
|
private const val TASK_GENERATE_POM = "generatePom"
|
||||||
|
@ -152,7 +153,7 @@ data class GithubConfig(val project: Project) {
|
||||||
public fun Project.github(init: GithubConfig.() -> Unit) {
|
public fun Project.github(init: GithubConfig.() -> Unit) {
|
||||||
with(GithubConfig(this)) {
|
with(GithubConfig(this)) {
|
||||||
init()
|
init()
|
||||||
(Kobalt.findPlugin("publish") as PublishPlugin).addGithubConfiguration(name, this)
|
(Kobalt.findPlugin(PublishPlugin.PLUGIN_NAME) as PublishPlugin).addGithubConfiguration(name, this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,6 +171,6 @@ data class JCenterConfig(val project: Project) {
|
||||||
public fun Project.jcenter(init: JCenterConfig.() -> Unit) {
|
public fun Project.jcenter(init: JCenterConfig.() -> Unit) {
|
||||||
with(JCenterConfig(this)) {
|
with(JCenterConfig(this)) {
|
||||||
init()
|
init()
|
||||||
(Kobalt.findPlugin("publish") as PublishPlugin).addJCenterConfiguration(name, this)
|
(Kobalt.findPlugin(PublishPlugin.PLUGIN_NAME) as PublishPlugin).addJCenterConfiguration(name, this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue