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
|
@ -143,7 +143,7 @@ val kobaltApp = project(kobaltPluginApi, wrapper) {
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// Used by the plugins
|
// Used by the plugins
|
||||||
compile("org.jetbrains.kotlin:kotlin-compiler-embeddable:1.0.3")
|
compile("org.jetbrains.kotlin:kotlin-compiler-embeddable:1.0.5")
|
||||||
|
|
||||||
// Used by the main app
|
// Used by the main app
|
||||||
compile("com.github.spullara.mustache.java:compiler:0.9.1",
|
compile("com.github.spullara.mustache.java:compiler:0.9.1",
|
||||||
|
@ -157,7 +157,7 @@ val kobaltApp = project(kobaltPluginApi, wrapper) {
|
||||||
"com.squareup.retrofit2:retrofit:${Versions.retrofit}",
|
"com.squareup.retrofit2:retrofit:${Versions.retrofit}",
|
||||||
"com.squareup.retrofit2:converter-gson:${Versions.retrofit}",
|
"com.squareup.retrofit2:converter-gson:${Versions.retrofit}",
|
||||||
"com.squareup.okhttp3:okhttp-ws:${Versions.okhttp}",
|
"com.squareup.okhttp3:okhttp-ws:${Versions.okhttp}",
|
||||||
"org.codehaus.plexus:plexus-utils:3.0.22",
|
"org.codehaus.plexus:plexus-utils:4.0",
|
||||||
"biz.aQute.bnd:bndlib:2.4.0",
|
"biz.aQute.bnd:bndlib:2.4.0",
|
||||||
|
|
||||||
"com.squareup.okhttp3:logging-interceptor:3.2.0",
|
"com.squareup.okhttp3:logging-interceptor:3.2.0",
|
||||||
|
|
|
@ -3,13 +3,27 @@ package com.beust.kobalt.api
|
||||||
/**
|
/**
|
||||||
* Plugins that add compiler flags.
|
* Plugins that add compiler flags.
|
||||||
*/
|
*/
|
||||||
interface ICompilerFlagContributor : IContributor {
|
class FlagContributor(val flagPriority: Int = DEFAULT_FLAG_PRIORITY,
|
||||||
fun flagsFor(project: Project, context: KobaltContext, currentFlags: List<String>,
|
val closure: (project: Project, context: KobaltContext, currentFlags: List<String>,
|
||||||
suffixesBeingCompiled: List<String>): List<String>
|
suffixesBeingCompiled: List<String>) -> List<String>) : IContributor {
|
||||||
val flagPriority: Int
|
|
||||||
get() = DEFAULT_FLAG_PRIORITY
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val DEFAULT_FLAG_PRIORITY = 20
|
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 {
|
ICompilerFlagContributor {
|
||||||
companion object {
|
companion object {
|
||||||
// Run before other flag contributors
|
// 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>,
|
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 val flagPriority = FLAG_CONTRIBUTOR_PRIORITY
|
||||||
|
|
||||||
override fun accept(project: Project) = hasSourceFiles(project)
|
override fun accept(project: Project) = sourceFileCount(project) > 0
|
||||||
|
|
||||||
// IBuildConfigContributor
|
// IBuildConfigContributor
|
||||||
|
|
||||||
private fun hasSourceFiles(project: Project)
|
protected fun sourceFileCount(project: Project)
|
||||||
= KFiles.findSourceFiles(project.directory, project.sourceDirectories, sourceSuffixes()).size > 0
|
= 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>
|
abstract fun sourceSuffixes() : List<String>
|
||||||
}
|
}
|
|
@ -229,4 +229,25 @@ class CompilerUtils @Inject constructor(val files: KFiles,
|
||||||
private fun isDependencyExcluded(id: IClasspathDependency, excluded: List<IClasspathDependency>)
|
private fun isDependencyExcluded(id: IClasspathDependency, excluded: List<IClasspathDependency>)
|
||||||
= excluded.any { id.id.startsWith(it.id) }
|
= 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.
|
* Also validates the classpath and run all the contributors.
|
||||||
*/
|
*/
|
||||||
class JvmCompiler @Inject constructor(val dependencyManager: DependencyManager) {
|
class JvmCompiler @Inject constructor(val dependencyManager: DependencyManager) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Take the given CompilerActionInfo and enrich it with all the applicable contributors and
|
* Take the given CompilerActionInfo and enrich it with all the applicable contributors and
|
||||||
* then pass it to the ICompilerAction.
|
* then pass it to the ICompilerAction.
|
||||||
*/
|
*/
|
||||||
fun doCompile(project: Project?, context: KobaltContext?, action: ICompilerAction, info: CompilerActionInfo)
|
fun doCompile(project: Project?, context: KobaltContext?, action: ICompilerAction, info: CompilerActionInfo,
|
||||||
: TaskResult {
|
flags: List<String>): TaskResult {
|
||||||
|
|
||||||
// Dependencies
|
// Dependencies
|
||||||
val allDependencies = (info.dependencies
|
val allDependencies = (info.dependencies
|
||||||
|
@ -30,16 +29,7 @@ class JvmCompiler @Inject constructor(val dependencyManager: DependencyManager)
|
||||||
|
|
||||||
// Plugins that add flags to the compiler
|
// Plugins that add flags to the compiler
|
||||||
val currentFlags = arrayListOf<String>().apply { addAll(info.compilerArgs) }
|
val currentFlags = arrayListOf<String>().apply { addAll(info.compilerArgs) }
|
||||||
val contributorFlags : List<String> = if (project != null) {
|
val contributorFlags : List<String> = if (project != null) flags else emptyList()
|
||||||
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 addedFlags = contributorFlags + ArrayList(info.compilerArgs)
|
val addedFlags = contributorFlags + ArrayList(info.compilerArgs)
|
||||||
|
|
||||||
|
|
|
@ -150,8 +150,7 @@ open class JvmCompilerPlugin @Inject constructor(
|
||||||
val results = arrayListOf<TaskResult>()
|
val results = arrayListOf<TaskResult>()
|
||||||
|
|
||||||
val compilerContributors = context.pluginInfo.compilerContributors
|
val compilerContributors = context.pluginInfo.compilerContributors
|
||||||
ActorUtils.selectAffinityActors(project, context,
|
ActorUtils.selectAffinityActors(project, context, context.pluginInfo.compilerContributors)
|
||||||
context.pluginInfo.compilerContributors)
|
|
||||||
|
|
||||||
var failedResult: TaskResult? = null
|
var failedResult: TaskResult? = null
|
||||||
if (compilerContributors.isEmpty()) {
|
if (compilerContributors.isEmpty()) {
|
||||||
|
|
|
@ -98,6 +98,7 @@ class PluginInfo(val xml: KobaltPluginXml, val pluginClassLoader: ClassLoader?,
|
||||||
val localMavenRepoPathInterceptors = arrayListOf<ILocalMavenRepoPathInterceptor>()
|
val localMavenRepoPathInterceptors = arrayListOf<ILocalMavenRepoPathInterceptor>()
|
||||||
val buildListeners = arrayListOf<IBuildListener>()
|
val buildListeners = arrayListOf<IBuildListener>()
|
||||||
val buildReportContributors = arrayListOf<IBuildReportContributor>()
|
val buildReportContributors = arrayListOf<IBuildReportContributor>()
|
||||||
|
val docFlagContributors = arrayListOf<IDocFlagContributor>()
|
||||||
|
|
||||||
// Note: intentionally repeating them here even though they are defined by our base class so
|
// 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
|
// 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 ILocalMavenRepoPathInterceptor) localMavenRepoPathInterceptors.add(this)
|
||||||
if (this is IBuildListener) buildListeners.add(this)
|
if (this is IBuildListener) buildListeners.add(this)
|
||||||
if (this is IBuildReportContributor) buildReportContributors.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,
|
taskContributors, incrementalTaskContributors, assemblyContributors,
|
||||||
incrementalAssemblyContributors, testJvmFlagInterceptors,
|
incrementalAssemblyContributors, testJvmFlagInterceptors,
|
||||||
jvmFlagContributors, localMavenRepoPathInterceptors, buildListeners,
|
jvmFlagContributors, localMavenRepoPathInterceptors, buildListeners,
|
||||||
buildReportContributors
|
buildReportContributors, docFlagContributors
|
||||||
).forEach {
|
).forEach {
|
||||||
it.forEach {
|
it.forEach(IPluginActor::cleanUpActors)
|
||||||
it.cleanUpActors()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,6 +273,7 @@ class PluginInfo(val xml: KobaltPluginXml, val pluginClassLoader: ClassLoader?,
|
||||||
localMavenRepoPathInterceptors.addAll(pluginInfo.localMavenRepoPathInterceptors)
|
localMavenRepoPathInterceptors.addAll(pluginInfo.localMavenRepoPathInterceptors)
|
||||||
buildListeners.addAll(pluginInfo.buildListeners)
|
buildListeners.addAll(pluginInfo.buildListeners)
|
||||||
buildReportContributors.addAll(pluginInfo.buildReportContributors)
|
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,
|
= TaskAnnotation(method, plugin, ta.name, ta.description, ta.group, ta.dependsOn, ta.reverseDependsOn,
|
||||||
ta.runBefore, ta.runAfter, ta.alwaysRunAfter,
|
ta.runBefore, ta.runAfter, ta.alwaysRunAfter,
|
||||||
{ project ->
|
{ project ->
|
||||||
|
Kobalt.context?.variant = Variant()
|
||||||
method.invoke(plugin, project) as TaskResult
|
method.invoke(plugin, project) as TaskResult
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, va
|
||||||
context.variant.toIntermediateDir())
|
context.variant.toIntermediateDir())
|
||||||
|
|
||||||
// ICompilerFlagContributor
|
// ICompilerFlagContributor
|
||||||
override fun flagsFor(project: Project, context: KobaltContext, currentFlags: List<String>,
|
override fun compilerFlagsFor(project: Project, context: KobaltContext, currentFlags: List<String>,
|
||||||
suffixesBeingCompiled: List<String>): List<String> {
|
suffixesBeingCompiled: List<String>): List<String> {
|
||||||
if (!suffixesBeingCompiled.contains("java")) return emptyList()
|
if (!suffixesBeingCompiled.contains("java")) return emptyList()
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,8 @@ package com.beust.kobalt.plugin.java
|
||||||
import com.beust.kobalt.JavaInfo
|
import com.beust.kobalt.JavaInfo
|
||||||
import com.beust.kobalt.SystemProperties
|
import com.beust.kobalt.SystemProperties
|
||||||
import com.beust.kobalt.TaskResult
|
import com.beust.kobalt.TaskResult
|
||||||
import com.beust.kobalt.api.CompilerActionInfo
|
import com.beust.kobalt.api.*
|
||||||
import com.beust.kobalt.api.ICompiler
|
import com.beust.kobalt.internal.CompilerUtils
|
||||||
import com.beust.kobalt.api.KobaltContext
|
|
||||||
import com.beust.kobalt.api.Project
|
|
||||||
import com.beust.kobalt.internal.ICompilerAction
|
import com.beust.kobalt.internal.ICompilerAction
|
||||||
import com.beust.kobalt.internal.JvmCompiler
|
import com.beust.kobalt.internal.JvmCompiler
|
||||||
import com.beust.kobalt.internal.ParallelLogger
|
import com.beust.kobalt.internal.ParallelLogger
|
||||||
|
@ -22,7 +20,8 @@ import javax.tools.JavaFileObject
|
||||||
import javax.tools.ToolProvider
|
import javax.tools.ToolProvider
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class JavaCompiler @Inject constructor(val jvmCompiler: JvmCompiler, val kobaltLog: ParallelLogger) : ICompiler {
|
class JavaCompiler @Inject constructor(val jvmCompiler: JvmCompiler, val kobaltLog: ParallelLogger,
|
||||||
|
val compilerUtils: CompilerUtils) : ICompiler {
|
||||||
fun compilerAction(executable: File) = object : ICompilerAction {
|
fun compilerAction(executable: File) = object : ICompilerAction {
|
||||||
override fun compile(projectName: String?, info: CompilerActionInfo): TaskResult {
|
override fun compile(projectName: String?, info: CompilerActionInfo): TaskResult {
|
||||||
if (info.sourceFiles.isEmpty()) {
|
if (info.sourceFiles.isEmpty()) {
|
||||||
|
@ -35,11 +34,12 @@ class JavaCompiler @Inject constructor(val jvmCompiler: JvmCompiler, val kobaltL
|
||||||
val compiler = ToolProvider.getSystemJavaCompiler()
|
val compiler = ToolProvider.getSystemJavaCompiler()
|
||||||
fun logk(level: Int, message: CharSequence) = kobaltLog.log(projectName ?: "", level, message)
|
fun logk(level: Int, message: CharSequence) = kobaltLog.log(projectName ?: "", level, message)
|
||||||
val result =
|
val result =
|
||||||
if (compiler != null) {
|
if (false) {
|
||||||
|
// if (compiler != null) {
|
||||||
logk(2, "Found system Java compiler, using the compiler API")
|
logk(2, "Found system Java compiler, using the compiler API")
|
||||||
val allArgs = arrayListOf(
|
val allArgs = arrayListOf(
|
||||||
"-d", KFiles.makeDir(info.directory!!, info.outputDir.path).path)
|
"-d", KFiles.makeDir(info.directory!!, info.outputDir.path).path)
|
||||||
if (info.dependencies.size > 0) {
|
if (info.dependencies.isNotEmpty()) {
|
||||||
allArgs.add("-classpath")
|
allArgs.add("-classpath")
|
||||||
allArgs.add(info.dependencies.map { it.jarFile.get() }.joinToString(File.pathSeparator))
|
allArgs.add(info.dependencies.map { it.jarFile.get() }.joinToString(File.pathSeparator))
|
||||||
}
|
}
|
||||||
|
@ -63,12 +63,12 @@ class JavaCompiler @Inject constructor(val jvmCompiler: JvmCompiler, val kobaltL
|
||||||
errorMessage = dc.diagnostics.joinToString("\n")
|
errorMessage = dc.diagnostics.joinToString("\n")
|
||||||
result
|
result
|
||||||
} else {
|
} else {
|
||||||
logk(2, "Didn't find system Java compiler, forking javac")
|
logk(2, "Forking $executable")
|
||||||
val allArgs = arrayListOf(
|
val allArgs = arrayListOf(
|
||||||
executable.absolutePath,
|
executable.absolutePath,
|
||||||
"-d", KFiles.makeDir(info.directory!!, info.outputDir.path).path)
|
"-d", KFiles.makeDir(info.directory!!, info.outputDir.path).path)
|
||||||
|
|
||||||
if (info.dependencies.size > 0) {
|
if (info.dependencies.isNotEmpty()) {
|
||||||
allArgs.add("-classpath")
|
allArgs.add("-classpath")
|
||||||
allArgs.add(info.dependencies.map { it.jarFile.get() }.joinToString(File.pathSeparator))
|
allArgs.add(info.dependencies.map { it.jarFile.get() }.joinToString(File.pathSeparator))
|
||||||
}
|
}
|
||||||
|
@ -103,13 +103,30 @@ class JavaCompiler @Inject constructor(val jvmCompiler: JvmCompiler, val kobaltL
|
||||||
/**
|
/**
|
||||||
* Invoke the given executable on the CompilerActionInfo.
|
* Invoke the given executable on the CompilerActionInfo.
|
||||||
*/
|
*/
|
||||||
private fun run(project: Project?, context: KobaltContext?, cai: CompilerActionInfo, executable: File): TaskResult {
|
private fun run(project: Project?, context: KobaltContext?, cai: CompilerActionInfo, executable: File,
|
||||||
return jvmCompiler.doCompile(project, context, compilerAction(executable), cai)
|
flags: List<String>): TaskResult {
|
||||||
|
return jvmCompiler.doCompile(project, context, compilerAction(executable), cai, flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun compile(project: Project, context: KobaltContext, info: CompilerActionInfo) : TaskResult
|
override fun compile(project: Project, context: KobaltContext, info: CompilerActionInfo) : TaskResult {
|
||||||
= run(project, context, info, JavaInfo.create(File(SystemProperties.javaBase)).javacExecutable!!)
|
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 run(project, context, info, JavaInfo.create(File(SystemProperties.javaBase)).javacExecutable!!,
|
||||||
|
compilerUtils.compilerFlags(project, context, info, adapters))
|
||||||
|
}
|
||||||
|
|
||||||
fun javadoc(project: Project?, context: KobaltContext?, cai: CompilerActionInfo) : TaskResult
|
fun javadoc(project: Project?, context: KobaltContext, info: CompilerActionInfo) : TaskResult {
|
||||||
= run(project, context, cai, JavaInfo.create(File(SystemProperties.javaBase)).javadocExecutable!!)
|
val adapters = context.pluginInfo.docFlagContributors.map {
|
||||||
|
val closure = { project: Project, context: KobaltContext, currentFlags: List<String>,
|
||||||
|
suffixesBeingCompiled: List<String>
|
||||||
|
-> it.docFlagsFor(project, context, currentFlags, suffixesBeingCompiled) }
|
||||||
|
FlagContributor(it.flagPriority, closure)
|
||||||
|
}
|
||||||
|
return run(project, context, info, JavaInfo.create(File(SystemProperties.javaBase)).javadocExecutable!!,
|
||||||
|
compilerUtils.compilerFlags(project, context, info, adapters))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ import javax.inject.Singleton
|
||||||
@Singleton
|
@Singleton
|
||||||
class JavaPlugin @Inject constructor(val javaCompiler: JavaCompiler, override val configActor: ConfigActor<JavaConfig>)
|
class JavaPlugin @Inject constructor(val javaCompiler: JavaCompiler, override val configActor: ConfigActor<JavaConfig>)
|
||||||
: BaseJvmPlugin<JavaConfig>(configActor), IDocContributor, ICompilerContributor,
|
: BaseJvmPlugin<JavaConfig>(configActor), IDocContributor, ICompilerContributor,
|
||||||
ITestSourceDirectoryContributor, IBuildConfigContributor {
|
ITestSourceDirectoryContributor, IBuildConfigContributor, IDocFlagContributor {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val PLUGIN_NAME = "Java"
|
val PLUGIN_NAME = "Java"
|
||||||
|
@ -24,14 +24,13 @@ class JavaPlugin @Inject constructor(val javaCompiler: JavaCompiler, override va
|
||||||
override val name = PLUGIN_NAME
|
override val name = PLUGIN_NAME
|
||||||
|
|
||||||
// IDocContributor
|
// IDocContributor
|
||||||
override fun affinity(project: Project, context: KobaltContext) =
|
override fun affinity(project: Project, context: KobaltContext) = sourceFileCount(project)
|
||||||
if (accept(project)) 1 else 0
|
|
||||||
|
|
||||||
override fun sourceSuffixes() = SOURCE_SUFFIXES
|
override fun sourceSuffixes() = SOURCE_SUFFIXES
|
||||||
|
|
||||||
override fun generateDoc(project: Project, context: KobaltContext, info: CompilerActionInfo) : TaskResult {
|
override fun generateDoc(project: Project, context: KobaltContext, info: CompilerActionInfo) : TaskResult {
|
||||||
val result =
|
val result =
|
||||||
if (info.sourceFiles.size > 0) {
|
if (info.sourceFiles.isNotEmpty()) {
|
||||||
javaCompiler.javadoc(project, context, info)
|
javaCompiler.javadoc(project, context, info)
|
||||||
} else {
|
} else {
|
||||||
warn("Couldn't find any source files to run Javadoc on")
|
warn("Couldn't find any source files to run Javadoc on")
|
||||||
|
@ -41,15 +40,22 @@ class JavaPlugin @Inject constructor(val javaCompiler: JavaCompiler, override va
|
||||||
}
|
}
|
||||||
|
|
||||||
// ICompilerFlagsContributor
|
// ICompilerFlagsContributor
|
||||||
override fun flagsFor(project: Project, context: KobaltContext, currentFlags: List<String>,
|
override fun compilerFlagsFor(project: Project, context: KobaltContext, currentFlags: List<String>,
|
||||||
suffixesBeingCompiled: List<String>) =
|
suffixesBeingCompiled: List<String>) =
|
||||||
maybeCompilerArgs(compiler.sourceSuffixes, suffixesBeingCompiled,
|
maybeCompilerArgs(compiler.sourceSuffixes, suffixesBeingCompiled,
|
||||||
configurationFor(project)?.compilerArgs ?: listOf<String>())
|
configurationFor(project)?.compilerArgs ?: listOf<String>())
|
||||||
|
|
||||||
|
// IDocFlagContributor
|
||||||
|
override fun docFlagsFor(project: Project, context: KobaltContext, currentFlags: List<String>,
|
||||||
|
suffixesBeingCompiled: List<String>): List<String> {
|
||||||
|
return listOf("-d", "javadoc", "-Xdoclint:none", "-Xmaxerrs", "1", "-quiet")
|
||||||
|
}
|
||||||
|
|
||||||
// ICompilerContributor
|
// ICompilerContributor
|
||||||
val compiler = CompilerDescription(PLUGIN_NAME, "java", SOURCE_SUFFIXES, javaCompiler)
|
val compiler = CompilerDescription(PLUGIN_NAME, "java", SOURCE_SUFFIXES, javaCompiler)
|
||||||
|
|
||||||
override fun compilersFor(project: Project, context: KobaltContext) = listOf(compiler)
|
override fun compilersFor(project: Project, context: KobaltContext)
|
||||||
|
= if (sourceFileCount(project) > 0) listOf(compiler) else emptyList()
|
||||||
|
|
||||||
// ITestSourceDirectoryContributor
|
// ITestSourceDirectoryContributor
|
||||||
override fun testSourceDirectoriesFor(project: Project, context: KobaltContext)
|
override fun testSourceDirectoriesFor(project: Project, context: KobaltContext)
|
||||||
|
|
|
@ -31,7 +31,7 @@ class KotlinCompiler @Inject constructor(
|
||||||
val executors: KobaltExecutors,
|
val executors: KobaltExecutors,
|
||||||
val settings: KobaltSettings,
|
val settings: KobaltSettings,
|
||||||
val jvmCompiler: JvmCompiler,
|
val jvmCompiler: JvmCompiler,
|
||||||
val kotlinJarFiles: KotlinJarFiles,
|
val compilerUtils: CompilerUtils,
|
||||||
val kobaltLog: ParallelLogger) {
|
val kobaltLog: ParallelLogger) {
|
||||||
|
|
||||||
val compilerAction = object: ICompilerAction {
|
val compilerAction = object: ICompilerAction {
|
||||||
|
@ -93,6 +93,10 @@ class KotlinCompiler @Inject constructor(
|
||||||
+ " -classpath " + args.classpath
|
+ " -classpath " + args.classpath
|
||||||
+ " " + sourceFiles.joinToString(" "))
|
+ " " + sourceFiles.joinToString(" "))
|
||||||
val collector = object : MessageCollector {
|
val collector = object : MessageCollector {
|
||||||
|
override fun clear() {
|
||||||
|
throw UnsupportedOperationException("not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
override fun hasErrors(): Boolean {
|
override fun hasErrors(): Boolean {
|
||||||
throw UnsupportedOperationException("not implemented")
|
throw UnsupportedOperationException("not implemented")
|
||||||
}
|
}
|
||||||
|
@ -214,7 +218,8 @@ class KotlinCompiler @Inject constructor(
|
||||||
val info = CompilerActionInfo(project?.directory, dependencies, sourceFiles, listOf("kt"), outputDir, args,
|
val info = CompilerActionInfo(project?.directory, dependencies, sourceFiles, listOf("kt"), outputDir, args,
|
||||||
friendPaths)
|
friendPaths)
|
||||||
|
|
||||||
return jvmCompiler.doCompile(project, context, compilerAction, info)
|
return jvmCompiler.doCompile(project, context, compilerAction, info,
|
||||||
|
if (context != null) compilerUtils.sourceCompilerFlags(project, context, info) else emptyList())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,10 +40,11 @@ class KotlinPlugin @Inject constructor(val executors: KobaltExecutors, val depen
|
||||||
}
|
}
|
||||||
|
|
||||||
// ICompilerFlagsContributor
|
// ICompilerFlagsContributor
|
||||||
override fun flagsFor(project: Project, context: KobaltContext, currentFlags: List<String>,
|
override fun compilerFlagsFor(project: Project, context: KobaltContext, currentFlags: List<String>,
|
||||||
suffixesBeingCompiled: List<String>) : List<String> {
|
suffixesBeingCompiled: List<String>) : List<String> {
|
||||||
val args = (configurationFor(project)?.compilerArgs ?: listOf<String>()) + "-no-stdlib"
|
val args = (configurationFor(project)?.compilerArgs ?: listOf<String>()) + "-no-stdlib"
|
||||||
return maybeCompilerArgs(compiler.sourceSuffixes, suffixesBeingCompiled, args)
|
val result = maybeCompilerArgs(compiler.sourceSuffixes, suffixesBeingCompiled, args)
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
// override fun generateDoc(project: Project, context: KobaltContext, info: CompilerActionInfo) : TaskResult {
|
// override fun generateDoc(project: Project, context: KobaltContext, info: CompilerActionInfo) : TaskResult {
|
||||||
|
@ -113,7 +114,8 @@ class KotlinPlugin @Inject constructor(val executors: KobaltExecutors, val depen
|
||||||
val compiler = CompilerDescription(PLUGIN_NAME, "kotlin", SOURCE_SUFFIXES, KotlinCompiler(),
|
val compiler = CompilerDescription(PLUGIN_NAME, "kotlin", SOURCE_SUFFIXES, KotlinCompiler(),
|
||||||
ICompilerDescription.DEFAULT_PRIORITY - 5, canCompileDirectories = false)
|
ICompilerDescription.DEFAULT_PRIORITY - 5, canCompileDirectories = false)
|
||||||
|
|
||||||
override fun compilersFor(project: Project, context: KobaltContext) = arrayListOf(compiler)
|
override fun compilersFor(project: Project, context: KobaltContext)
|
||||||
|
= if (sourceFileCount(project) > 0) listOf(compiler) else emptyList()
|
||||||
|
|
||||||
// private val dokkaConfigurations = ArrayListMultimap.create<String, DokkaConfig>()
|
// private val dokkaConfigurations = ArrayListMultimap.create<String, DokkaConfig>()
|
||||||
//
|
//
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue