1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 00:17:11 -07:00

Incremental compilation.

This commit is contained in:
Cedric Beust 2017-03-03 13:52:25 -08:00
parent 83633cd011
commit 4bdc12def5
10 changed files with 121 additions and 38 deletions

View file

@ -57,9 +57,6 @@ class Args {
@Parameter(names = arrayOf("--noIncremental"), description = "Turn off incremental builds")
var noIncremental: Boolean = false
@Parameter(names = arrayOf("--parallel"), description = "Build all the projects in parallel whenever possible")
var parallel: Boolean = true
@Parameter(names = arrayOf("--plugins"), description = "Comma-separated list of plug-in Maven id's")
var pluginIds: String? = null
@ -82,6 +79,9 @@ class Args {
@Parameter(names = arrayOf("--projectInfo"), description = "Display information about the current projects")
var projectInfo: Boolean = false
@Parameter(names = arrayOf("--noIncrementalKotlin"), description = "Disable incremental Kotlin compilation")
var noIncrementalKotlin: Boolean = false
@Parameter(names = arrayOf("--sequential"), description = "Build all the projects in sequence")
var sequential: Boolean = false

View file

@ -11,4 +11,5 @@ data class CompilerActionInfo(val directory: String?,
val suffixesBeingCompiled: List<String>,
val outputDir: File,
val compilerArgs: List<String>,
val friendPaths: List<String>)
val friendPaths: List<String>,
val forceRecompile: Boolean)

View file

@ -19,6 +19,7 @@ import java.io.File
class KobaltContext(val args: Args) {
lateinit var variant: Variant
val profiles = arrayListOf<String>()
var forceRecompile: Boolean = false
init {
args.profiles?.split(',')?.filterNotNull()?.forEach {

View file

@ -167,7 +167,7 @@ class CompilerUtils @Inject constructor(val files: KFiles, val dependencyManager
// Finally, alter the info with the compiler interceptors before returning it
val initialActionInfo = CompilerActionInfo(projectDirectory.path, classpath, allSources,
sourceSuffixes, buildDirectory, emptyList() /* the flags will be provided by flag contributors */,
emptyList())
emptyList(), context.forceRecompile)
val result = context.pluginInfo.compilerInterceptors.fold(initialActionInfo, { ai, interceptor ->
interceptor.intercept(project, context, ai)
})

View file

@ -5,14 +5,12 @@ import com.beust.kobalt.api.Kobalt
import com.beust.kobalt.api.Project
import com.beust.kobalt.internal.build.BuildFile
import com.beust.kobalt.maven.Md5
import java.io.File
import java.io.IOException
import java.io.InputStream
import java.io.OutputStream
import java.io.*
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
import java.nio.file.StandardCopyOption
import java.util.jar.JarInputStream
class KFiles {
/**
@ -170,6 +168,30 @@ class KFiles {
return result
}
/**
* List the files contained in a directory or a jar file.
*/
fun listFiles(file: File, block: (String) -> Unit) {
if (file.isDirectory) {
KFiles.findRecursively(file).forEach {
block(it)
}
} else if (file.name.endsWith(".jar")) {
FileInputStream(file).use {
JarInputStream(it).use { stream ->
var entry = stream.nextJarEntry
while (entry != null) {
block(entry.name)
entry = stream.nextJarEntry;
}
}
}
} else {
throw KobaltException("Can't list files of a file: " + file)
}
}
fun copyRecursively(from: File, to: File, replaceExisting: Boolean = true, deleteFirst: Boolean = false,
onError: (File, IOException) -> OnErrorAction = { _, exception -> throw exception }) {
// Need to wait until copyRecursively supports an overwrite: Boolean = false parameter