Stop using -Xbuild-file in Gradle Plugin
#KT-27640 fixed
#KT-27778 fixed
#KT-27638 fixed
This commit is contained in:
+2
-1
@@ -18,7 +18,8 @@ internal class GradleCompilerEnvironment(
|
||||
outputItemsCollector: OutputItemsCollector,
|
||||
val outputFiles: FileCollection,
|
||||
val buildReportMode: BuildReportMode?,
|
||||
val incrementalCompilationEnvironment: IncrementalCompilationEnvironment? = null
|
||||
val incrementalCompilationEnvironment: IncrementalCompilationEnvironment? = null,
|
||||
val kotlinScriptExtensions: Array<String> = emptyArray()
|
||||
) : CompilerEnvironment(Services.EMPTY, messageCollector, outputItemsCollector) {
|
||||
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.tasks.bundling.AbstractArchiveTask
|
||||
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.K2JSCompilerArguments
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
||||
@@ -73,23 +72,16 @@ internal open class GradleCompilerRunner(protected val task: Task) {
|
||||
args: K2JVMCompilerArguments,
|
||||
environment: GradleCompilerEnvironment
|
||||
) {
|
||||
val buildFile = makeModuleFile(
|
||||
args.moduleName!!,
|
||||
isTest = false,
|
||||
outputDir = args.destinationAsFile,
|
||||
sourcesToCompile = sourcesToCompile,
|
||||
commonSources = commonSources,
|
||||
javaSourceRoots = javaSourceRoots.map { JvmSourceRoot(it, javaPackagePrefix) },
|
||||
classpath = args.classpathAsList,
|
||||
friendDirs = args.friendPaths?.map(::File).orEmpty()
|
||||
)
|
||||
args.buildFile = buildFile.absolutePath
|
||||
args.freeArgs += sourcesToCompile.map { it.absolutePath }
|
||||
args.commonSources = commonSources.map { it.absolutePath }.toTypedArray()
|
||||
args.javaSourceRoots = javaSourceRoots.map { it.absolutePath }.toTypedArray()
|
||||
args.javaPackagePrefix = javaPackagePrefix
|
||||
|
||||
if (environment.incrementalCompilationEnvironment == null || kotlinCompilerExecutionStrategy() != DAEMON_EXECUTION_STRATEGY) {
|
||||
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(
|
||||
compilerClassName: String,
|
||||
compilerArgs: CommonCompilerArguments,
|
||||
environment: GradleCompilerEnvironment,
|
||||
buildFile: File? = null
|
||||
environment: GradleCompilerEnvironment
|
||||
) {
|
||||
if (compilerArgs.version) {
|
||||
task.logger.lifecycle(
|
||||
@@ -144,10 +135,10 @@ internal open class GradleCompilerRunner(protected val task: Task) {
|
||||
isVerbose = compilerArgs.verbose,
|
||||
incrementalCompilationEnvironment = incrementalCompilationEnvironment,
|
||||
incrementalModuleInfo = modulesInfo,
|
||||
buildFile = buildFile,
|
||||
outputFiles = environment.outputFiles.toList(),
|
||||
taskPath = task.path,
|
||||
buildReportMode = environment.buildReportMode
|
||||
buildReportMode = environment.buildReportMode,
|
||||
kotlinScriptExtensions = environment.kotlinScriptExtensions
|
||||
)
|
||||
TaskLoggers.put(task.path, task.logger)
|
||||
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.utils.stackTraceAsString
|
||||
import org.jetbrains.kotlin.incremental.ChangedFiles
|
||||
import org.jetbrains.kotlin.incremental.DELETE_MODULE_FILE_PROPERTY
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.io.*
|
||||
import java.net.URLClassLoader
|
||||
@@ -53,10 +52,10 @@ internal class GradleKotlinCompilerWorkArguments(
|
||||
val isVerbose: Boolean,
|
||||
val incrementalCompilationEnvironment: IncrementalCompilationEnvironment?,
|
||||
val incrementalModuleInfo: IncrementalModuleInfo?,
|
||||
val buildFile: File?,
|
||||
val outputFiles: List<File>,
|
||||
val taskPath: String,
|
||||
val buildReportMode: BuildReportMode?
|
||||
val buildReportMode: BuildReportMode?,
|
||||
val kotlinScriptExtensions: Array<String>
|
||||
) : Serializable {
|
||||
companion object {
|
||||
const val serialVersionUID: Long = 0
|
||||
@@ -91,10 +90,10 @@ internal class GradleKotlinCompilerWork @Inject constructor(
|
||||
private val isVerbose = config.isVerbose
|
||||
private val incrementalCompilationEnvironment = config.incrementalCompilationEnvironment
|
||||
private val incrementalModuleInfo = config.incrementalModuleInfo
|
||||
private val buildFile = config.buildFile
|
||||
private val outputFiles = config.outputFiles
|
||||
private val taskPath = config.taskPath
|
||||
private val buildReportMode = config.buildReportMode
|
||||
private val kotlinScriptExtensions = config.kotlinScriptExtensions
|
||||
|
||||
private val log: KotlinLogger =
|
||||
TaskLoggers.get(taskPath)?.let { GradleKotlinLogger(it).apply { debug("Using '$taskPath' logger") } }
|
||||
@@ -114,14 +113,7 @@ internal class GradleKotlinCompilerWork @Inject constructor(
|
||||
|
||||
override fun run() {
|
||||
val messageCollector = GradlePrintingMessageCollector(log)
|
||||
val exitCode = try {
|
||||
compileWithDaemonOrFallbackImpl(messageCollector)
|
||||
} finally {
|
||||
if (buildFile != null && System.getProperty(DELETE_MODULE_FILE_PROPERTY) != "false") {
|
||||
buildFile.delete()
|
||||
}
|
||||
}
|
||||
|
||||
val exitCode = compileWithDaemonOrFallbackImpl(messageCollector)
|
||||
if (incrementalCompilationEnvironment?.disableMultiModuleIC == true) {
|
||||
incrementalCompilationEnvironment.multiModuleICSettings.buildHistoryFile.delete()
|
||||
}
|
||||
@@ -230,7 +222,8 @@ internal class GradleKotlinCompilerWork @Inject constructor(
|
||||
targetPlatform = targetPlatform,
|
||||
reportCategories = reportCategories(isVerbose),
|
||||
reportSeverity = reportSeverity(isVerbose),
|
||||
requestedCompilationResults = emptyArray()
|
||||
requestedCompilationResults = emptyArray(),
|
||||
kotlinScriptExtensions = kotlinScriptExtensions
|
||||
)
|
||||
val servicesFacade = GradleCompilerServicesFacadeImpl(log, bufferingMessageCollector)
|
||||
return try {
|
||||
@@ -275,7 +268,8 @@ internal class GradleKotlinCompilerWork @Inject constructor(
|
||||
outputFiles = outputFiles,
|
||||
multiModuleICSettings = icEnv.multiModuleICSettings,
|
||||
modulesInfo = incrementalModuleInfo!!,
|
||||
classpathFqNamesHistory = icEnv.classpathFqNamesHistory
|
||||
classpathFqNamesHistory = icEnv.classpathFqNamesHistory,
|
||||
kotlinScriptExtensions = kotlinScriptExtensions
|
||||
)
|
||||
|
||||
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::pluginOptions, // handled specially in the task
|
||||
K2JVMCompilerArguments::pluginClasspaths, // handled in the task as classpath
|
||||
K2JVMCompilerArguments::javaSourceRoots, // handled in inputs
|
||||
|
||||
K2JSCompilerArguments::outputFile, // already handled by Gradle task property
|
||||
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,
|
||||
outputFiles = allOutputFiles(),
|
||||
buildReportMode = buildReportMode,
|
||||
incrementalCompilationEnvironment = icEnv
|
||||
incrementalCompilationEnvironment = icEnv,
|
||||
kotlinScriptExtensions = sourceFilesExtensions.toTypedArray()
|
||||
)
|
||||
compilerRunner.runJvmCompilerAsync(
|
||||
sourceRoots.kotlinSourceFiles,
|
||||
|
||||
Reference in New Issue
Block a user