mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Fix Javadoc generation.
This commit is contained in:
parent
8589c46b43
commit
5609bb27aa
13 changed files with 115 additions and 59 deletions
|
@ -3,13 +3,27 @@ package com.beust.kobalt.api
|
|||
/**
|
||||
* Plugins that add compiler flags.
|
||||
*/
|
||||
interface ICompilerFlagContributor : IContributor {
|
||||
fun flagsFor(project: Project, context: KobaltContext, currentFlags: List<String>,
|
||||
suffixesBeingCompiled: List<String>): List<String>
|
||||
val flagPriority: Int
|
||||
get() = DEFAULT_FLAG_PRIORITY
|
||||
|
||||
class FlagContributor(val flagPriority: Int = DEFAULT_FLAG_PRIORITY,
|
||||
val closure: (project: Project, context: KobaltContext, currentFlags: List<String>,
|
||||
suffixesBeingCompiled: List<String>) -> List<String>) : IContributor {
|
||||
companion object {
|
||||
val DEFAULT_FLAG_PRIORITY = 20
|
||||
}
|
||||
|
||||
fun flagsFor(project: Project, context: KobaltContext, currentFlags: List<String>,
|
||||
suffixesBeingCompiled: List<String>) = closure(project, context, currentFlags, suffixesBeingCompiled)
|
||||
}
|
||||
|
||||
interface IFlagBase {
|
||||
val flagPriority: Int get() = FlagContributor.DEFAULT_FLAG_PRIORITY
|
||||
}
|
||||
|
||||
interface ICompilerFlagContributor : IContributor, IFlagBase {
|
||||
fun compilerFlagsFor(project: Project, context: KobaltContext, currentFlags: List<String>,
|
||||
suffixesBeingCompiled: List<String>): List<String>
|
||||
}
|
||||
|
||||
interface IDocFlagContributor : IContributor, IFlagBase {
|
||||
fun docFlagsFor(project: Project, context: KobaltContext, currentFlags: List<String>,
|
||||
suffixesBeingCompiled: List<String>): List<String>
|
||||
}
|
|
@ -12,7 +12,7 @@ abstract class BaseJvmPlugin<T>(open val configActor: ConfigActor<T>) :
|
|||
ICompilerFlagContributor {
|
||||
companion object {
|
||||
// Run before other flag contributors
|
||||
val FLAG_CONTRIBUTOR_PRIORITY = ICompilerFlagContributor.DEFAULT_FLAG_PRIORITY - 10
|
||||
val FLAG_CONTRIBUTOR_PRIORITY = FlagContributor.DEFAULT_FLAG_PRIORITY - 10
|
||||
}
|
||||
|
||||
protected fun maybeCompilerArgs(sourceSuffixes: List<String>, suffixesBeingCompiled: List<String>,
|
||||
|
@ -21,14 +21,14 @@ abstract class BaseJvmPlugin<T>(open val configActor: ConfigActor<T>) :
|
|||
|
||||
override val flagPriority = FLAG_CONTRIBUTOR_PRIORITY
|
||||
|
||||
override fun accept(project: Project) = hasSourceFiles(project)
|
||||
override fun accept(project: Project) = sourceFileCount(project) > 0
|
||||
|
||||
// IBuildConfigContributor
|
||||
|
||||
private fun hasSourceFiles(project: Project)
|
||||
= KFiles.findSourceFiles(project.directory, project.sourceDirectories, sourceSuffixes()).size > 0
|
||||
protected fun sourceFileCount(project: Project)
|
||||
= KFiles.findSourceFiles(project.directory, project.sourceDirectories, sourceSuffixes()).size
|
||||
|
||||
fun affinity(project: Project) = if (hasSourceFiles(project)) 1 else 0
|
||||
fun affinity(project: Project) = sourceFileCount(project)
|
||||
|
||||
abstract fun sourceSuffixes() : List<String>
|
||||
}
|
|
@ -229,4 +229,25 @@ class CompilerUtils @Inject constructor(val files: KFiles,
|
|||
private fun isDependencyExcluded(id: IClasspathDependency, excluded: List<IClasspathDependency>)
|
||||
= excluded.any { id.id.startsWith(it.id) }
|
||||
|
||||
fun sourceCompilerFlags(project: Project?, context: KobaltContext, info: CompilerActionInfo) : List<String> {
|
||||
val adapters = context.pluginInfo.compilerFlagContributors.map {
|
||||
val closure = { project: Project, context: KobaltContext, currentFlags: List<String>,
|
||||
suffixesBeingCompiled: List<String>
|
||||
-> it.compilerFlagsFor(project, context, currentFlags, suffixesBeingCompiled) }
|
||||
FlagContributor(it.flagPriority, closure)
|
||||
}
|
||||
return compilerFlags(project, context, info, adapters)
|
||||
}
|
||||
|
||||
fun compilerFlags(project: Project?, context: KobaltContext, info: CompilerActionInfo,
|
||||
adapters: List<FlagContributor>) : List<String> {
|
||||
val result = arrayListOf<String>()
|
||||
if (project != null) {
|
||||
adapters.sortedBy { it.flagPriority }
|
||||
adapters.forEach {
|
||||
result.addAll(it.flagsFor(project, context, result, info.suffixesBeingCompiled))
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,13 +15,12 @@ import java.util.*
|
|||
* Also validates the classpath and run all the contributors.
|
||||
*/
|
||||
class JvmCompiler @Inject constructor(val dependencyManager: DependencyManager) {
|
||||
|
||||
/**
|
||||
* Take the given CompilerActionInfo and enrich it with all the applicable contributors and
|
||||
* then pass it to the ICompilerAction.
|
||||
*/
|
||||
fun doCompile(project: Project?, context: KobaltContext?, action: ICompilerAction, info: CompilerActionInfo)
|
||||
: TaskResult {
|
||||
fun doCompile(project: Project?, context: KobaltContext?, action: ICompilerAction, info: CompilerActionInfo,
|
||||
flags: List<String>): TaskResult {
|
||||
|
||||
// Dependencies
|
||||
val allDependencies = (info.dependencies
|
||||
|
@ -30,16 +29,7 @@ class JvmCompiler @Inject constructor(val dependencyManager: DependencyManager)
|
|||
|
||||
// Plugins that add flags to the compiler
|
||||
val currentFlags = arrayListOf<String>().apply { addAll(info.compilerArgs) }
|
||||
val contributorFlags : List<String> = if (project != null) {
|
||||
val contributors = context.pluginInfo.compilerFlagContributors
|
||||
contributors.sortBy { it.flagPriority }
|
||||
context.pluginInfo.compilerFlagContributors.forEach {
|
||||
currentFlags.addAll(it.flagsFor(project, context, currentFlags, info.suffixesBeingCompiled))
|
||||
}
|
||||
currentFlags
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
val contributorFlags : List<String> = if (project != null) flags else emptyList()
|
||||
|
||||
val addedFlags = contributorFlags + ArrayList(info.compilerArgs)
|
||||
|
||||
|
|
|
@ -150,8 +150,7 @@ open class JvmCompilerPlugin @Inject constructor(
|
|||
val results = arrayListOf<TaskResult>()
|
||||
|
||||
val compilerContributors = context.pluginInfo.compilerContributors
|
||||
ActorUtils.selectAffinityActors(project, context,
|
||||
context.pluginInfo.compilerContributors)
|
||||
ActorUtils.selectAffinityActors(project, context, context.pluginInfo.compilerContributors)
|
||||
|
||||
var failedResult: TaskResult? = null
|
||||
if (compilerContributors.isEmpty()) {
|
||||
|
|
|
@ -98,6 +98,7 @@ class PluginInfo(val xml: KobaltPluginXml, val pluginClassLoader: ClassLoader?,
|
|||
val localMavenRepoPathInterceptors = arrayListOf<ILocalMavenRepoPathInterceptor>()
|
||||
val buildListeners = arrayListOf<IBuildListener>()
|
||||
val buildReportContributors = arrayListOf<IBuildReportContributor>()
|
||||
val docFlagContributors = arrayListOf<IDocFlagContributor>()
|
||||
|
||||
// Note: intentionally repeating them here even though they are defined by our base class so
|
||||
// that this class always contains the full list of contributors and interceptors
|
||||
|
@ -216,6 +217,7 @@ class PluginInfo(val xml: KobaltPluginXml, val pluginClassLoader: ClassLoader?,
|
|||
if (this is ILocalMavenRepoPathInterceptor) localMavenRepoPathInterceptors.add(this)
|
||||
if (this is IBuildListener) buildListeners.add(this)
|
||||
if (this is IBuildReportContributor) buildReportContributors.add(this)
|
||||
if (this is IDocFlagContributor) docFlagContributors.add(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -230,11 +232,9 @@ class PluginInfo(val xml: KobaltPluginXml, val pluginClassLoader: ClassLoader?,
|
|||
taskContributors, incrementalTaskContributors, assemblyContributors,
|
||||
incrementalAssemblyContributors, testJvmFlagInterceptors,
|
||||
jvmFlagContributors, localMavenRepoPathInterceptors, buildListeners,
|
||||
buildReportContributors
|
||||
buildReportContributors, docFlagContributors
|
||||
).forEach {
|
||||
it.forEach {
|
||||
it.cleanUpActors()
|
||||
}
|
||||
it.forEach(IPluginActor::cleanUpActors)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -273,6 +273,7 @@ class PluginInfo(val xml: KobaltPluginXml, val pluginClassLoader: ClassLoader?,
|
|||
localMavenRepoPathInterceptors.addAll(pluginInfo.localMavenRepoPathInterceptors)
|
||||
buildListeners.addAll(pluginInfo.buildListeners)
|
||||
buildReportContributors.addAll(pluginInfo.buildReportContributors)
|
||||
docFlagContributors.addAll(pluginInfo.docFlagContributors)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -192,6 +192,7 @@ class TaskManager @Inject constructor(val args: Args,
|
|||
= TaskAnnotation(method, plugin, ta.name, ta.description, ta.group, ta.dependsOn, ta.reverseDependsOn,
|
||||
ta.runBefore, ta.runAfter, ta.alwaysRunAfter,
|
||||
{ project ->
|
||||
Kobalt.context?.variant = Variant()
|
||||
method.invoke(plugin, project) as TaskResult
|
||||
})
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue