diff --git a/jps-plugin/src/org/jetbrains/jet/jps/build/KotlinJpsCompilerArgumentsProvider.kt b/jps-plugin/src/org/jetbrains/jet/jps/build/KotlinJpsCompilerArgumentsProvider.kt new file mode 100644 index 00000000000..065b2644b37 --- /dev/null +++ b/jps-plugin/src/org/jetbrains/jet/jps/build/KotlinJpsCompilerArgumentsProvider.kt @@ -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 +} \ No newline at end of file diff --git a/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt b/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt index a50171c021a..72b007a0d10 100644 --- a/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt +++ b/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt @@ -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())) { + // appending to pluginOptions + commonArguments.pluginOptions = array( + *(commonArguments.pluginOptions ?: array()), + *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) {