mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Fix the compiler bug.
This commit is contained in:
parent
eb575abc14
commit
b62e167cde
3 changed files with 13 additions and 5 deletions
|
@ -26,7 +26,9 @@ abstract class BaseJvmPlugin<T>(open val configActor: ConfigActor<T>) :
|
|||
// IBuildConfigContributor
|
||||
|
||||
private fun hasSourceFiles(project: Project)
|
||||
= KFiles.findSourceFiles(project.directory, project.sourceDirectories, listOf("java")).size > 0
|
||||
= KFiles.findSourceFiles(project.directory, project.sourceDirectories, sourceSuffixes()).size > 0
|
||||
|
||||
fun affinity(project: Project) = if (hasSourceFiles(project)) 1 else 0
|
||||
|
||||
abstract fun sourceSuffixes() : List<String>
|
||||
}
|
|
@ -17,7 +17,8 @@ class JavaPlugin @Inject constructor(val javaCompiler: JavaCompiler, override va
|
|||
ITestSourceDirectoryContributor, IBuildConfigContributor {
|
||||
|
||||
companion object {
|
||||
const val PLUGIN_NAME = "Java"
|
||||
val PLUGIN_NAME = "Java"
|
||||
val SOURCE_SUFFIXES = listOf("java")
|
||||
}
|
||||
|
||||
override val name = PLUGIN_NAME
|
||||
|
@ -26,6 +27,8 @@ class JavaPlugin @Inject constructor(val javaCompiler: JavaCompiler, override va
|
|||
override fun affinity(project: Project, context: KobaltContext) =
|
||||
if (accept(project)) 1 else 0
|
||||
|
||||
override fun sourceSuffixes() = SOURCE_SUFFIXES
|
||||
|
||||
override fun generateDoc(project: Project, context: KobaltContext, info: CompilerActionInfo) : TaskResult {
|
||||
val result =
|
||||
if (info.sourceFiles.size > 0) {
|
||||
|
@ -44,7 +47,7 @@ class JavaPlugin @Inject constructor(val javaCompiler: JavaCompiler, override va
|
|||
configurationFor(project)?.compilerArgs ?: listOf<String>())
|
||||
|
||||
// ICompilerContributor
|
||||
val compiler = CompilerDescription(listOf("java"), "java", javaCompiler)
|
||||
val compiler = CompilerDescription(SOURCE_SUFFIXES, "java", javaCompiler)
|
||||
|
||||
override fun compilersFor(project: Project, context: KobaltContext) = listOf(compiler)
|
||||
|
||||
|
|
|
@ -24,11 +24,14 @@ class KotlinPlugin @Inject constructor(val executors: KobaltExecutors, val depen
|
|||
IBuildConfigContributor {
|
||||
|
||||
companion object {
|
||||
const val PLUGIN_NAME = "Kotlin"
|
||||
val PLUGIN_NAME = "Kotlin"
|
||||
val SOURCE_SUFFIXES = listOf("kt")
|
||||
}
|
||||
|
||||
override val name = PLUGIN_NAME
|
||||
|
||||
override fun sourceSuffixes() = SOURCE_SUFFIXES
|
||||
|
||||
// IDocContributor
|
||||
override fun affinity(project: Project, context: KobaltContext) =
|
||||
if (project.sourceDirectories.any { it.contains("kotlin") }) 2 else 0
|
||||
|
@ -108,7 +111,7 @@ class KotlinPlugin @Inject constructor(val executors: KobaltExecutors, val depen
|
|||
// ICompilerContributor
|
||||
|
||||
/** The Kotlin compiler should run before the Java one, hence priority - 5 */
|
||||
val compiler = CompilerDescription(listOf("kt"), "kotlin", KotlinCompiler(),
|
||||
val compiler = CompilerDescription(SOURCE_SUFFIXES, "kotlin", KotlinCompiler(),
|
||||
ICompilerDescription.DEFAULT_PRIORITY - 5)
|
||||
|
||||
override fun compilersFor(project: Project, context: KobaltContext) = arrayListOf(compiler)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue