mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 00:17:11 -07:00
Incremental packaging.
This commit is contained in:
parent
fa546e4510
commit
15b43c0127
12 changed files with 94 additions and 44 deletions
|
@ -3,6 +3,6 @@ package com.beust.kobalt
|
|||
class Features {
|
||||
companion object {
|
||||
/** If true, uses timestamps to speed up the tasks */
|
||||
const val USE_TIMESTAMPS = false
|
||||
const val USE_TIMESTAMPS = true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ class JvmCompiler @Inject constructor(val dependencyManager: DependencyManager)
|
|||
val addedFlags = contributorFlags + ArrayList(info.compilerArgs)
|
||||
|
||||
validateClasspath(allDependencies.map { it.jarFile.get().absolutePath })
|
||||
return action.compile(info.copy(dependencies = allDependencies, compilerArgs = addedFlags))
|
||||
return action.compile(project?.name, info.copy(dependencies = allDependencies, compilerArgs = addedFlags))
|
||||
}
|
||||
|
||||
private fun validateClasspath(cp: List<String>) {
|
||||
|
@ -53,5 +53,5 @@ class JvmCompiler @Inject constructor(val dependencyManager: DependencyManager)
|
|||
}
|
||||
|
||||
interface ICompilerAction {
|
||||
fun compile(info: CompilerActionInfo): TaskResult
|
||||
fun compile(projectName: String?, info: CompilerActionInfo): TaskResult
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
package com.beust.kobalt.internal
|
||||
|
||||
import com.beust.kobalt.Features
|
||||
import com.beust.kobalt.IncrementalTaskInfo
|
||||
import com.beust.kobalt.KobaltException
|
||||
import com.beust.kobalt.TaskResult
|
||||
|
@ -188,16 +187,11 @@ abstract class JvmCompilerPlugin @Inject constructor(
|
|||
sourceDirectories.add(sourceDirectory)
|
||||
}
|
||||
val info = createCompilerActionInfo(project, context, isTest = false)
|
||||
if (! Features.USE_TIMESTAMPS || isOutdated(project, context, info)) {
|
||||
val compiler = ActorUtils.selectAffinityActor(project, context, context.pluginInfo.compilerContributors)
|
||||
if (compiler != null) {
|
||||
return compiler.compile(project, context, info)
|
||||
} else {
|
||||
throw KobaltException("Couldn't find any compiler for project ${project.name}")
|
||||
}
|
||||
val compiler = ActorUtils.selectAffinityActor(project, context, context.pluginInfo.compilerContributors)
|
||||
if (compiler != null) {
|
||||
return compiler.compile(project, context, info)
|
||||
} else {
|
||||
log(2, " Source files are up to date, not compiling")
|
||||
return TaskResult()
|
||||
throw KobaltException("Couldn't find any compiler for project ${project.name}")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ public class TaskManager @Inject constructor(val args: Args, val incrementalMana
|
|||
graph.addEdge(pluginTask, to)
|
||||
}
|
||||
} else {
|
||||
log(2, "Couldn't find node $it: not applicable to project ${project.name}")
|
||||
log(1, "Couldn't find node $it: not applicable to project ${project.name}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ public class TaskManager @Inject constructor(val args: Args, val incrementalMana
|
|||
newToProcess.add(TaskInfo(project.name, it))
|
||||
}
|
||||
} else {
|
||||
log(2, "Couldn't find task ${currentTask.taskName}: not applicable to project ${project.name}")
|
||||
log(1, "Couldn't find task ${currentTask.taskName}: not applicable to project ${project.name}")
|
||||
}
|
||||
}
|
||||
done = newToProcess.isEmpty()
|
||||
|
@ -256,34 +256,37 @@ public class TaskManager @Inject constructor(val args: Args, val incrementalMana
|
|||
if (outputChecksum == iit.outputChecksum) {
|
||||
upToDate = true
|
||||
} else {
|
||||
log(2, " INC- Incremental task ${ta.name} output is out of date, running it")
|
||||
logIncremental(1, "Incremental task ${ta.name} output is out of date, running it")
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log(2, " INC- Incremental task ${ta.name} input is out of date, running it")
|
||||
logIncremental(1, "Incremental task ${ta.name} input is out of date, running it"
|
||||
+ " old: $inputChecksum new: ${iit.inputChecksum}")
|
||||
}
|
||||
}
|
||||
if (! upToDate) {
|
||||
val result = iit.task(project)
|
||||
if (result.success) {
|
||||
log(2, " INC- Incremental task ${ta.name} done running, saving checksums")
|
||||
logIncremental(1, "Incremental task ${ta.name} done running, saving checksums")
|
||||
iit.inputChecksum?.let {
|
||||
incrementalManager.saveInputChecksum(taskName, it)
|
||||
log(2, " INC- input checksum \"$it\" saved")
|
||||
logIncremental(1, " input checksum \"$it\" saved")
|
||||
}
|
||||
iit.outputChecksum?.let {
|
||||
incrementalManager.saveOutputChecksum(taskName, it)
|
||||
log(2, " INC- output checksum \"$it\" saved")
|
||||
logIncremental(1, " output checksum \"$it\" saved")
|
||||
}
|
||||
}
|
||||
result
|
||||
} else {
|
||||
log(2, " INC- Incremental task ${ta.name} is up to date, not running it")
|
||||
logIncremental(2, "Incremental task \"${ta.name}\" is up to date, not running it")
|
||||
TaskResult()
|
||||
}
|
||||
})
|
||||
|
||||
private fun logIncremental(level: Int, s: String) = log(level, " INC - $s")
|
||||
|
||||
class PluginDynamicTask(val plugin: IPlugin, val task: DynamicTask)
|
||||
|
||||
/** Tasks annotated with @Task or @IncrementalTask */
|
||||
|
|
|
@ -11,15 +11,20 @@ public class Md5 {
|
|||
fun toMd5Directories(directories: List<File>) : String {
|
||||
MessageDigest.getInstance("MD5").let { md5 ->
|
||||
directories.forEach { file ->
|
||||
val files = KFiles.findRecursively(file) // , { f -> f.endsWith("java")})
|
||||
log(2, " Calculating checksum of ${files.size} files")
|
||||
files.map {
|
||||
File(file, it)
|
||||
}.filter {
|
||||
it.isFile
|
||||
}.forEach {
|
||||
val bytes = it.readBytes()
|
||||
if (file.isFile) {
|
||||
val bytes = file.readBytes()
|
||||
md5.update(bytes, 0, bytes.size)
|
||||
} else {
|
||||
val files = KFiles.findRecursively(file) // , { f -> f.endsWith("java")})
|
||||
log(2, " Calculating checksum of ${files.size} files in $file")
|
||||
files.map {
|
||||
File(file, it)
|
||||
}.filter {
|
||||
it.isFile
|
||||
}.forEach {
|
||||
val bytes = it.readBytes()
|
||||
md5.update(bytes, 0, bytes.size)
|
||||
}
|
||||
}
|
||||
}
|
||||
val result = DatatypeConverter.printHexBinary(md5.digest()).toLowerCase()
|
||||
|
|
|
@ -157,10 +157,10 @@ class IncludedFile(val fromOriginal: From, val toOriginal: To, val specs: List<I
|
|||
"from", from,
|
||||
"to", to)
|
||||
|
||||
fun allFromFiles(directory: String): List<File> {
|
||||
fun allFromFiles(directory: String? = null): List<File> {
|
||||
val result = arrayListOf<File>()
|
||||
specs.forEach { spec ->
|
||||
val fullDir = KFiles.joinDir(directory, from)
|
||||
val fullDir = if (directory == null) from else KFiles.joinDir(directory, from)
|
||||
spec.toFiles(fullDir).forEach { source ->
|
||||
result.add(if (source.isAbsolute) source else File(source.path))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue