Providing plugin classpath through JPS extensions

Original commit: af9c5cc45d
This commit is contained in:
Yan Zhulanow
2014-10-17 19:52:39 +04:00
parent 6aa4a3c16a
commit fb8ca13e71
2 changed files with 13 additions and 3 deletions
@@ -22,4 +22,5 @@ import org.jetbrains.jps.incremental.CompileContext
public trait KotlinJpsCompilerArgumentsProvider {
public fun getExtraArguments(moduleBuildTarget: ModuleBuildTarget, context: CompileContext): List<String>
public fun getClasspath(moduleBuildTarget: ModuleBuildTarget, context: CompileContext): List<String>
}
@@ -142,11 +142,20 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
val representativeTarget = chunk.representativeTarget()
fun concatenate(strings: Array<String>?, cp: List<String>) = array(*(strings ?: array<String>()), *cp.copyToArray())
for (argumentProvider in ServiceLoader.load(javaClass<KotlinJpsCompilerArgumentsProvider>())) {
// appending to pluginOptions
commonArguments.pluginOptions = array(
*(commonArguments.pluginOptions ?: array<String>()),
*argumentProvider.getExtraArguments(representativeTarget, context).copyToArray()
commonArguments.pluginOptions = concatenate(commonArguments.pluginOptions,
argumentProvider.getExtraArguments(representativeTarget, context))
// appending to classpath
commonArguments.pluginClasspaths = concatenate(commonArguments.pluginClasspaths,
argumentProvider.getClasspath(representativeTarget, context))
messageCollector.report(
INFO,
"Plugin loaded: ${argumentProvider.javaClass.getSimpleName()}",
NO_LOCATION
)
}