1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 08:27:12 -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 var noIncremental: Boolean = false
@Parameter(names = arrayOf("--parallel"), description = "Build all the projects in parallel whenever possible") @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") @Parameter(names = arrayOf("--plugins"), description = "Comma-separated list of plug-in Maven id's")
var pluginIds: String? = null var pluginIds: String? = null
@ -82,6 +82,9 @@ class Args {
@Parameter(names = arrayOf("--projectInfo"), description = "Display information about the current projects") @Parameter(names = arrayOf("--projectInfo"), description = "Display information about the current projects")
var projectInfo: Boolean = false 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") @Parameter(names = arrayOf("--server"), description = "Run in server mode")
var serverMode: Boolean = false var serverMode: Boolean = false

View file

@ -98,10 +98,10 @@ class BuildListeners : IBuildListener, IBuildReportContributor {
val message = val message =
if (hasFailures) { if (hasFailures) {
String.format("BUILD FAILED", buildTime) String.format("BUILD FAILED", buildTime)
} else if (args.parallel) { } else if (! args.sequential) {
val sequentialBuildTime = ((projectInfos.values.sumByDouble { it.durationMillis.toDouble() }) / 1000) val sequentialBuildTime = ((projectInfos.values.sumByDouble { it.durationMillis.toDouble() }) / 1000)
.toInt() .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) buildTime, sequentialBuildTime)
} else { } else {
String.format("BUILD SUCCESSFUL (%d SECONDS)", buildTime) 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) { override fun log(tag: CharSequence, level: Int, message: CharSequence, newLine: Boolean) {
if (args.parallel) { if (args.sequential) {
addLogLine(tag, LogLine(tag, level, message, Type.LOG, newLine))
} else {
kobaltLog(level, message, newLine) 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() logger.shutdown()
if (args.parallel) { if (! args.sequential) {
executor.dumpHistory() executor.dumpHistory()
} }
return TaskManager.RunTargetResult(taskResult, emptyList()) return TaskManager.RunTargetResult(taskResult, emptyList())

View file

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