mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 16:28:12 -07:00
Always compile the build files with Kotlin incremental compilation disabled.
This commit is contained in:
parent
187593b9b1
commit
1f3f666d93
6 changed files with 23 additions and 8 deletions
|
@ -19,7 +19,6 @@ import java.io.File
|
||||||
class KobaltContext(val args: Args) {
|
class KobaltContext(val args: Args) {
|
||||||
lateinit var variant: Variant
|
lateinit var variant: Variant
|
||||||
val profiles = arrayListOf<String>()
|
val profiles = arrayListOf<String>()
|
||||||
var forceRecompile: Boolean = false
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
args.profiles?.split(',')?.filterNotNull()?.forEach {
|
args.profiles?.split(',')?.filterNotNull()?.forEach {
|
||||||
|
@ -106,4 +105,12 @@ class InternalContext {
|
||||||
* The absolute directory of the current project.
|
* The absolute directory of the current project.
|
||||||
*/
|
*/
|
||||||
var absoluteDir: File? = null
|
var absoluteDir: File? = null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If true, will force a recompile of the files even if using the incremental compile
|
||||||
|
*/
|
||||||
|
var forceRecompile: Boolean = false
|
||||||
|
|
||||||
|
var noIncrementalKotlin: Boolean = false
|
||||||
|
|
||||||
}
|
}
|
|
@ -167,7 +167,7 @@ class CompilerUtils @Inject constructor(val files: KFiles, val dependencyManager
|
||||||
// Finally, alter the info with the compiler interceptors before returning it
|
// Finally, alter the info with the compiler interceptors before returning it
|
||||||
val initialActionInfo = CompilerActionInfo(projectDirectory.path, classpath, allSources,
|
val initialActionInfo = CompilerActionInfo(projectDirectory.path, classpath, allSources,
|
||||||
sourceSuffixes, buildDirectory, emptyList() /* the flags will be provided by flag contributors */,
|
sourceSuffixes, buildDirectory, emptyList() /* the flags will be provided by flag contributors */,
|
||||||
emptyList(), context.forceRecompile)
|
emptyList(), context.internalContext.forceRecompile)
|
||||||
val result = context.pluginInfo.compilerInterceptors.fold(initialActionInfo, { ai, interceptor ->
|
val result = context.pluginInfo.compilerInterceptors.fold(initialActionInfo, { ai, interceptor ->
|
||||||
interceptor.intercept(project, context, ai)
|
interceptor.intercept(project, context, ai)
|
||||||
})
|
})
|
||||||
|
|
|
@ -61,7 +61,7 @@ class BuildFileCompiler @Inject constructor(@Assisted("buildFiles") val buildFil
|
||||||
context.resolver = resolver
|
context.resolver = resolver
|
||||||
context.pomGeneratorFactory = pomGeneratorFactory
|
context.pomGeneratorFactory = pomGeneratorFactory
|
||||||
context.logger = parallelLogger
|
context.logger = parallelLogger
|
||||||
context.forceRecompile = forceRecompile
|
context.internalContext.forceRecompile = forceRecompile
|
||||||
Kobalt.context = context
|
Kobalt.context = context
|
||||||
|
|
||||||
// The list of dynamic plug-ins has to be a companion since it's modified directly from
|
// The list of dynamic plug-ins has to be a companion since it's modified directly from
|
||||||
|
@ -111,7 +111,7 @@ class BuildFileCompiler @Inject constructor(@Assisted("buildFiles") val buildFil
|
||||||
KFiles.saveFile(modifiedBuildFile, parsedBuildFile.buildScriptCode)
|
KFiles.saveFile(modifiedBuildFile, parsedBuildFile.buildScriptCode)
|
||||||
val taskResult = maybeCompileBuildFile(context, BuildFile(Paths.get(modifiedBuildFile.path),
|
val taskResult = maybeCompileBuildFile(context, BuildFile(Paths.get(modifiedBuildFile.path),
|
||||||
"Modified ${Constants.BUILD_FILE_NAME}", buildFile.realPath),
|
"Modified ${Constants.BUILD_FILE_NAME}", buildFile.realPath),
|
||||||
buildScriptJarFile, pluginUrls, context.forceRecompile)
|
buildScriptJarFile, pluginUrls, context.internalContext.forceRecompile)
|
||||||
if (taskResult.success) {
|
if (taskResult.success) {
|
||||||
projects.addAll(buildScriptUtil.runBuildScriptJarFile(buildScriptJarFile, pluginUrls, context))
|
projects.addAll(buildScriptUtil.runBuildScriptJarFile(buildScriptJarFile, pluginUrls, context))
|
||||||
} else {
|
} else {
|
||||||
|
@ -155,6 +155,7 @@ class BuildFileCompiler @Inject constructor(@Assisted("buildFiles") val buildFil
|
||||||
classpath(buildFileClasspath)
|
classpath(buildFileClasspath)
|
||||||
sourceFiles(listOf(buildFile.path.toFile().absolutePath))
|
sourceFiles(listOf(buildFile.path.toFile().absolutePath))
|
||||||
output = buildScriptJarFile
|
output = buildScriptJarFile
|
||||||
|
noIncrementalKotlin = true
|
||||||
}.compile(context = context)
|
}.compile(context = context)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -138,11 +138,13 @@ class ParsedBuildFile(val buildFile: BuildFile, val context: KobaltContext, val
|
||||||
val kotlinDeps = dependencyManager.calculateDependencies(null, context)
|
val kotlinDeps = dependencyManager.calculateDependencies(null, context)
|
||||||
val deps: List<String> = kotlinDeps.map { it.jarFile.get().absolutePath }
|
val deps: List<String> = kotlinDeps.map { it.jarFile.get().absolutePath }
|
||||||
val outputJar = File(buildScriptJarFile.absolutePath)
|
val outputJar = File(buildScriptJarFile.absolutePath)
|
||||||
|
val saved = context.internalContext.noIncrementalKotlin
|
||||||
val result = kotlinCompilePrivate {
|
val result = kotlinCompilePrivate {
|
||||||
classpath(files.kobaltJar)
|
classpath(files.kobaltJar)
|
||||||
classpath(deps)
|
classpath(deps)
|
||||||
sourceFiles(buildFile.path.toFile().absolutePath)
|
sourceFiles(buildFile.path.toFile().absolutePath)
|
||||||
output = outputJar
|
output = outputJar
|
||||||
|
noIncrementalKotlin = true
|
||||||
}.compile(context = context)
|
}.compile(context = context)
|
||||||
if (! result.success) {
|
if (! result.success) {
|
||||||
throw KobaltException("Couldn't compile ${originalFile.realPath}:\n"
|
throw KobaltException("Couldn't compile ${originalFile.realPath}:\n"
|
||||||
|
|
|
@ -91,7 +91,7 @@ class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, va
|
||||||
val dependencies = dependencyManager.calculateDependencies(project, context)
|
val dependencies = dependencyManager.calculateDependencies(project, context)
|
||||||
val info = CompilerActionInfo(sourceDir.absolutePath, dependencies,
|
val info = CompilerActionInfo(sourceDir.absolutePath, dependencies,
|
||||||
listOf(javaFile.absolutePath), listOf("java"), File(sourceDir, "generated"),
|
listOf(javaFile.absolutePath), listOf("java"), File(sourceDir, "generated"),
|
||||||
listOf(), listOf(), context.forceRecompile)
|
listOf(), listOf(), context.internalContext.forceRecompile)
|
||||||
|
|
||||||
val results = compilerUtils.invokeCompiler(project, context, javaCompiler, info)
|
val results = compilerUtils.invokeCompiler(project, context, javaCompiler, info)
|
||||||
}
|
}
|
||||||
|
|
|
@ -223,7 +223,7 @@ class KotlinCompiler @Inject constructor(
|
||||||
System.setProperty("kotlin.incremental.compilation.experimental", "true")
|
System.setProperty("kotlin.incremental.compilation.experimental", "true")
|
||||||
|
|
||||||
val result =
|
val result =
|
||||||
if (cliArgs.noIncrementalKotlin) {
|
if (cliArgs.noIncrementalKotlin || Kobalt.context?.internalContext?.noIncrementalKotlin ?: false) {
|
||||||
log(2, " Kotlin incremental compilation is disabled")
|
log(2, " Kotlin incremental compilation is disabled")
|
||||||
val duration = benchmarkMillis {
|
val duration = benchmarkMillis {
|
||||||
K2JVMCompiler().exec(collector, Services.Builder().build(), args)
|
K2JVMCompiler().exec(collector, Services.Builder().build(), args)
|
||||||
|
@ -383,7 +383,7 @@ class KotlinCompiler @Inject constructor(
|
||||||
emptyList<String>()
|
emptyList<String>()
|
||||||
}
|
}
|
||||||
val info = CompilerActionInfo(project?.directory, dependencies, sourceFiles, listOf("kt"), outputDir, args,
|
val info = CompilerActionInfo(project?.directory, dependencies, sourceFiles, listOf("kt"), outputDir, args,
|
||||||
friendPaths, context?.forceRecompile ?: false)
|
friendPaths, context?.internalContext?.forceRecompile ?: false)
|
||||||
|
|
||||||
return jvmCompiler.doCompile(project, context, compilerAction, info,
|
return jvmCompiler.doCompile(project, context, compilerAction, info,
|
||||||
if (context != null) compilerUtils.sourceCompilerFlags(project, context, info) else emptyList())
|
if (context != null) compilerUtils.sourceCompilerFlags(project, context, info) else emptyList())
|
||||||
|
@ -396,6 +396,7 @@ class KConfiguration @Inject constructor(val compiler: KotlinCompiler){
|
||||||
var source = arrayListOf<String>()
|
var source = arrayListOf<String>()
|
||||||
var output: File by Delegates.notNull()
|
var output: File by Delegates.notNull()
|
||||||
val args = arrayListOf<String>()
|
val args = arrayListOf<String>()
|
||||||
|
var noIncrementalKotlin = false
|
||||||
|
|
||||||
fun sourceFiles(s: String) = source.add(s)
|
fun sourceFiles(s: String) = source.add(s)
|
||||||
|
|
||||||
|
@ -408,7 +409,11 @@ class KConfiguration @Inject constructor(val compiler: KotlinCompiler){
|
||||||
fun compilerArgs(s: List<String>) = args.addAll(s)
|
fun compilerArgs(s: List<String>) = args.addAll(s)
|
||||||
|
|
||||||
fun compile(project: Project? = null, context: KobaltContext? = null) : TaskResult {
|
fun compile(project: Project? = null, context: KobaltContext? = null) : TaskResult {
|
||||||
return compiler.compile(project, context, dependencies, classpath, source, output, args)
|
val saved = context?.internalContext?.noIncrementalKotlin ?: false
|
||||||
|
if (context != null) context.internalContext.noIncrementalKotlin = noIncrementalKotlin
|
||||||
|
val result = compiler.compile(project, context, dependencies, classpath, source, output, args)
|
||||||
|
if (context != null) context.internalContext.noIncrementalKotlin = saved
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue