Compiler plugins can provide extra command line parameters in JPS

This commit is contained in:
Andrey Breslav
2014-09-23 18:20:50 +04:00
committed by Yan Zhulanow
parent d961e2f5b4
commit febfdde89e
2 changed files with 36 additions and 13 deletions
@@ -0,0 +1,25 @@
/*
* Copyright 2010-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.jps.build
import org.jetbrains.jet.cli.common.arguments.CommonCompilerArguments
import org.jetbrains.jps.incremental.ModuleBuildTarget
import org.jetbrains.jps.incremental.CompileContext
public trait KotlinJpsCompilerArgumentsProvider {
public fun getExtraArguments(moduleBuildTarget: ModuleBuildTarget, context: CompileContext): List<String>
}
@@ -40,6 +40,7 @@ import org.jetbrains.jps.incremental.java.JavaBuilder
import org.jetbrains.jps.incremental.messages.BuildMessage
import org.jetbrains.jps.incremental.messages.CompilerMessage
import java.io.File
import java.lang.reflect.Modifier
import java.util.*
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation.NO_LOCATION
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.*
@@ -139,6 +140,16 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
}
}
val representativeTarget = chunk.representativeTarget()
for (argumentProvider in ServiceLoader.load(javaClass<KotlinJpsCompilerArgumentsProvider>())) {
// appending to pluginOptions
commonArguments.pluginOptions = array(
*(commonArguments.pluginOptions ?: array<String>()),
*argumentProvider.getExtraArguments(representativeTarget, context).copyToArray()
)
}
compileToJvm(allCompiledFiles, chunk, commonArguments, context, dirtyFilesHolder, environment, filesToCompile, messageCollector)
}
@@ -433,19 +444,6 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
return outputItemCollector
}
private fun getAndroidResPath(module: JpsModule, context: CompileContext): String {
val extension = AndroidJpsUtil.getExtension(module)
if (extension == null) return ""
val path = AndroidJpsUtil.getResourceDirForCompilationPath(extension)
return File(path!!.getAbsolutePath() + "/layout").getAbsolutePath()
}
private fun getAndroidManifest(module: JpsModule): String {
val extension = AndroidJpsUtil.getExtension(module)
if (extension == null) return ""
return AndroidJpsUtil.getManifestFileForCompilationPath(extension)!!.getAbsolutePath()
}
public class MessageCollectorAdapter(private val context: CompileContext) : MessageCollector {
override fun report(severity: CompilerMessageSeverity, message: String, location: CompilerMessageLocation) {