[Gradle, JVM] Validate JVM targets even if compiler isn't called
Previously the validation was inconsistent allowing non-incremental builds without Kotlin sources to pass successfully with JVM target misconfiguraiton but fail incremental builds #KT-48408 Fixed
This commit is contained in:
committed by
Space
parent
2a77da4caa
commit
aa52a60f45
+9
-3
@@ -375,6 +375,9 @@ abstract class AbstractKotlinCompile<T : CommonCompilerArguments> : AbstractKotl
|
|||||||
|
|
||||||
logger.kotlinDebug { "All kotlin sources: ${allKotlinSources.pathsAsStringRelativeTo(projectDir)}" }
|
logger.kotlinDebug { "All kotlin sources: ${allKotlinSources.pathsAsStringRelativeTo(projectDir)}" }
|
||||||
|
|
||||||
|
val args = prepareCompilerArguments()
|
||||||
|
validateCompilerArguments(args)
|
||||||
|
|
||||||
if (!inputChanges.isIncremental && skipCondition()) {
|
if (!inputChanges.isIncremental && skipCondition()) {
|
||||||
// Skip running only if non-incremental run. Otherwise, we may need to do some cleanup.
|
// Skip running only if non-incremental run. Otherwise, we may need to do some cleanup.
|
||||||
logger.kotlinDebug { "No Kotlin files found, skipping Kotlin compiler task" }
|
logger.kotlinDebug { "No Kotlin files found, skipping Kotlin compiler task" }
|
||||||
@@ -382,7 +385,6 @@ abstract class AbstractKotlinCompile<T : CommonCompilerArguments> : AbstractKotl
|
|||||||
}
|
}
|
||||||
|
|
||||||
sourceRoots.log(this.name, logger)
|
sourceRoots.log(this.name, logger)
|
||||||
val args = prepareCompilerArguments()
|
|
||||||
taskBuildDirectory.get().asFile.mkdirs()
|
taskBuildDirectory.get().asFile.mkdirs()
|
||||||
callCompilerAsync(args, sourceRoots, inputChanges)
|
callCompilerAsync(args, sourceRoots, inputChanges)
|
||||||
}
|
}
|
||||||
@@ -412,6 +414,8 @@ abstract class AbstractKotlinCompile<T : CommonCompilerArguments> : AbstractKotl
|
|||||||
@Internal
|
@Internal
|
||||||
internal abstract fun getSourceRoots(): SourceRoots
|
internal abstract fun getSourceRoots(): SourceRoots
|
||||||
|
|
||||||
|
protected open fun validateCompilerArguments(args: T) = Unit
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compiler might be executed asynchronously. Do not do anything requiring end of compilation after this function is called.
|
* Compiler might be executed asynchronously. Do not do anything requiring end of compilation after this function is called.
|
||||||
* @see [GradleKotlinCompilerWork]
|
* @see [GradleKotlinCompilerWork]
|
||||||
@@ -663,11 +667,13 @@ abstract class KotlinCompile @Inject constructor(
|
|||||||
|
|
||||||
override fun getSourceRoots(): SourceRoots.ForJvm = jvmSourceRoots
|
override fun getSourceRoots(): SourceRoots.ForJvm = jvmSourceRoots
|
||||||
|
|
||||||
|
override fun validateCompilerArguments(args: K2JVMCompilerArguments) {
|
||||||
|
validateKotlinAndJavaHasSameTargetCompatibility(args)
|
||||||
|
}
|
||||||
|
|
||||||
override fun callCompilerAsync(args: K2JVMCompilerArguments, sourceRoots: SourceRoots, inputChanges: InputChanges) {
|
override fun callCompilerAsync(args: K2JVMCompilerArguments, sourceRoots: SourceRoots, inputChanges: InputChanges) {
|
||||||
sourceRoots as SourceRoots.ForJvm
|
sourceRoots as SourceRoots.ForJvm
|
||||||
|
|
||||||
validateKotlinAndJavaHasSameTargetCompatibility(args)
|
|
||||||
|
|
||||||
val messageCollector = GradlePrintingMessageCollector(logger, args.allWarningsAsErrors)
|
val messageCollector = GradlePrintingMessageCollector(logger, args.allWarningsAsErrors)
|
||||||
val outputItemCollector = OutputItemsCollectorImpl()
|
val outputItemCollector = OutputItemsCollectorImpl()
|
||||||
val compilerRunner = compilerRunner.get()
|
val compilerRunner = compilerRunner.get()
|
||||||
|
|||||||
Reference in New Issue
Block a user