Stop using -Xbuild-file in Gradle Plugin

#KT-27640 fixed
    #KT-27778 fixed
    #KT-27638 fixed
This commit is contained in:
Alexey Tsvetkov
2018-11-02 05:08:48 +03:00
parent 9b5b0447fa
commit 5f54f67f70
12 changed files with 94 additions and 101 deletions
@@ -191,6 +191,20 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
)
var javacArguments: Array<String>? by FreezableVar(null)
@Argument(
value = "-Xjava-source-roots",
valueDescription = "<path>",
description = "Paths to output directories for friend modules (whose internals should be visible)"
)
var javaSourceRoots: Array<String>? by FreezableVar(null)
@Argument(
value = "-Xjava-package-prefix",
description = "Package prefix for Java files"
)
var javaPackagePrefix: String? by FreezableVar(null)
@Argument(
value = "-Xjsr305",
deprecatedName = "-Xjsr305-annotations",
@@ -85,6 +85,10 @@ class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
}
}
}
for (path in arguments.javaSourceRoots ?: emptyArray()) {
configuration.addJavaSourceRoot(File(path), arguments.javaPackagePrefix)
}
}
configuration.put(CommonConfigurationKeys.MODULE_NAME, arguments.moduleName ?: JvmAbi.DEFAULT_MODULE_NAME)
@@ -108,11 +112,17 @@ class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
val destination = arguments.destination
if (arguments.buildFile != null) {
fun strongWarning(message: String) {
messageCollector.report(STRONG_WARNING, message)
}
if (destination != null) {
messageCollector.report(
STRONG_WARNING,
"The '-d' option with a directory destination is ignored because '-Xbuild-file' is specified"
)
strongWarning("The '-d' option with a directory destination is ignored because '-Xbuild-file' is specified")
}
if (arguments.javaSourceRoots != null) {
strongWarning("The '-Xjava-source-roots' option is ignored because '-Xbuild-file' is specified")
}
if (arguments.javaPackagePrefix != null) {
strongWarning("The '-Xjava-package-prefix' option is ignored because '-Xbuild-file' is specified")
}
val sanitizedCollector = FilteringMessageCollector(messageCollector, VERBOSE::contains)
@@ -420,9 +420,11 @@ object KotlinToJVMBytecodeCompiler {
private fun GenerationState.Builder.withModule(module: Module?) =
apply {
targetId(module?.let { TargetId(it) })
moduleName(module?.getModuleName())
outDirectory(module?.let { File(it.getOutputDirectory()) })
if (module != null) {
targetId(TargetId(module))
moduleName(module.getModuleName())
outDirectory(File(module.getOutputDirectory()))
}
}
private fun generate(