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

Make parallel builds the default.

This commit is contained in:
Cedric Beust 2016-08-11 22:36:50 -08:00
parent 39c1b6f8d3
commit eb0b4b1e0f
5 changed files with 17 additions and 11 deletions

View file

@ -58,7 +58,7 @@ class Args {
var noIncremental: Boolean = false
@Parameter(names = arrayOf("--parallel"), description = "Build all the projects in parallel whenever possible")
var parallel: Boolean = false
var parallel: Boolean = true
@Parameter(names = arrayOf("--plugins"), description = "Comma-separated list of plug-in Maven id's")
var pluginIds: String? = null
@ -82,6 +82,9 @@ class Args {
@Parameter(names = arrayOf("--projectInfo"), description = "Display information about the current projects")
var projectInfo: Boolean = false
@Parameter(names = arrayOf("--sequential"), description = "Build all the projects in sequence")
var sequential: Boolean = false
@Parameter(names = arrayOf("--server"), description = "Run in server mode")
var serverMode: Boolean = false

View file

@ -98,10 +98,10 @@ class BuildListeners : IBuildListener, IBuildReportContributor {
val message =
if (hasFailures) {
String.format("BUILD FAILED", buildTime)
} else if (args.parallel) {
} else if (! args.sequential) {
val sequentialBuildTime = ((projectInfos.values.sumByDouble { it.durationMillis.toDouble() }) / 1000)
.toInt()
String.format("PARALLEL BUILD SUCCESSFUL (%d SECONDS), sequential build sould have taken %d seconds",
String.format("PARALLEL BUILD SUCCESSFUL (%d SECONDS), sequential build would have taken %d seconds",
buildTime, sequentialBuildTime)
} else {
String.format("BUILD SUCCESSFUL (%d SECONDS)", buildTime)

View file

@ -116,10 +116,10 @@ class ParallelLogger @Inject constructor(val args: Args) : ILogger {
}
override fun log(tag: CharSequence, level: Int, message: CharSequence, newLine: Boolean) {
if (args.parallel) {
addLogLine(tag, LogLine(tag, level, message, Type.LOG, newLine))
} else {
if (args.sequential) {
kobaltLog(level, message, newLine)
} else {
addLogLine(tag, LogLine(tag, level, message, Type.LOG, newLine))
}
}

View file

@ -105,7 +105,7 @@ class ParallelProjectRunner(val tasksByNames: (Project) -> ListMultimap<String,
logger.shutdown()
if (args.parallel) {
if (! args.sequential) {
executor.dumpHistory()
}
return TaskManager.RunTargetResult(taskResult, emptyList())

View file

@ -94,10 +94,13 @@ class TaskManager @Inject constructor(val args: Args,
val projectsToRun = findProjectsToRun(taskInfos, allProjects)
val projectRunner =
if (args.parallel) ParallelProjectRunner({ p -> tasksByNames(p) }, dependsOn,
reverseDependsOn, runBefore, runAfter, alwaysRunAfter, args, pluginInfo, kobaltLog)
else SequentialProjectRunner({ p -> tasksByNames(p) }, dependsOn,
reverseDependsOn, runBefore, runAfter, alwaysRunAfter, args, pluginInfo)
if (args.sequential) {
SequentialProjectRunner({ p -> tasksByNames(p) }, dependsOn,
reverseDependsOn, runBefore, runAfter, alwaysRunAfter, args, pluginInfo)
} else {
ParallelProjectRunner({ p -> tasksByNames(p) }, dependsOn,
reverseDependsOn, runBefore, runAfter, alwaysRunAfter, args, pluginInfo, kobaltLog)
}
return projectRunner.runProjects(taskInfos, projectsToRun)
}