Stop using -Xbuild-file in Gradle Plugin
#KT-27640 fixed
#KT-27778 fixed
#KT-27638 fixed
This commit is contained in:
@@ -149,8 +149,12 @@ class GenerationState private constructor(
|
|||||||
init {
|
init {
|
||||||
val icComponents = configuration.get(JVMConfigurationKeys.INCREMENTAL_COMPILATION_COMPONENTS)
|
val icComponents = configuration.get(JVMConfigurationKeys.INCREMENTAL_COMPILATION_COMPONENTS)
|
||||||
if (icComponents != null) {
|
if (icComponents != null) {
|
||||||
incrementalCacheForThisTarget =
|
val targetId = targetId
|
||||||
icComponents.getIncrementalCache(targetId ?: error("Target ID should be specified for incremental compilation"))
|
?: moduleName?.let {
|
||||||
|
// hack for Gradle IC, Gradle does not use build.xml file, so there is no way to pass target id
|
||||||
|
TargetId(it, "java-production")
|
||||||
|
} ?: error("Target ID should be specified for incremental compilation")
|
||||||
|
incrementalCacheForThisTarget = icComponents.getIncrementalCache(targetId)
|
||||||
packagesWithObsoleteParts = incrementalCacheForThisTarget.getObsoletePackageParts().map {
|
packagesWithObsoleteParts = incrementalCacheForThisTarget.getObsoletePackageParts().map {
|
||||||
JvmClassName.byInternalName(it).packageFqName
|
JvmClassName.byInternalName(it).packageFqName
|
||||||
}.toSet()
|
}.toSet()
|
||||||
|
|||||||
+14
@@ -191,6 +191,20 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
|
|||||||
)
|
)
|
||||||
var javacArguments: Array<String>? by FreezableVar(null)
|
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(
|
@Argument(
|
||||||
value = "-Xjsr305",
|
value = "-Xjsr305",
|
||||||
deprecatedName = "-Xjsr305-annotations",
|
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)
|
configuration.put(CommonConfigurationKeys.MODULE_NAME, arguments.moduleName ?: JvmAbi.DEFAULT_MODULE_NAME)
|
||||||
@@ -108,11 +112,17 @@ class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
|
|||||||
val destination = arguments.destination
|
val destination = arguments.destination
|
||||||
|
|
||||||
if (arguments.buildFile != null) {
|
if (arguments.buildFile != null) {
|
||||||
|
fun strongWarning(message: String) {
|
||||||
|
messageCollector.report(STRONG_WARNING, message)
|
||||||
|
}
|
||||||
if (destination != null) {
|
if (destination != null) {
|
||||||
messageCollector.report(
|
strongWarning("The '-d' option with a directory destination is ignored because '-Xbuild-file' is specified")
|
||||||
STRONG_WARNING,
|
}
|
||||||
"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)
|
val sanitizedCollector = FilteringMessageCollector(messageCollector, VERBOSE::contains)
|
||||||
|
|||||||
+5
-3
@@ -420,9 +420,11 @@ object KotlinToJVMBytecodeCompiler {
|
|||||||
|
|
||||||
private fun GenerationState.Builder.withModule(module: Module?) =
|
private fun GenerationState.Builder.withModule(module: Module?) =
|
||||||
apply {
|
apply {
|
||||||
targetId(module?.let { TargetId(it) })
|
if (module != null) {
|
||||||
moduleName(module?.getModuleName())
|
targetId(TargetId(module))
|
||||||
outDirectory(module?.let { File(it.getOutputDirectory()) })
|
moduleName(module.getModuleName())
|
||||||
|
outDirectory(File(module.getOutputDirectory()))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun generate(
|
private fun generate(
|
||||||
|
|||||||
+13
-3
@@ -28,7 +28,8 @@ open class CompilationOptions(
|
|||||||
/** @See [ReportSeverity] */
|
/** @See [ReportSeverity] */
|
||||||
val reportSeverity: Int,
|
val reportSeverity: Int,
|
||||||
/** @See [CompilationResultCategory]] */
|
/** @See [CompilationResultCategory]] */
|
||||||
val requestedCompilationResults: Array<Int>
|
val requestedCompilationResults: Array<Int>,
|
||||||
|
val kotlinScriptExtensions: Array<String>? = null
|
||||||
) : Serializable {
|
) : Serializable {
|
||||||
companion object {
|
companion object {
|
||||||
const val serialVersionUID: Long = 0
|
const val serialVersionUID: Long = 0
|
||||||
@@ -41,6 +42,7 @@ open class CompilationOptions(
|
|||||||
"reportCategories=${Arrays.toString(reportCategories)}, " +
|
"reportCategories=${Arrays.toString(reportCategories)}, " +
|
||||||
"reportSeverity=$reportSeverity, " +
|
"reportSeverity=$reportSeverity, " +
|
||||||
"requestedCompilationResults=${Arrays.toString(requestedCompilationResults)}" +
|
"requestedCompilationResults=${Arrays.toString(requestedCompilationResults)}" +
|
||||||
|
"kotlinScriptExtensions=${Arrays.toString(kotlinScriptExtensions)}" +
|
||||||
")"
|
")"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -65,8 +67,16 @@ class IncrementalCompilationOptions(
|
|||||||
val outputFiles: List<File>,
|
val outputFiles: List<File>,
|
||||||
val multiModuleICSettings: MultiModuleICSettings,
|
val multiModuleICSettings: MultiModuleICSettings,
|
||||||
val modulesInfo: IncrementalModuleInfo,
|
val modulesInfo: IncrementalModuleInfo,
|
||||||
val classpathFqNamesHistory: File? = null
|
val classpathFqNamesHistory: File? = null,
|
||||||
) : CompilationOptions(compilerMode, targetPlatform, reportCategories, reportSeverity, requestedCompilationResults) {
|
kotlinScriptExtensions: Array<String>? = null
|
||||||
|
) : CompilationOptions(
|
||||||
|
compilerMode,
|
||||||
|
targetPlatform,
|
||||||
|
reportCategories,
|
||||||
|
reportSeverity,
|
||||||
|
requestedCompilationResults,
|
||||||
|
kotlinScriptExtensions
|
||||||
|
) {
|
||||||
companion object {
|
companion object {
|
||||||
const val serialVersionUID: Long = 0
|
const val serialVersionUID: Long = 0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -454,7 +454,7 @@ class CompileServiceImpl(
|
|||||||
doCompile(sessionId, daemonReporter, tracer = null) { _, _ ->
|
doCompile(sessionId, daemonReporter, tracer = null) { _, _ ->
|
||||||
execIncrementalCompiler(
|
execIncrementalCompiler(
|
||||||
k2jvmArgs, gradleIncrementalArgs, gradleIncrementalServicesFacade, compilationResults!!,
|
k2jvmArgs, gradleIncrementalArgs, gradleIncrementalServicesFacade, compilationResults!!,
|
||||||
messageCollector, daemonReporter
|
messageCollector
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -525,44 +525,28 @@ class CompileServiceImpl(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo: non-IC non-KTS scripts?
|
||||||
private fun execIncrementalCompiler(
|
private fun execIncrementalCompiler(
|
||||||
k2jvmArgs: K2JVMCompilerArguments,
|
k2jvmArgs: K2JVMCompilerArguments,
|
||||||
incrementalCompilationOptions: IncrementalCompilationOptions,
|
incrementalCompilationOptions: IncrementalCompilationOptions,
|
||||||
servicesFacade: IncrementalCompilerServicesFacade,
|
servicesFacade: IncrementalCompilerServicesFacade,
|
||||||
compilationResults: CompilationResults,
|
compilationResults: CompilationResults,
|
||||||
compilerMessageCollector: MessageCollector,
|
compilerMessageCollector: MessageCollector
|
||||||
daemonMessageReporter: DaemonMessageReporter
|
|
||||||
): ExitCode {
|
): ExitCode {
|
||||||
val moduleFile = k2jvmArgs.buildFile?.let(::File)
|
val allKotlinExtensions = (DEFAULT_KOTLIN_SOURCE_FILES_EXTENSIONS +
|
||||||
assert(moduleFile?.exists() ?: false) { "Module does not exist ${k2jvmArgs.buildFile}" }
|
(incrementalCompilationOptions.kotlinScriptExtensions ?: emptyArray())).distinct()
|
||||||
|
val dotExtensions = allKotlinExtensions.map { ".$it" }
|
||||||
// todo: pass javaSourceRoots and allKotlinFiles using IncrementalCompilationOptions
|
val freeArgs = arrayListOf<String>()
|
||||||
val parsedModule = run {
|
val allKotlinFiles = arrayListOf<File>()
|
||||||
val bytesOut = ByteArrayOutputStream()
|
for (arg in k2jvmArgs.freeArgs) {
|
||||||
val printStream = PrintStream(bytesOut)
|
val file = File(arg)
|
||||||
val mc = PrintingMessageCollector(printStream, MessageRenderer.PLAIN_FULL_PATHS, false)
|
if (file.isFile && dotExtensions.any { ext -> file.path.endsWith(ext, ignoreCase = true) }) {
|
||||||
val parsedModule = ModuleXmlParser.parseModuleScript(k2jvmArgs.buildFile!!, mc)
|
allKotlinFiles.add(file)
|
||||||
if (mc.hasErrors()) {
|
} else {
|
||||||
daemonMessageReporter.report(ReportSeverity.ERROR, bytesOut.toString("UTF8"))
|
freeArgs.add(arg)
|
||||||
}
|
}
|
||||||
parsedModule
|
|
||||||
}
|
}
|
||||||
|
k2jvmArgs.freeArgs = freeArgs
|
||||||
val javaSourceRoots = parsedModule.modules.flatMapTo(HashSet()) {
|
|
||||||
it.getJavaSourceRoots().map { JvmSourceRoot(File(it.path), it.packagePrefix) }
|
|
||||||
}
|
|
||||||
|
|
||||||
k2jvmArgs.commonSources = parsedModule.modules.flatMap { it.getCommonSourceFiles() }.toTypedArray().takeUnless { it.isEmpty() }
|
|
||||||
|
|
||||||
val allKotlinFiles = parsedModule.modules.flatMap { it.getSourceFiles().map(::File) }
|
|
||||||
val allKotlinExtensions = (
|
|
||||||
DEFAULT_KOTLIN_SOURCE_FILES_EXTENSIONS +
|
|
||||||
allKotlinFiles.asSequence()
|
|
||||||
.map { it.extension }
|
|
||||||
.filter { !it.equals("java", ignoreCase = true) }
|
|
||||||
.asIterable()
|
|
||||||
).distinct()
|
|
||||||
k2jvmArgs.friendPaths = parsedModule.modules.flatMap(Module::getFriendPaths).toTypedArray()
|
|
||||||
|
|
||||||
val changedFiles = if (incrementalCompilationOptions.areFileChangesKnown) {
|
val changedFiles = if (incrementalCompilationOptions.areFileChangesKnown) {
|
||||||
ChangedFiles.Known(incrementalCompilationOptions.modifiedFiles!!, incrementalCompilationOptions.deletedFiles!!)
|
ChangedFiles.Known(incrementalCompilationOptions.modifiedFiles!!, incrementalCompilationOptions.deletedFiles!!)
|
||||||
@@ -588,7 +572,6 @@ class CompileServiceImpl(
|
|||||||
|
|
||||||
val compiler = IncrementalJvmCompilerRunner(
|
val compiler = IncrementalJvmCompilerRunner(
|
||||||
workingDir,
|
workingDir,
|
||||||
javaSourceRoots,
|
|
||||||
reporter,
|
reporter,
|
||||||
buildHistoryFile = incrementalCompilationOptions.multiModuleICSettings.buildHistoryFile,
|
buildHistoryFile = incrementalCompilationOptions.multiModuleICSettings.buildHistoryFile,
|
||||||
outputFiles = outputFiles,
|
outputFiles = outputFiles,
|
||||||
|
|||||||
+6
-24
@@ -62,11 +62,11 @@ fun makeIncrementally(
|
|||||||
val files = rootsWalk.filter(File::isFile)
|
val files = rootsWalk.filter(File::isFile)
|
||||||
val sourceFiles = files.filter { it.extension.toLowerCase() in allExtensions }.toList()
|
val sourceFiles = files.filter { it.extension.toLowerCase() in allExtensions }.toList()
|
||||||
val buildHistoryFile = File(cachesDir, "build-history.bin")
|
val buildHistoryFile = File(cachesDir, "build-history.bin")
|
||||||
|
args.javaSourceRoots = sourceRoots.map { it.absolutePath }.toTypedArray()
|
||||||
|
|
||||||
withIC {
|
withIC {
|
||||||
val compiler = IncrementalJvmCompilerRunner(
|
val compiler = IncrementalJvmCompilerRunner(
|
||||||
cachesDir,
|
cachesDir,
|
||||||
sourceRoots.map { JvmSourceRoot(it, null) }.toSet(),
|
|
||||||
reporter,
|
reporter,
|
||||||
// Use precise setting in case of non-Gradle build
|
// Use precise setting in case of non-Gradle build
|
||||||
usePreciseJavaTracking = true,
|
usePreciseJavaTracking = true,
|
||||||
@@ -104,7 +104,6 @@ inline fun <R> withIC(enabled: Boolean = true, fn: ()->R): R {
|
|||||||
|
|
||||||
class IncrementalJvmCompilerRunner(
|
class IncrementalJvmCompilerRunner(
|
||||||
workingDir: File,
|
workingDir: File,
|
||||||
private val javaSourceRoots: Set<JvmSourceRoot>,
|
|
||||||
reporter: ICReporter,
|
reporter: ICReporter,
|
||||||
private val usePreciseJavaTracking: Boolean,
|
private val usePreciseJavaTracking: Boolean,
|
||||||
buildHistoryFile: File,
|
buildHistoryFile: File,
|
||||||
@@ -367,28 +366,11 @@ class IncrementalJvmCompilerRunner(
|
|||||||
messageCollector: MessageCollector
|
messageCollector: MessageCollector
|
||||||
): ExitCode {
|
): ExitCode {
|
||||||
val compiler = K2JVMCompiler()
|
val compiler = K2JVMCompiler()
|
||||||
val outputDir = args.destinationAsFile
|
val freeArgsBackup = args.freeArgs.toList()
|
||||||
val classpath = args.classpathAsList
|
args.freeArgs += sourcesToCompile.map { it.absolutePath }
|
||||||
val moduleFile = makeModuleFile(
|
val exitCode = compiler.exec(messageCollector, services, args)
|
||||||
args.moduleName!!,
|
args.freeArgs = freeArgsBackup
|
||||||
isTest = false,
|
return exitCode
|
||||||
outputDir = outputDir,
|
|
||||||
sourcesToCompile = sourcesToCompile,
|
|
||||||
commonSources = args.commonSources?.map(::File).orEmpty(),
|
|
||||||
javaSourceRoots = javaSourceRoots,
|
|
||||||
classpath = classpath,
|
|
||||||
friendDirs = listOf()
|
|
||||||
)
|
|
||||||
val destination = args.destination
|
|
||||||
args.destination = null
|
|
||||||
args.buildFile = moduleFile.absolutePath
|
|
||||||
|
|
||||||
return try {
|
|
||||||
compiler.exec(messageCollector, services, args)
|
|
||||||
} finally {
|
|
||||||
args.destination = destination
|
|
||||||
moduleFile.delete()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -18,7 +18,8 @@ internal class GradleCompilerEnvironment(
|
|||||||
outputItemsCollector: OutputItemsCollector,
|
outputItemsCollector: OutputItemsCollector,
|
||||||
val outputFiles: FileCollection,
|
val outputFiles: FileCollection,
|
||||||
val buildReportMode: BuildReportMode?,
|
val buildReportMode: BuildReportMode?,
|
||||||
val incrementalCompilationEnvironment: IncrementalCompilationEnvironment? = null
|
val incrementalCompilationEnvironment: IncrementalCompilationEnvironment? = null,
|
||||||
|
val kotlinScriptExtensions: Array<String> = emptyArray()
|
||||||
) : CompilerEnvironment(Services.EMPTY, messageCollector, outputItemsCollector) {
|
) : CompilerEnvironment(Services.EMPTY, messageCollector, outputItemsCollector) {
|
||||||
val toolsJar: File? by lazy { findToolsJar() }
|
val toolsJar: File? by lazy { findToolsJar() }
|
||||||
|
|
||||||
|
|||||||
+8
-17
@@ -22,7 +22,6 @@ import org.gradle.api.invocation.Gradle
|
|||||||
import org.gradle.api.plugins.JavaPluginConvention
|
import org.gradle.api.plugins.JavaPluginConvention
|
||||||
import org.gradle.api.tasks.bundling.AbstractArchiveTask
|
import org.gradle.api.tasks.bundling.AbstractArchiveTask
|
||||||
import org.gradle.jvm.tasks.Jar
|
import org.gradle.jvm.tasks.Jar
|
||||||
import org.jetbrains.kotlin.build.JvmSourceRoot
|
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
||||||
@@ -73,23 +72,16 @@ internal open class GradleCompilerRunner(protected val task: Task) {
|
|||||||
args: K2JVMCompilerArguments,
|
args: K2JVMCompilerArguments,
|
||||||
environment: GradleCompilerEnvironment
|
environment: GradleCompilerEnvironment
|
||||||
) {
|
) {
|
||||||
val buildFile = makeModuleFile(
|
args.freeArgs += sourcesToCompile.map { it.absolutePath }
|
||||||
args.moduleName!!,
|
args.commonSources = commonSources.map { it.absolutePath }.toTypedArray()
|
||||||
isTest = false,
|
args.javaSourceRoots = javaSourceRoots.map { it.absolutePath }.toTypedArray()
|
||||||
outputDir = args.destinationAsFile,
|
args.javaPackagePrefix = javaPackagePrefix
|
||||||
sourcesToCompile = sourcesToCompile,
|
|
||||||
commonSources = commonSources,
|
|
||||||
javaSourceRoots = javaSourceRoots.map { JvmSourceRoot(it, javaPackagePrefix) },
|
|
||||||
classpath = args.classpathAsList,
|
|
||||||
friendDirs = args.friendPaths?.map(::File).orEmpty()
|
|
||||||
)
|
|
||||||
args.buildFile = buildFile.absolutePath
|
|
||||||
|
|
||||||
if (environment.incrementalCompilationEnvironment == null || kotlinCompilerExecutionStrategy() != DAEMON_EXECUTION_STRATEGY) {
|
if (environment.incrementalCompilationEnvironment == null || kotlinCompilerExecutionStrategy() != DAEMON_EXECUTION_STRATEGY) {
|
||||||
args.destination = null
|
args.destination = null
|
||||||
}
|
}
|
||||||
|
|
||||||
runCompilerAsync(KotlinCompilerClass.JVM, args, environment, buildFile = buildFile)
|
runCompilerAsync(KotlinCompilerClass.JVM, args, environment)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -123,8 +115,7 @@ internal open class GradleCompilerRunner(protected val task: Task) {
|
|||||||
private fun runCompilerAsync(
|
private fun runCompilerAsync(
|
||||||
compilerClassName: String,
|
compilerClassName: String,
|
||||||
compilerArgs: CommonCompilerArguments,
|
compilerArgs: CommonCompilerArguments,
|
||||||
environment: GradleCompilerEnvironment,
|
environment: GradleCompilerEnvironment
|
||||||
buildFile: File? = null
|
|
||||||
) {
|
) {
|
||||||
if (compilerArgs.version) {
|
if (compilerArgs.version) {
|
||||||
task.logger.lifecycle(
|
task.logger.lifecycle(
|
||||||
@@ -144,10 +135,10 @@ internal open class GradleCompilerRunner(protected val task: Task) {
|
|||||||
isVerbose = compilerArgs.verbose,
|
isVerbose = compilerArgs.verbose,
|
||||||
incrementalCompilationEnvironment = incrementalCompilationEnvironment,
|
incrementalCompilationEnvironment = incrementalCompilationEnvironment,
|
||||||
incrementalModuleInfo = modulesInfo,
|
incrementalModuleInfo = modulesInfo,
|
||||||
buildFile = buildFile,
|
|
||||||
outputFiles = environment.outputFiles.toList(),
|
outputFiles = environment.outputFiles.toList(),
|
||||||
taskPath = task.path,
|
taskPath = task.path,
|
||||||
buildReportMode = environment.buildReportMode
|
buildReportMode = environment.buildReportMode,
|
||||||
|
kotlinScriptExtensions = environment.kotlinScriptExtensions
|
||||||
)
|
)
|
||||||
TaskLoggers.put(task.path, task.logger)
|
TaskLoggers.put(task.path, task.logger)
|
||||||
runCompilerAsync(workArgs)
|
runCompilerAsync(workArgs)
|
||||||
|
|||||||
+8
-14
@@ -19,7 +19,6 @@ import org.jetbrains.kotlin.gradle.tasks.clearLocalState
|
|||||||
import org.jetbrains.kotlin.gradle.tasks.throwGradleExceptionIfError
|
import org.jetbrains.kotlin.gradle.tasks.throwGradleExceptionIfError
|
||||||
import org.jetbrains.kotlin.gradle.utils.stackTraceAsString
|
import org.jetbrains.kotlin.gradle.utils.stackTraceAsString
|
||||||
import org.jetbrains.kotlin.incremental.ChangedFiles
|
import org.jetbrains.kotlin.incremental.ChangedFiles
|
||||||
import org.jetbrains.kotlin.incremental.DELETE_MODULE_FILE_PROPERTY
|
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import java.io.*
|
import java.io.*
|
||||||
import java.net.URLClassLoader
|
import java.net.URLClassLoader
|
||||||
@@ -53,10 +52,10 @@ internal class GradleKotlinCompilerWorkArguments(
|
|||||||
val isVerbose: Boolean,
|
val isVerbose: Boolean,
|
||||||
val incrementalCompilationEnvironment: IncrementalCompilationEnvironment?,
|
val incrementalCompilationEnvironment: IncrementalCompilationEnvironment?,
|
||||||
val incrementalModuleInfo: IncrementalModuleInfo?,
|
val incrementalModuleInfo: IncrementalModuleInfo?,
|
||||||
val buildFile: File?,
|
|
||||||
val outputFiles: List<File>,
|
val outputFiles: List<File>,
|
||||||
val taskPath: String,
|
val taskPath: String,
|
||||||
val buildReportMode: BuildReportMode?
|
val buildReportMode: BuildReportMode?,
|
||||||
|
val kotlinScriptExtensions: Array<String>
|
||||||
) : Serializable {
|
) : Serializable {
|
||||||
companion object {
|
companion object {
|
||||||
const val serialVersionUID: Long = 0
|
const val serialVersionUID: Long = 0
|
||||||
@@ -91,10 +90,10 @@ internal class GradleKotlinCompilerWork @Inject constructor(
|
|||||||
private val isVerbose = config.isVerbose
|
private val isVerbose = config.isVerbose
|
||||||
private val incrementalCompilationEnvironment = config.incrementalCompilationEnvironment
|
private val incrementalCompilationEnvironment = config.incrementalCompilationEnvironment
|
||||||
private val incrementalModuleInfo = config.incrementalModuleInfo
|
private val incrementalModuleInfo = config.incrementalModuleInfo
|
||||||
private val buildFile = config.buildFile
|
|
||||||
private val outputFiles = config.outputFiles
|
private val outputFiles = config.outputFiles
|
||||||
private val taskPath = config.taskPath
|
private val taskPath = config.taskPath
|
||||||
private val buildReportMode = config.buildReportMode
|
private val buildReportMode = config.buildReportMode
|
||||||
|
private val kotlinScriptExtensions = config.kotlinScriptExtensions
|
||||||
|
|
||||||
private val log: KotlinLogger =
|
private val log: KotlinLogger =
|
||||||
TaskLoggers.get(taskPath)?.let { GradleKotlinLogger(it).apply { debug("Using '$taskPath' logger") } }
|
TaskLoggers.get(taskPath)?.let { GradleKotlinLogger(it).apply { debug("Using '$taskPath' logger") } }
|
||||||
@@ -114,14 +113,7 @@ internal class GradleKotlinCompilerWork @Inject constructor(
|
|||||||
|
|
||||||
override fun run() {
|
override fun run() {
|
||||||
val messageCollector = GradlePrintingMessageCollector(log)
|
val messageCollector = GradlePrintingMessageCollector(log)
|
||||||
val exitCode = try {
|
val exitCode = compileWithDaemonOrFallbackImpl(messageCollector)
|
||||||
compileWithDaemonOrFallbackImpl(messageCollector)
|
|
||||||
} finally {
|
|
||||||
if (buildFile != null && System.getProperty(DELETE_MODULE_FILE_PROPERTY) != "false") {
|
|
||||||
buildFile.delete()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (incrementalCompilationEnvironment?.disableMultiModuleIC == true) {
|
if (incrementalCompilationEnvironment?.disableMultiModuleIC == true) {
|
||||||
incrementalCompilationEnvironment.multiModuleICSettings.buildHistoryFile.delete()
|
incrementalCompilationEnvironment.multiModuleICSettings.buildHistoryFile.delete()
|
||||||
}
|
}
|
||||||
@@ -230,7 +222,8 @@ internal class GradleKotlinCompilerWork @Inject constructor(
|
|||||||
targetPlatform = targetPlatform,
|
targetPlatform = targetPlatform,
|
||||||
reportCategories = reportCategories(isVerbose),
|
reportCategories = reportCategories(isVerbose),
|
||||||
reportSeverity = reportSeverity(isVerbose),
|
reportSeverity = reportSeverity(isVerbose),
|
||||||
requestedCompilationResults = emptyArray()
|
requestedCompilationResults = emptyArray(),
|
||||||
|
kotlinScriptExtensions = kotlinScriptExtensions
|
||||||
)
|
)
|
||||||
val servicesFacade = GradleCompilerServicesFacadeImpl(log, bufferingMessageCollector)
|
val servicesFacade = GradleCompilerServicesFacadeImpl(log, bufferingMessageCollector)
|
||||||
return try {
|
return try {
|
||||||
@@ -275,7 +268,8 @@ internal class GradleKotlinCompilerWork @Inject constructor(
|
|||||||
outputFiles = outputFiles,
|
outputFiles = outputFiles,
|
||||||
multiModuleICSettings = icEnv.multiModuleICSettings,
|
multiModuleICSettings = icEnv.multiModuleICSettings,
|
||||||
modulesInfo = incrementalModuleInfo!!,
|
modulesInfo = incrementalModuleInfo!!,
|
||||||
classpathFqNamesHistory = icEnv.classpathFqNamesHistory
|
classpathFqNamesHistory = icEnv.classpathFqNamesHistory,
|
||||||
|
kotlinScriptExtensions = kotlinScriptExtensions
|
||||||
)
|
)
|
||||||
|
|
||||||
log.info("Options for KOTLIN DAEMON: $compilationOptions")
|
log.info("Options for KOTLIN DAEMON: $compilationOptions")
|
||||||
|
|||||||
+1
@@ -55,6 +55,7 @@ internal object CompilerArgumentsGradleInput {
|
|||||||
K2JVMCompilerArguments::buildFile, // in Gradle build, these XMLs are transient and provide no useful info
|
K2JVMCompilerArguments::buildFile, // in Gradle build, these XMLs are transient and provide no useful info
|
||||||
K2JVMCompilerArguments::pluginOptions, // handled specially in the task
|
K2JVMCompilerArguments::pluginOptions, // handled specially in the task
|
||||||
K2JVMCompilerArguments::pluginClasspaths, // handled in the task as classpath
|
K2JVMCompilerArguments::pluginClasspaths, // handled in the task as classpath
|
||||||
|
K2JVMCompilerArguments::javaSourceRoots, // handled in inputs
|
||||||
|
|
||||||
K2JSCompilerArguments::outputFile, // already handled by Gradle task property
|
K2JSCompilerArguments::outputFile, // already handled by Gradle task property
|
||||||
K2JSCompilerArguments::libraries, // defined by by classpath and friendDependency of the Gradle task
|
K2JSCompilerArguments::libraries, // defined by by classpath and friendDependency of the Gradle task
|
||||||
|
|||||||
+2
-1
@@ -439,7 +439,8 @@ open class KotlinCompile : AbstractKotlinCompile<K2JVMCompilerArguments>(), Kotl
|
|||||||
computedCompilerClasspath, messageCollector, outputItemCollector,
|
computedCompilerClasspath, messageCollector, outputItemCollector,
|
||||||
outputFiles = allOutputFiles(),
|
outputFiles = allOutputFiles(),
|
||||||
buildReportMode = buildReportMode,
|
buildReportMode = buildReportMode,
|
||||||
incrementalCompilationEnvironment = icEnv
|
incrementalCompilationEnvironment = icEnv,
|
||||||
|
kotlinScriptExtensions = sourceFilesExtensions.toTypedArray()
|
||||||
)
|
)
|
||||||
compilerRunner.runJvmCompilerAsync(
|
compilerRunner.runJvmCompilerAsync(
|
||||||
sourceRoots.kotlinSourceFiles,
|
sourceRoots.kotlinSourceFiles,
|
||||||
|
|||||||
Reference in New Issue
Block a user