From 5609bb27aa4852d50dcd0c92a8ca6ee4d0d19348 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Wed, 4 Jan 2017 15:19:34 -0800 Subject: [PATCH] Fix Javadoc generation. --- kobalt/src/Build.kt | 4 +- .../kobalt/api/ICompilerFlagContributor.kt | 26 +++++++--- .../beust/kobalt/internal/BaseJvmPlugin.kt | 10 ++-- .../beust/kobalt/internal/CompilerUtils.kt | 21 +++++++++ .../com/beust/kobalt/internal/JvmCompiler.kt | 16 ++----- .../kobalt/internal/JvmCompilerPlugin.kt | 3 +- .../beust/kobalt/internal/KobaltPluginXml.kt | 9 ++-- .../com/beust/kobalt/internal/TaskManager.kt | 1 + .../com/beust/kobalt/plugin/apt/AptPlugin.kt | 2 +- .../beust/kobalt/plugin/java/JavaCompiler.kt | 47 +++++++++++++------ .../beust/kobalt/plugin/java/JavaPlugin.kt | 18 ++++--- .../kobalt/plugin/kotlin/KotlinCompiler.kt | 9 +++- .../kobalt/plugin/kotlin/KotlinPlugin.kt | 8 ++-- 13 files changed, 115 insertions(+), 59 deletions(-) diff --git a/kobalt/src/Build.kt b/kobalt/src/Build.kt index 97d7eec5..72f44550 100644 --- a/kobalt/src/Build.kt +++ b/kobalt/src/Build.kt @@ -143,7 +143,7 @@ val kobaltApp = project(kobaltPluginApi, wrapper) { dependencies { // 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 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:converter-gson:${Versions.retrofit}", "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", "com.squareup.okhttp3:logging-interceptor:3.2.0", diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/ICompilerFlagContributor.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/ICompilerFlagContributor.kt index 5962e9fb..2d8febe4 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/ICompilerFlagContributor.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/ICompilerFlagContributor.kt @@ -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, - suffixesBeingCompiled: List): List - val flagPriority: Int - get() = DEFAULT_FLAG_PRIORITY - +class FlagContributor(val flagPriority: Int = DEFAULT_FLAG_PRIORITY, + val closure: (project: Project, context: KobaltContext, currentFlags: List, + suffixesBeingCompiled: List) -> List) : IContributor { companion object { val DEFAULT_FLAG_PRIORITY = 20 } + + fun flagsFor(project: Project, context: KobaltContext, currentFlags: List, + suffixesBeingCompiled: List) = 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, + suffixesBeingCompiled: List): List +} + +interface IDocFlagContributor : IContributor, IFlagBase { + fun docFlagsFor(project: Project, context: KobaltContext, currentFlags: List, + suffixesBeingCompiled: List): List +} \ No newline at end of file diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/BaseJvmPlugin.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/BaseJvmPlugin.kt index cfece392..f45b4565 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/BaseJvmPlugin.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/BaseJvmPlugin.kt @@ -12,7 +12,7 @@ abstract class BaseJvmPlugin(open val configActor: ConfigActor) : 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, suffixesBeingCompiled: List, @@ -21,14 +21,14 @@ abstract class BaseJvmPlugin(open val configActor: ConfigActor) : 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 } \ No newline at end of file diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/CompilerUtils.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/CompilerUtils.kt index 93b2dd2b..4a2712ab 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/CompilerUtils.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/CompilerUtils.kt @@ -229,4 +229,25 @@ class CompilerUtils @Inject constructor(val files: KFiles, private fun isDependencyExcluded(id: IClasspathDependency, excluded: List) = excluded.any { id.id.startsWith(it.id) } + fun sourceCompilerFlags(project: Project?, context: KobaltContext, info: CompilerActionInfo) : List { + val adapters = context.pluginInfo.compilerFlagContributors.map { + val closure = { project: Project, context: KobaltContext, currentFlags: List, + suffixesBeingCompiled: List + -> 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) : List { + val result = arrayListOf() + if (project != null) { + adapters.sortedBy { it.flagPriority } + adapters.forEach { + result.addAll(it.flagsFor(project, context, result, info.suffixesBeingCompiled)) + } + } + return result + } } diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JvmCompiler.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JvmCompiler.kt index dd612256..23f9f8dc 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JvmCompiler.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JvmCompiler.kt @@ -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): 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().apply { addAll(info.compilerArgs) } - val contributorFlags : List = 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 = if (project != null) flags else emptyList() val addedFlags = contributorFlags + ArrayList(info.compilerArgs) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JvmCompilerPlugin.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JvmCompilerPlugin.kt index 40035a65..455a2785 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JvmCompilerPlugin.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JvmCompilerPlugin.kt @@ -150,8 +150,7 @@ open class JvmCompilerPlugin @Inject constructor( val results = arrayListOf() 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()) { diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/KobaltPluginXml.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/KobaltPluginXml.kt index 154ffcdb..2b36f2e7 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/KobaltPluginXml.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/KobaltPluginXml.kt @@ -98,6 +98,7 @@ class PluginInfo(val xml: KobaltPluginXml, val pluginClassLoader: ClassLoader?, val localMavenRepoPathInterceptors = arrayListOf() val buildListeners = arrayListOf() val buildReportContributors = arrayListOf() + val docFlagContributors = arrayListOf() // 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) } } diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt index 670244dc..2139326c 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt @@ -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 }) diff --git a/src/main/kotlin/com/beust/kobalt/plugin/apt/AptPlugin.kt b/src/main/kotlin/com/beust/kobalt/plugin/apt/AptPlugin.kt index 569a2ec9..666e009d 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/apt/AptPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/apt/AptPlugin.kt @@ -102,7 +102,7 @@ class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, va context.variant.toIntermediateDir()) // ICompilerFlagContributor - override fun flagsFor(project: Project, context: KobaltContext, currentFlags: List, + override fun compilerFlagsFor(project: Project, context: KobaltContext, currentFlags: List, suffixesBeingCompiled: List): List { if (!suffixesBeingCompiled.contains("java")) return emptyList() diff --git a/src/main/kotlin/com/beust/kobalt/plugin/java/JavaCompiler.kt b/src/main/kotlin/com/beust/kobalt/plugin/java/JavaCompiler.kt index 2f43f2c7..00bfab4a 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/java/JavaCompiler.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/java/JavaCompiler.kt @@ -3,10 +3,8 @@ package com.beust.kobalt.plugin.java import com.beust.kobalt.JavaInfo import com.beust.kobalt.SystemProperties import com.beust.kobalt.TaskResult -import com.beust.kobalt.api.CompilerActionInfo -import com.beust.kobalt.api.ICompiler -import com.beust.kobalt.api.KobaltContext -import com.beust.kobalt.api.Project +import com.beust.kobalt.api.* +import com.beust.kobalt.internal.CompilerUtils import com.beust.kobalt.internal.ICompilerAction import com.beust.kobalt.internal.JvmCompiler import com.beust.kobalt.internal.ParallelLogger @@ -22,7 +20,8 @@ import javax.tools.JavaFileObject import javax.tools.ToolProvider @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 { override fun compile(projectName: String?, info: CompilerActionInfo): TaskResult { if (info.sourceFiles.isEmpty()) { @@ -35,11 +34,12 @@ class JavaCompiler @Inject constructor(val jvmCompiler: JvmCompiler, val kobaltL val compiler = ToolProvider.getSystemJavaCompiler() fun logk(level: Int, message: CharSequence) = kobaltLog.log(projectName ?: "", level, message) val result = - if (compiler != null) { + if (false) { +// if (compiler != null) { logk(2, "Found system Java compiler, using the compiler API") val allArgs = arrayListOf( "-d", KFiles.makeDir(info.directory!!, info.outputDir.path).path) - if (info.dependencies.size > 0) { + if (info.dependencies.isNotEmpty()) { allArgs.add("-classpath") 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") result } else { - logk(2, "Didn't find system Java compiler, forking javac") + logk(2, "Forking $executable") val allArgs = arrayListOf( executable.absolutePath, "-d", KFiles.makeDir(info.directory!!, info.outputDir.path).path) - if (info.dependencies.size > 0) { + if (info.dependencies.isNotEmpty()) { allArgs.add("-classpath") 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. */ - private fun run(project: Project?, context: KobaltContext?, cai: CompilerActionInfo, executable: File): TaskResult { - return jvmCompiler.doCompile(project, context, compilerAction(executable), cai) + private fun run(project: Project?, context: KobaltContext?, cai: CompilerActionInfo, executable: File, + flags: List): TaskResult { + return jvmCompiler.doCompile(project, context, compilerAction(executable), cai, flags) } - override fun compile(project: Project, context: KobaltContext, info: CompilerActionInfo) : TaskResult - = run(project, context, info, JavaInfo.create(File(SystemProperties.javaBase)).javacExecutable!!) + override fun compile(project: Project, context: KobaltContext, info: CompilerActionInfo) : TaskResult { + val adapters = context.pluginInfo.compilerFlagContributors.map { + val closure = { project: Project, context: KobaltContext, currentFlags: List, + suffixesBeingCompiled: List + -> 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 - = run(project, context, cai, JavaInfo.create(File(SystemProperties.javaBase)).javadocExecutable!!) + fun javadoc(project: Project?, context: KobaltContext, info: CompilerActionInfo) : TaskResult { + val adapters = context.pluginInfo.docFlagContributors.map { + val closure = { project: Project, context: KobaltContext, currentFlags: List, + suffixesBeingCompiled: List + -> 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)) + } } diff --git a/src/main/kotlin/com/beust/kobalt/plugin/java/JavaPlugin.kt b/src/main/kotlin/com/beust/kobalt/plugin/java/JavaPlugin.kt index b6d2cc79..c10245bc 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/java/JavaPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/java/JavaPlugin.kt @@ -14,7 +14,7 @@ import javax.inject.Singleton @Singleton class JavaPlugin @Inject constructor(val javaCompiler: JavaCompiler, override val configActor: ConfigActor) : BaseJvmPlugin(configActor), IDocContributor, ICompilerContributor, - ITestSourceDirectoryContributor, IBuildConfigContributor { + ITestSourceDirectoryContributor, IBuildConfigContributor, IDocFlagContributor { companion object { val PLUGIN_NAME = "Java" @@ -24,14 +24,13 @@ class JavaPlugin @Inject constructor(val javaCompiler: JavaCompiler, override va override val name = PLUGIN_NAME // IDocContributor - override fun affinity(project: Project, context: KobaltContext) = - if (accept(project)) 1 else 0 + override fun affinity(project: Project, context: KobaltContext) = sourceFileCount(project) override fun sourceSuffixes() = SOURCE_SUFFIXES override fun generateDoc(project: Project, context: KobaltContext, info: CompilerActionInfo) : TaskResult { val result = - if (info.sourceFiles.size > 0) { + if (info.sourceFiles.isNotEmpty()) { javaCompiler.javadoc(project, context, info) } else { 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 - override fun flagsFor(project: Project, context: KobaltContext, currentFlags: List, + override fun compilerFlagsFor(project: Project, context: KobaltContext, currentFlags: List, suffixesBeingCompiled: List) = maybeCompilerArgs(compiler.sourceSuffixes, suffixesBeingCompiled, configurationFor(project)?.compilerArgs ?: listOf()) + // IDocFlagContributor + override fun docFlagsFor(project: Project, context: KobaltContext, currentFlags: List, + suffixesBeingCompiled: List): List { + return listOf("-d", "javadoc", "-Xdoclint:none", "-Xmaxerrs", "1", "-quiet") + } + // ICompilerContributor 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 override fun testSourceDirectoriesFor(project: Project, context: KobaltContext) diff --git a/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt b/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt index 67c9a3c7..3e7527bd 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt @@ -31,7 +31,7 @@ class KotlinCompiler @Inject constructor( val executors: KobaltExecutors, val settings: KobaltSettings, val jvmCompiler: JvmCompiler, - val kotlinJarFiles: KotlinJarFiles, + val compilerUtils: CompilerUtils, val kobaltLog: ParallelLogger) { val compilerAction = object: ICompilerAction { @@ -93,6 +93,10 @@ class KotlinCompiler @Inject constructor( + " -classpath " + args.classpath + " " + sourceFiles.joinToString(" ")) val collector = object : MessageCollector { + override fun clear() { + throw UnsupportedOperationException("not implemented") + } + override fun hasErrors(): Boolean { throw UnsupportedOperationException("not implemented") } @@ -214,7 +218,8 @@ class KotlinCompiler @Inject constructor( val info = CompilerActionInfo(project?.directory, dependencies, sourceFiles, listOf("kt"), outputDir, args, 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()) } } diff --git a/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinPlugin.kt b/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinPlugin.kt index 40860bc2..1ac3e828 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinPlugin.kt @@ -40,10 +40,11 @@ class KotlinPlugin @Inject constructor(val executors: KobaltExecutors, val depen } // ICompilerFlagsContributor - override fun flagsFor(project: Project, context: KobaltContext, currentFlags: List, + override fun compilerFlagsFor(project: Project, context: KobaltContext, currentFlags: List, suffixesBeingCompiled: List) : List { val args = (configurationFor(project)?.compilerArgs ?: listOf()) + "-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 { @@ -113,7 +114,8 @@ class KotlinPlugin @Inject constructor(val executors: KobaltExecutors, val depen val compiler = CompilerDescription(PLUGIN_NAME, "kotlin", SOURCE_SUFFIXES, KotlinCompiler(), 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() //