mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Fix ICompilerFlagContributor.
This commit is contained in:
parent
7e574951b2
commit
8a850c22ce
4 changed files with 33 additions and 8 deletions
|
@ -3,7 +3,7 @@ package com.beust.kobalt.api
|
|||
/**
|
||||
* Plug-ins can alter the build directory by implementing this interface.
|
||||
*/
|
||||
interface IBuildDirectoryIncerceptor : IPluginActor {
|
||||
interface IBuildDirectoryIncerceptor : IInterceptor {
|
||||
fun intercept(project: Project, context: KobaltContext, buildDirectory: String) : String
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import java.io.File
|
|||
/**
|
||||
* Plug-ins can alter the source directories by implementing this interface.
|
||||
*/
|
||||
interface ISourceDirectoriesIncerceptor : IPluginActor {
|
||||
interface ISourceDirectoryIncerceptor : IInterceptor {
|
||||
fun intercept(project: Project, context: KobaltContext, sourceDirectories: List<File>) : List<File>
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ class PluginInfo(val xml: KobaltPluginXml, val classLoader: ClassLoader?) {
|
|||
val repoContributors = arrayListOf<IRepoContributor>()
|
||||
val compilerFlagContributors = arrayListOf<ICompilerFlagContributor>()
|
||||
val compilerInterceptors = arrayListOf<ICompilerInterceptor>()
|
||||
val sourceDirectoriesInterceptors = arrayListOf<ISourceDirectoriesIncerceptor>()
|
||||
val sourceDirectoriesInterceptors = arrayListOf<ISourceDirectoryIncerceptor>()
|
||||
val buildDirectoryInterceptors = arrayListOf<IBuildDirectoryIncerceptor>()
|
||||
val runnerContributors = arrayListOf<IRunnerContributor>()
|
||||
val testRunnerContributors = arrayListOf<ITestRunnerContributor>()
|
||||
|
@ -128,9 +128,10 @@ class PluginInfo(val xml: KobaltPluginXml, val classLoader: ClassLoader?) {
|
|||
if (this is IProjectContributor) projectContributors.add(this)
|
||||
if (this is IInitContributor<*>) initContributors.add(this as IInitContributor<File>)
|
||||
if (this is IRepoContributor) repoContributors.add(this)
|
||||
if (this is ICompilerFlagContributor) compilerFlagContributors.add(this)
|
||||
if (this is ICompilerContributor) compilerContributors.add(this)
|
||||
if (this is ICompilerInterceptor) compilerInterceptors.add(this)
|
||||
if (this is ISourceDirectoriesIncerceptor) sourceDirectoriesInterceptors.add(this)
|
||||
if (this is ISourceDirectoryIncerceptor) sourceDirectoriesInterceptors.add(this)
|
||||
if (this is IBuildDirectoryIncerceptor) buildDirectoryInterceptors.add(this)
|
||||
if (this is IRunnerContributor) runnerContributors.add(this)
|
||||
if (this is ITestRunnerContributor) testRunnerContributors.add(this)
|
||||
|
@ -154,6 +155,7 @@ class PluginInfo(val xml: KobaltPluginXml, val classLoader: ClassLoader?) {
|
|||
projectContributors.addAll(pluginInfo.projectContributors)
|
||||
initContributors.addAll(pluginInfo.initContributors)
|
||||
repoContributors.addAll(pluginInfo.repoContributors)
|
||||
compilerFlagContributors.addAll(pluginInfo.compilerFlagContributors)
|
||||
compilerInterceptors.addAll(pluginInfo.compilerInterceptors)
|
||||
sourceDirectoriesInterceptors.addAll(pluginInfo.sourceDirectoriesInterceptors)
|
||||
buildDirectoryInterceptors.addAll(pluginInfo.buildDirectoryInterceptors)
|
||||
|
|
|
@ -206,13 +206,36 @@ public class AndroidPlugin @Inject constructor(val javaCompiler: JavaCompiler, v
|
|||
override fun flagsFor(project: Project, currentFlags: List<String>) : List<String> {
|
||||
if (isAndroid(project)) {
|
||||
val result = arrayListOf<String>()
|
||||
var foundSource = false
|
||||
var foundTarget = false
|
||||
var noWarn = false
|
||||
if (! currentFlags.contains("-source")) with(result) {
|
||||
addAll(listOf("-source", "1.6"))
|
||||
var i = 0
|
||||
while (i < currentFlags.size) {
|
||||
with(currentFlags[i]) {
|
||||
if (this == "-source") {
|
||||
result.add(this)
|
||||
result.add(currentFlags[i + 1])
|
||||
i++
|
||||
foundSource = true
|
||||
} else if (this == "-target") {
|
||||
result.add(this)
|
||||
result.add(currentFlags[i + 1])
|
||||
i++
|
||||
foundTarget = true
|
||||
} else {
|
||||
result.add(this)
|
||||
}
|
||||
}
|
||||
i++
|
||||
}
|
||||
if (! foundSource) {
|
||||
result.add("-source")
|
||||
result.add("1.6")
|
||||
noWarn = true
|
||||
}
|
||||
if (!currentFlags.contains("-target")) with(result) {
|
||||
addAll(listOf("-target", "1.6"))
|
||||
if (! foundTarget) {
|
||||
result.add("-target")
|
||||
result.add("1.6")
|
||||
noWarn = true
|
||||
}
|
||||
if (noWarn) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue