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

Logging clean up.

This commit is contained in:
Cedric Beust 2016-08-09 02:11:43 -08:00
parent 8a672ad764
commit 8805e1c130
62 changed files with 336 additions and 320 deletions

View file

@ -1,6 +1,6 @@
package com.beust.kobalt
import com.beust.kobalt.misc.log
import com.beust.kobalt.misc.kobaltLog
import java.io.File
import java.nio.file.*
import java.nio.file.attribute.BasicFileAttributes
@ -28,15 +28,15 @@ sealed class IFileSpec {
private fun isIncluded(includeMatchers: Glob, excludes: List<Glob>, rel: Path) : Boolean {
excludes.forEach {
if (it.matches(rel)) {
log(3, "Excluding ${rel.toFile()}")
kobaltLog(3, "Excluding ${rel.toFile()}")
return false
}
}
if (includeMatchers.matches(rel)) {
log(3, "Including ${rel.toFile().path}")
kobaltLog(3, "Including ${rel.toFile().path}")
return true
}
log(2, "Excluding ${rel.toFile()} (not matching any include pattern")
kobaltLog(2, "Excluding ${rel.toFile()} (not matching any include pattern")
return false
}
@ -56,7 +56,7 @@ sealed class IFileSpec {
val path = p.normalize()
val rel = orgRootDir.relativize(path)
if (isIncluded(includes, excludes, path)) {
log(3, " including file " + rel.toFile() + " from rootDir $rootDir")
kobaltLog(3, " including file " + rel.toFile() + " from rootDir $rootDir")
result.add(rel.toFile())
}
return FileVisitResult.CONTINUE

View file

@ -36,16 +36,16 @@ class JarGenerator @Inject constructor(val dependencyManager: DependencyManager)
val normalized = Paths.get(file.path).normalize().toFile().path
includedSpecs.add(IFileSpec.FileSpec(normalized))
} else {
log(2, "Not adding ${file.path} to jar file because it's excluded")
kobaltLog(2, "Not adding ${file.path} to jar file because it's excluded")
}
}
} else {
log(2, "Directory $fromPath doesn't exist, not including it in the jar")
kobaltLog(2, "Directory $fromPath doesn't exist, not including it in the jar")
}
}
if (includedSpecs.size > 0) {
log(3, "Including specs $includedSpecs")
kobaltLog(3, "Including specs $includedSpecs")
result.add(IncludedFile(From(includedFile.from), To(includedFile.to), includedSpecs))
}
}
@ -95,7 +95,7 @@ class JarGenerator @Inject constructor(val dependencyManager: DependencyManager)
// If fatJar is true, add all the transitive dependencies as well: compile, runtime and dependent projects
//
if (jar.fatJar) {
log(2, "Finding included files for fat jar")
context.logger.log(project.name, 2, "Finding included files for fat jar")
val seen = hashSetOf<String>()
@Suppress("UNCHECKED_CAST")

View file

@ -1,6 +1,6 @@
package com.beust.kobalt
import com.beust.kobalt.misc.log
import com.beust.kobalt.misc.kobaltLog
import com.beust.kobalt.misc.warn
import java.io.File
import java.io.IOException
@ -93,7 +93,7 @@ public open class Jvm constructor(
// return false
// }
override public fun findExecutable(command: String): File {
override fun findExecutable(command: String): File {
if (javaHome != null) {
val jdkHome = if (javaHome!!.endsWith("jre")) javaHome!!.parentFile else javaHome
val exec = File(jdkHome, "bin/" + command)
@ -110,7 +110,7 @@ public open class Jvm constructor(
val pathExecutable = os.findInPath(command)
if (pathExecutable != null) {
log(2, "Unable to find the $command executable using home: " +
kobaltLog(2, "Unable to find the $command executable using home: " +
"$javaHome but found it on the PATH: $pathExecutable.")
return pathExecutable
}

View file

@ -8,10 +8,7 @@ import com.beust.kobalt.internal.PluginInfo
import com.beust.kobalt.internal.TaskManager
import com.beust.kobalt.maven.DependencyManager
import com.beust.kobalt.maven.LocalRepo
import com.beust.kobalt.misc.JarUtils
import com.beust.kobalt.misc.KFiles
import com.beust.kobalt.misc.KobaltExecutors
import com.beust.kobalt.misc.log
import com.beust.kobalt.misc.*
import com.google.inject.Provider
import java.io.File
import java.lang.reflect.Method
@ -65,7 +62,7 @@ class Plugins @Inject constructor (val taskManagerProvider : Provider<TaskManage
}
// Call apply() on each plug-in that accepts a project
log(2, "Applying plug-in \"${plugin.name}\"")
kobaltLog(2, "Applying plug-in \"${plugin.name}\"")
projects.filter { plugin.accept(it) }.forEach { project ->
plugin.apply(project, context)
}

View file

@ -6,7 +6,7 @@ import com.beust.kobalt.maven.MavenId
import com.beust.kobalt.maven.aether.KobaltAether
import com.beust.kobalt.misc.KobaltExecutors
import com.beust.kobalt.misc.Node
import com.beust.kobalt.misc.log
import com.beust.kobalt.misc.kobaltLog
import com.google.inject.Inject
import java.util.*
@ -42,7 +42,7 @@ class ResolveDependency @Inject constructor(
val seen = hashSetOf(dep.id)
root.addChildren(findChildren(root, seen))
log(1, AsciiArt.logBox(listOf(dep.id, url, dep.jarFile.get()).map { " $it" }))
kobaltLog(1, AsciiArt.logBox(listOf(dep.id, url, dep.jarFile.get()).map { " $it" }))
display(root.children)
println("")
@ -73,13 +73,13 @@ class ResolveDependency @Inject constructor(
if (! seen.contains(it.id)) {
val dep = Dep(it, root.value.level + 1)
val node = Node(dep)
log(2, "Found dependency ${dep.dep.id} level: ${dep.level}")
kobaltLog(2, "Found dependency ${dep.dep.id} level: ${dep.level}")
result.add(node)
seen.add(it.id)
node.addChildren(findChildren(node, seen))
}
}
log(2, "Children for ${root.value.dep.id}: ${result.size}")
kobaltLog(2, "Children for ${root.value.dep.id}: ${result.size}")
return result
}
}

View file

@ -2,9 +2,9 @@ package com.beust.kobalt
import com.beust.kobalt.api.*
import com.beust.kobalt.internal.ActorUtils
import com.beust.kobalt.internal.ParallelLogger
import com.beust.kobalt.internal.SourceSet
import com.beust.kobalt.misc.KFiles
import com.beust.kobalt.misc.log
import java.io.File
import java.util.*
@ -76,22 +76,21 @@ class Variant(val initialProductFlavor: ProductFlavorConfig? = null,
result.addAll(sourceDirectories)
} else {
// // The ordering of files is: 1) build type 2) product flavor 3) default
val kobaltLog = Kobalt.INJECTOR.getInstance(ParallelLogger::class.java)
buildType.let {
val dir = File(KFiles.joinDir("src", it.name, suffix))
log(3, "Adding source for build type ${it.name}: ${dir.path}")
kobaltLog.log(project.name, 3, "Adding source for build type ${it.name}: ${dir.path}")
result.add(dir)
}
productFlavor.let {
val dir = File(KFiles.joinDir("src", it.name, suffix))
log(3, "Adding source for product flavor ${it.name}: ${dir.path}")
kobaltLog.log(project.name, 3, "Adding source for product flavor ${it.name}: ${dir.path}")
result.add(dir)
}
result.addAll(allDirectories(project).map {
File(KFiles.joinDir("src", it, suffix))
}.filter {
it.exists()
})
result.addAll(allDirectories(project)
.map { File(KFiles.joinDir("src", it, suffix)) }
.filter(File::exists))
// Now that all the variant source directories have been added, add the project's default ones
result.addAll(sourceDirectories)
@ -175,7 +174,7 @@ class Variant(val initialProductFlavor: ProductFlavorConfig? = null,
val outputGeneratedSourceDirectory = File(result, pkg.replace('.', File.separatorChar))
val outputDir = File(outputGeneratedSourceDirectory, "BuildConfig." + contributor.buildConfigSuffix)
KFiles.saveFile(outputDir, code)
log(2, "Generated ${outputDir.path}")
context.logger.log(project.name, 2, "Generated ${outputDir.path}")
return result
} else {
throw KobaltException("Couldn't find a contributor to generateAndSave BuildConfig")

View file

@ -2,7 +2,7 @@ package com.beust.kobalt.api
import com.beust.kobalt.Args
import com.beust.kobalt.misc.KFiles
import com.beust.kobalt.misc.log
import com.beust.kobalt.misc.kobaltLog
import java.io.File
import java.io.FileOutputStream
import java.util.jar.JarInputStream
@ -22,7 +22,7 @@ abstract class JarTemplate(val jarName: String) : ITemplate {
continue
}
log(2, "Extracting: $entry to ${f.absolutePath}")
kobaltLog(2, "Extracting: $entry to ${f.absolutePath}")
FileOutputStream(f).use { fos ->
KFiles.copy(ins, fos)
}
@ -32,7 +32,7 @@ abstract class JarTemplate(val jarName: String) : ITemplate {
}
override fun generateTemplate(args: Args, classLoader: ClassLoader) {
log(2, "Generating template with class loader $classLoader")
kobaltLog(2, "Generating template with class loader $classLoader")
val destDir = File(".")
val ins = JarInputStream(classLoader.getResource(jarName).openConnection().inputStream)
extractFile(ins, destDir)

View file

@ -5,6 +5,7 @@ import com.beust.kobalt.api.annotation.Directive
import com.beust.kobalt.maven.DependencyManager
import com.beust.kobalt.maven.aether.KobaltAether
import com.beust.kobalt.misc.KFiles
import com.beust.kobalt.misc.kobaltLog
import com.beust.kobalt.misc.log
import org.apache.maven.model.Model
import java.io.File
@ -149,7 +150,7 @@ class Dependencies(val project: Project,
val resolved =
if (KobaltAether.isRangeVersion(it)) {
val result = Kobalt.INJECTOR.getInstance(KobaltAether::class.java).resolve(it).dependency.id
log(2, "Resolved range id $it to $result")
kobaltLog(2, "Resolved range id $it to $result")
result
} else {
it

View file

@ -36,7 +36,7 @@ class Archives {
try {
outputStreamFactory(FileOutputStream(result)).use {
JarUtils.addFiles(project.directory, includedFiles, it, expandJarFiles)
log(2, text = "Added ${includedFiles.size} files to $result")
context.logger.log(project.name, 2, "Added ${includedFiles.size} files to $result")
context.logger.log(project.name, 1, " Created $result")
}
} catch (e: Throwable) {
@ -47,7 +47,7 @@ class Archives {
}
} else {
log(3, " $result is up to date")
context.logger.log(project.name, 3, " $result is up to date")
}
project.projectProperties.put(JAR_NAME, result.absolutePath)
@ -68,7 +68,7 @@ class Archives {
File(KFiles.joinDir(directory, root.from, relFile.path))
if (file.isFile) {
if (file.lastModified() > lastModified) {
log(3, " TS - Outdated $file and $output "
kobaltLog(3, " TS - Outdated $file and $output "
+ Date(file.lastModified()) + " " + Date(output.lastModified()))
return true
}

View file

@ -3,7 +3,7 @@ package com.beust.kobalt.internal
import com.beust.kobalt.api.KobaltContext
import com.beust.kobalt.api.Project
import com.beust.kobalt.api.ProjectBuildStatus
import com.beust.kobalt.misc.log
import com.beust.kobalt.misc.kobaltLog
import com.google.common.annotations.VisibleForTesting
import com.google.common.collect.ArrayListMultimap
import com.google.common.collect.Multimap
@ -86,7 +86,7 @@ abstract class BaseProjectRunner {
val froms = nodeMap[from]
froms.forEach { f: T ->
nodeMap[to].forEach { t: T ->
log(LOG_LEVEL, " Adding edge ($text) $f -> $t")
kobaltLog(LOG_LEVEL, " Adding edge ($text) $f -> $t")
result.addEdge(f, t)
newToProcess.add(t)
}
@ -97,19 +97,19 @@ abstract class BaseProjectRunner {
* Whenever a task is added to the graph, we also add its alwaysRunAfter tasks.
*/
fun processAlways(always: Multimap<String, String>, node: T) {
log(LOG_LEVEL, " Processing always for $node")
kobaltLog(LOG_LEVEL, " Processing always for $node")
always[toName(node)]?.let { to: Collection<String> ->
to.forEach { t ->
nodeMap[t].forEach { from ->
log(LOG_LEVEL, " Adding always edge $from -> $node")
kobaltLog(LOG_LEVEL, " Adding always edge $from -> $node")
result.addEdge(from, node)
}
}
log(LOG_LEVEL, " ... done processing always for $node")
kobaltLog(LOG_LEVEL, " ... done processing always for $node")
}
}
log(LOG_LEVEL, " Current batch to process: $toProcess")
kobaltLog(LOG_LEVEL, " Current batch to process: $toProcess")
//
// Move dependsOn + reverseDependsOn in one multimap called allDepends
@ -131,7 +131,7 @@ abstract class BaseProjectRunner {
//
toProcess.forEach { taskInfo ->
val taskName = taskInfo.taskName
log(LOG_LEVEL, " ***** Current node: $taskName")
kobaltLog(LOG_LEVEL, " ***** Current node: $taskName")
nodeMap[taskName].forEach {
result.addNode(it)
processAlways(always, it)

View file

@ -3,6 +3,7 @@ package com.beust.kobalt.internal
import com.beust.kobalt.Args
import com.beust.kobalt.AsciiArt
import com.beust.kobalt.api.*
import com.beust.kobalt.misc.kobaltLog
import com.beust.kobalt.misc.log
import java.util.concurrent.ConcurrentHashMap
@ -63,11 +64,11 @@ class BuildListeners : IBuildListener, IBuildReportContributor {
val profiling = args.profiling
if (profiling) {
log(1, "\n" + AsciiArt.horizontalSingleLine + " Timings (in seconds)")
kobaltLog(1, "\n" + AsciiArt.horizontalSingleLine + " Timings (in seconds)")
timings.sortedByDescending { it.durationMillis }.forEach {
log(1, formatMillisRight(it.durationMillis, 10) + " " + it.taskName)
kobaltLog(1, formatMillisRight(it.durationMillis, 10) + " " + it.taskName)
}
log(1, "\n")
kobaltLog(1, "\n")
}
@ -90,7 +91,7 @@ class BuildListeners : IBuildListener, IBuildReportContributor {
table.append(" " + AsciiArt.verticalBar + " " + cl + " " + AsciiArt.verticalBar + "\n")
}
table.append(" " + AsciiArt.lowerBox(line.length))
log(1, table.toString())
kobaltLog(1, table.toString())
// }
}
@ -105,7 +106,7 @@ class BuildListeners : IBuildListener, IBuildReportContributor {
} else {
message.append(")")
}
log(1, message)
kobaltLog(1, message)
}

View file

@ -7,7 +7,6 @@ import com.beust.kobalt.maven.DependencyManager2
import com.beust.kobalt.maven.aether.Scope
import com.beust.kobalt.maven.dependency.FileDependency
import com.beust.kobalt.misc.KFiles
import com.beust.kobalt.misc.log
import com.google.inject.Inject
import java.io.File
import java.nio.file.Paths
@ -45,7 +44,8 @@ class CompilerUtils @Inject constructor(val files: KFiles,
failedResult = thisResult.failedResult
}
} else {
log(2, "${compiler.name} compiler not running on ${project.name} since no source files were found")
context.logger.log(project.name, 2,
"${compiler.name} compiler not running on ${project.name} since no source files were found")
}
return CompilerResult(results, failedResult)
@ -206,16 +206,17 @@ class CompilerUtils @Inject constructor(val files: KFiles,
val variantSourceDirs = context.variant.resourceDirectories(project, sourceSet)
if (variantSourceDirs.size > 0) {
JvmCompilerPlugin.lp(project, "Copying $sourceSet resources")
context.logger.log(project.name, 2, "Copying $sourceSet resources")
val absOutputDir = File(KFiles.joinDir(project.directory, project.buildDirectory, outputDir))
variantSourceDirs.map { File(project.directory, it.path) }.filter {
it.exists()
}.forEach {
log(2, "Copying from $it to $absOutputDir")
KFiles.copyRecursively(it, absOutputDir, deleteFirst = false)
}
variantSourceDirs
.map { File(project.directory, it.path) }
.filter(File::exists)
.forEach {
context.logger.log(project.name, 2, "Copying from $it to $absOutputDir")
KFiles.copyRecursively(it, absOutputDir, deleteFirst = false)
}
} else {
JvmCompilerPlugin.lp(project, "No resources to copy for $sourceSet")
context.logger.log(project.name, 2, "No resources to copy for $sourceSet")
}
}

View file

@ -5,7 +5,7 @@ import com.beust.kobalt.KobaltException
import com.beust.kobalt.TaskResult
import com.beust.kobalt.misc.NamedThreadFactory
import com.beust.kobalt.misc.error
import com.beust.kobalt.misc.log
import com.beust.kobalt.misc.kobaltLog
import com.google.common.collect.HashMultimap
import java.lang.reflect.InvocationTargetException
import java.util.*
@ -16,7 +16,7 @@ open class TaskResult2<T>(success: Boolean, errorMessage: String?, val value: T)
}
class DynamicGraph<T> {
val VERBOSE = 2
val VERBOSE = 3
val values : Collection<T> get() = nodes.map { it.value }
val nodes = hashSetOf<PrivateNode<T>>()
private val dependedUpon = HashMultimap.create<PrivateNode<T>, PrivateNode<T>>()
@ -90,7 +90,7 @@ class DynamicGraph<T> {
}
fun removeNode(t: T) = synchronized(nodes) {
log(VERBOSE, " Removing node $t")
kobaltLog(VERBOSE, " Removing node $t")
PrivateNode(t).let { node ->
nodes.remove(node)
dependingOn.removeAll(node)
@ -130,7 +130,7 @@ class DynamicGraph<T> {
}
}
val result = nodes.map { it.value }.filter { !nonFree.contains(it) }.toHashSet()
log(VERBOSE, " Free nodes: $result")
kobaltLog(VERBOSE, " Free nodes: $result")
return result
}
}
@ -236,19 +236,19 @@ class DynamicGraphExecutor<T>(val graph : DynamicGraph<T>, val factory: IThreadW
running--
if (taskResult.success) {
nodesRun.add(taskResult.value)
log(2, "Task succeeded: $taskResult")
kobaltLog(3, "Task succeeded: $taskResult")
graph.removeNode(taskResult.value)
newFreeNodes.clear()
newFreeNodes.addAll(graph.freeNodes.minus(nodesRun))
} else {
log(2, "Task failed: $taskResult")
kobaltLog(3, "Task failed: $taskResult")
newFreeNodes.clear()
if (failedResult == null) {
failedResult = taskResult
}
}
} catch(ex: TimeoutException) {
log(2, "Time out")
kobaltLog(3, "Time out")
} catch(ex: Exception) {
val ite = ex.cause
if (ite is InvocationTargetException) {
@ -268,7 +268,7 @@ class DynamicGraphExecutor<T>(val graph : DynamicGraph<T>, val factory: IThreadW
}
fun dumpHistory() {
log(1, "Thread report")
kobaltLog(1, "Thread report")
val table = AsciiTable.Builder()
.columnWidth(11)
@ -323,7 +323,7 @@ fun main(argv: Array<String>) {
return nodes.map {
object: IWorker<String> {
override fun call(): TaskResult2<String>? {
log(1, " Running worker $it")
kobaltLog(1, " Running worker $it")
return TaskResult2(true, null, it)
}

View file

@ -4,7 +4,6 @@ import com.beust.kobalt.*
import com.beust.kobalt.api.*
import com.beust.kobalt.maven.DependencyManager2
import com.beust.kobalt.misc.KFiles
import com.beust.kobalt.misc.log
import com.google.common.annotations.VisibleForTesting
import java.io.File
import java.util.*
@ -55,7 +54,7 @@ abstract class GenericTestRunner: ITestRunnerContributor {
// result
// }
log(2, "Found ${result.size} test classes")
context.logger.log(project.name, 2, "Found ${result.size} test classes")
return result.map { it.second }
}
@ -118,18 +117,18 @@ abstract class GenericTestRunner: ITestRunnerContributor {
val pb = ProcessBuilder(allArgs)
pb.directory(File(project.directory))
pb.inheritIO()
log(2, "Running tests with classpath size ${classpath.size}")
log(2, "Launching " + allArgs.joinToString(" "))
context.logger.log(project.name, 2, "Running tests with classpath size ${classpath.size}")
context.logger.log(project.name, 2, "Launching " + allArgs.joinToString(" "))
val process = pb.start()
val errorCode = process.waitFor()
if (errorCode == 0) {
log(1, "All tests passed")
context.logger.log(project.name, 1, "All tests passed")
} else {
log(1, "Test failures")
context.logger.log(project.name, 1, "Test failures")
}
result = result || errorCode == 0
} else {
log(1, " No tests to run")
context.logger.log(project.name, 1, " No tests to run")
result = true
}
} else {
@ -165,7 +164,7 @@ abstract class GenericTestRunner: ITestRunnerContributor {
}
if (result.any()) {
log(2, "Final JVM test flags after running the contributors and interceptors: $result")
context.logger.log(project.name, 2, "Final JVM test flags after running the contributors and interceptors: $result")
}
return result

View file

@ -7,7 +7,7 @@ import com.beust.kobalt.Variant
import com.beust.kobalt.api.Kobalt
import com.beust.kobalt.api.Project
import com.beust.kobalt.misc.KFiles
import com.beust.kobalt.misc.log
import com.beust.kobalt.misc.kobaltLog
import com.google.gson.Gson
import com.google.gson.GsonBuilder
import com.google.inject.Inject
@ -182,5 +182,5 @@ class IncrementalManager @Inject constructor(val args: Args, @Assisted val fileN
}
val LEVEL = 2
private fun logIncremental(level: Int, s: String) = log(level, " INC - $s")
private fun logIncremental(level: Int, s: String) = kobaltLog(level, " INC - $s")
}

View file

@ -12,7 +12,10 @@ import com.beust.kobalt.maven.DependencyManager
import com.beust.kobalt.maven.DependencyManager2
import com.beust.kobalt.maven.LocalRepo
import com.beust.kobalt.maven.Md5
import com.beust.kobalt.misc.*
import com.beust.kobalt.misc.KFiles
import com.beust.kobalt.misc.KobaltExecutors
import com.beust.kobalt.misc.error
import com.beust.kobalt.misc.warn
import java.io.File
import java.util.*
import javax.inject.Inject
@ -49,13 +52,6 @@ open class JvmCompilerPlugin @Inject constructor(
const val GROUP_TEST = "test"
const val GROUP_BUILD = "build"
const val GROUP_DOCUMENTATION = "documentation"
/**
* Log with a project.
*/
fun lp(project: Project, s: String) {
log(2, "${project.name}: $s")
}
}
override val name: String = PLUGIN_NAME
@ -86,7 +82,7 @@ open class JvmCompilerPlugin @Inject constructor(
}
private fun taskTest(project: Project, configName: String): TaskResult {
lp(project, "Running tests: $configName")
context.logger.log(project.name, 2, "Running tests: $configName")
val testContributor = ActorUtils.selectAffinityActor(project, context,
context.pluginInfo.testRunnerContributors)
@ -96,7 +92,8 @@ open class JvmCompilerPlugin @Inject constructor(
val compileDependencies = dependencyManager2.resolve(project, context, isTest = false)
return testContributor.run(project, context, configName, testDependencies + compileDependencies)
} else {
lp(project, "Couldn't find a test runner for project ${project.name}, did you specify dependenciesTest{}?")
context.logger.log(project.name, 2,
"Couldn't find a test runner for project ${project.name}, did you specify dependenciesTest{}?")
return TaskResult()
}
}

View file

@ -2,7 +2,7 @@ package com.beust.kobalt.internal
import com.beust.kobalt.KobaltException
import com.beust.kobalt.api.*
import com.beust.kobalt.misc.log
import com.beust.kobalt.misc.kobaltLog
import java.io.ByteArrayInputStream
import java.io.InputStream
import javax.xml.bind.JAXBContext
@ -123,7 +123,7 @@ class PluginInfo(val xml: KobaltPluginXml, val pluginClassLoader: ClassLoader?,
fun readKobaltPluginXml(): PluginInfo {
// Note: use forward slash here since we're looking up this file in a .jar file
val url = Kobalt::class.java.classLoader.getResource(PLUGIN_CORE_XML)
log(2, "URL for core kobalt-plugin.xml: $url")
kobaltLog(2, "URL for core kobalt-plugin.xml: $url")
if (url != null) {
return readPluginXml(url.openConnection().inputStream)
} else {
@ -139,7 +139,7 @@ class PluginInfo(val xml: KobaltPluginXml, val pluginClassLoader: ClassLoader?,
val jaxbContext = JAXBContext.newInstance(KobaltPluginXml::class.java)
val kobaltPlugin: KobaltPluginXml = jaxbContext.createUnmarshaller().unmarshal(ins)
as KobaltPluginXml
log(2, "Parsed plugin XML file, found: " + kobaltPlugin.name)
kobaltLog(2, "Parsed plugin XML file, found: " + kobaltPlugin.name)
val result =
try {
PluginInfo(kobaltPlugin, pluginClassLoader, classLoader)
@ -242,7 +242,7 @@ class PluginInfo(val xml: KobaltPluginXml, val pluginClassLoader: ClassLoader?,
* Add the content of @param[pluginInfo] to this pluginInfo.
*/
fun addPluginInfo(pluginInfo: PluginInfo) {
log(2, "Found new plug-in, adding it to pluginInfo: $pluginInfo")
kobaltLog(2, "Found new plug-in, adding it to pluginInfo: $pluginInfo")
plugins.addAll(pluginInfo.plugins)
classpathContributors.addAll(pluginInfo.classpathContributors)

View file

@ -3,6 +3,7 @@ package com.beust.kobalt.internal
import com.beust.kobalt.ProxyConfig
import com.beust.kobalt.homeDir
import com.beust.kobalt.misc.KFiles
import com.beust.kobalt.misc.kobaltLog
import com.beust.kobalt.misc.log
import com.google.inject.Inject
import com.google.inject.Singleton
@ -112,7 +113,7 @@ class KobaltSettings @Inject constructor(val xmlFile: KobaltSettingsXml) {
return result
}
} else {
log(2, "Couldn't find ${KobaltSettings.SETTINGS_FILE_PATH}, using default settings")
kobaltLog(2, "Couldn't find ${KobaltSettings.SETTINGS_FILE_PATH}, using default settings")
return KobaltSettings(KobaltSettingsXml())
}
}

View file

@ -12,7 +12,7 @@ import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.ConcurrentLinkedQueue
interface ILogger {
fun log(tag: CharSequence, level: Int, message: CharSequence)
fun log(tag: CharSequence, level: Int, message: CharSequence, newLine: Boolean = true)
}
/**
@ -28,7 +28,8 @@ interface ILogger {
class ParallelLogger @Inject constructor(val args: Args) : ILogger {
enum class Type { LOG, WARN, ERROR }
class LogLine(val name: CharSequence? = null, val level: Int, val message: CharSequence, val type: Type)
class LogLine(val name: CharSequence? = null, val level: Int, val message: CharSequence, val type: Type,
val newLine: Boolean)
private val logLines = ConcurrentHashMap<CharSequence, ArrayList<LogLine>>()
private val runningProjects = ConcurrentLinkedQueue<String>()
@ -82,7 +83,7 @@ class ParallelLogger @Inject constructor(val args: Args) : ILogger {
val time = System.currentTimeMillis() - startTime!!
val m = (if (args.dev) "### [$time] " else "") + ll.message
when(ll.type) {
Type.LOG -> kobaltLog(ll.level, m)
Type.LOG -> kobaltLog(ll.level, m, ll.newLine)
Type.WARN -> kobaltWarn(m)
Type.ERROR -> kobaltError(m)
}
@ -114,11 +115,11 @@ class ParallelLogger @Inject constructor(val args: Args) : ILogger {
}
}
override fun log(tag: CharSequence, level: Int, message: CharSequence) {
override fun log(tag: CharSequence, level: Int, message: CharSequence, newLine: Boolean) {
if (args.parallel) {
addLogLine(tag, LogLine(tag, level, message, Type.LOG))
addLogLine(tag, LogLine(tag, level, message, Type.LOG, newLine))
} else {
kobaltLog(level, message)
kobaltLog(level, message, newLine)
}
}

View file

@ -7,6 +7,7 @@ import com.beust.kobalt.api.ITask
import com.beust.kobalt.api.Kobalt
import com.beust.kobalt.api.Project
import com.beust.kobalt.api.ProjectBuildStatus
import com.beust.kobalt.misc.kobaltLog
import com.google.common.collect.ListMultimap
import com.google.common.collect.TreeMultimap
import java.util.concurrent.Callable
@ -22,7 +23,7 @@ class ParallelProjectRunner(val tasksByNames: (Project) -> ListMultimap<String,
val reverseDependsOn: TreeMultimap<String, String>, val runBefore: TreeMultimap<String, String>,
val runAfter: TreeMultimap<String, String>,
val alwaysRunAfter: TreeMultimap<String, String>, val args: Args, val pluginInfo: PluginInfo,
val kobaltLog: ParallelLogger)
val logger: ParallelLogger)
: BaseProjectRunner() {
override fun runProjects(taskInfos: List<TaskManager.TaskInfo>, projects: List<Project>)
: TaskManager .RunTargetResult {
@ -42,7 +43,7 @@ class ParallelProjectRunner(val tasksByNames: (Project) -> ListMultimap<String,
ITask::name,
{ task: ITask -> task.plugin.accept(project) })
var lastResult = TaskResult()
kobaltLog.onProjectStarted(project.name)
logger.onProjectStarted(project.name)
context.logger.log(project.name, 1, AsciiArt.logBox("Building ${project.name}", indent = 5))
while (graph.freeNodes.any()) {
val toProcess = graph.freeNodes
@ -51,7 +52,7 @@ class ParallelProjectRunner(val tasksByNames: (Project) -> ListMultimap<String,
tasks.forEach { task ->
runBuildListenersForTask(project, context, task.name, start = true)
kobaltLog.log(project.name, 1,
logger.log(project.name, 1,
AsciiArt.taskColor(AsciiArt.horizontalSingleLine + " ${project.name}:${task.name}"))
val thisResult = if (dryRun) TaskResult2(true, null, task) else task.call()
if (lastResult.success) {
@ -64,7 +65,7 @@ class ParallelProjectRunner(val tasksByNames: (Project) -> ListMultimap<String,
graph.freeNodes.forEach { graph.removeNode(it) }
}
kobaltLog.onProjectStopped(project.name)
logger.onProjectStopped(project.name)
runBuildListenersForProject(project, context, false,
if (lastResult.success) ProjectBuildStatus.SUCCESS else ProjectBuildStatus.FAILED)
@ -99,9 +100,10 @@ class ParallelProjectRunner(val tasksByNames: (Project) -> ListMultimap<String,
}
val executor = DynamicGraphExecutor(projectGraph, factory, 5)
kobaltLog(1, "Parallel build starting")
val taskResult = executor.run()
kobaltLog.shutdown()
logger.shutdown()
if (args.parallel) {
executor.dumpHistory()

View file

@ -9,7 +9,6 @@ import com.beust.kobalt.api.Project
import com.beust.kobalt.api.ProjectBuildStatus
import com.beust.kobalt.misc.Strings
import com.beust.kobalt.misc.kobaltError
import com.beust.kobalt.misc.log
import com.google.common.collect.ListMultimap
import com.google.common.collect.TreeMultimap
import java.util.*
@ -33,14 +32,17 @@ class SequentialProjectRunner(val tasksByNames: (Project) -> ListMultimap<String
val messages = Collections.synchronizedList(arrayListOf<TaskManager.ProfilerInfo>())
val context = Kobalt.context!!
projects.forEach { project ->
log(1, AsciiArt.logBox("Building ${project.name}", indent = 5))
val projectName = project.name
fun klog(level: Int, message: String) = context.logger.log(projectName, level, message)
klog(1, AsciiArt.logBox("Building $projectName", indent = 5))
// Does the current project depend on any failed projects?
val fp = project.dependsOn.filter { failedProjects.contains(it.name) }.map(Project::name)
if (fp.size > 0) {
log(2, "Marking project ${project.name} as skipped")
klog(2, "Marking project $projectName as skipped")
failedProjects.add(project.name)
runBuildListenersForProject(project, context, false, ProjectBuildStatus.SKIPPED)
kobaltError("Not building project ${project.name} since it depends on failed "
@ -53,9 +55,9 @@ class SequentialProjectRunner(val tasksByNames: (Project) -> ListMultimap<String
// define "install"), so use a multimap
val tasksByNames = tasksByNames(project)
log(3, "Tasks:")
klog(3, "Tasks:")
tasksByNames.keys().forEach {
log(3, " $it: " + tasksByNames.get(it))
klog(3, " $it: " + tasksByNames.get(it))
}
val graph = createTaskGraph(project.name, taskInfos, tasksByNames,
@ -66,7 +68,7 @@ class SequentialProjectRunner(val tasksByNames: (Project) -> ListMultimap<String
//
// Now that we have a full graph, run it
//
log(2, "About to run graph:\n ${graph.dump()} ")
klog(2, "About to run graph:\n ${graph.dump()} ")
val factory = object : IThreadWorkerFactory<ITask> {
override fun createWorkers(nodes: Collection<ITask>)
@ -76,7 +78,7 @@ class SequentialProjectRunner(val tasksByNames: (Project) -> ListMultimap<String
val executor = DynamicGraphExecutor(graph, factory)
val thisResult = executor.run()
if (! thisResult.success) {
log(2, "Marking project ${project.name} as failed")
klog(2, "Marking project ${project.name} as failed")
failedProjects.add(project.name)
}

View file

@ -5,7 +5,7 @@ import com.beust.kobalt.api.*
import com.beust.kobalt.api.annotation.IncrementalTask
import com.beust.kobalt.api.annotation.Task
import com.beust.kobalt.misc.Topological
import com.beust.kobalt.misc.log
import com.beust.kobalt.misc.kobaltLog
import com.google.common.collect.ArrayListMultimap
import com.google.common.collect.ListMultimap
import com.google.common.collect.TreeMultimap
@ -240,7 +240,7 @@ class TaskManager @Inject constructor(val args: Args,
val method = staticTask.method
val methodName = method.declaringClass.toString() + "." + method.name
log(3, " Found task:${staticTask.name} method: $methodName")
kobaltLog(3, " Found task:${staticTask.name} method: $methodName")
val plugin = staticTask.plugin
projects.filter { plugin.accept(it) }.forEach { project ->
@ -303,7 +303,7 @@ class TaskWorker(val tasks: List<ITask>, val dryRun: Boolean, val pluginInfo: Pl
override fun call() : TaskResult2<ITask> {
if (tasks.size > 0) {
tasks[0].let {
log(1, AsciiArt.taskColor(AsciiArt.horizontalSingleLine + " ${it.project.name}:${it.name}"))
kobaltLog(1, AsciiArt.taskColor(AsciiArt.horizontalSingleLine + " ${it.project.name}:${it.name}"))
}
}
var success = true

View file

@ -2,7 +2,7 @@ package com.beust.kobalt.maven
import com.beust.kobalt.OperatingSystem
import com.beust.kobalt.misc.error
import com.beust.kobalt.misc.log
import com.beust.kobalt.misc.kobaltLog
import com.beust.kobalt.misc.warn
import com.google.inject.Singleton
import java.io.BufferedReader
@ -47,7 +47,7 @@ public class Gpg {
val pb = ProcessBuilder(allArgs)
pb.directory(directory)
log(2, "Signing file: " + allArgs.joinToString(" "))
kobaltLog(2, "Signing file: " + allArgs.joinToString(" "))
val process = pb.start()
val br = BufferedReader(InputStreamReader(process.errorStream))

View file

@ -3,6 +3,7 @@ package com.beust.kobalt.maven
import com.beust.kobalt.KobaltException
import com.beust.kobalt.internal.KobaltSettings
import com.beust.kobalt.misc.CountingFileRequestBody
import com.beust.kobalt.misc.kobaltLog
import com.beust.kobalt.misc.log
import com.google.inject.Inject
import okhttp3.*
@ -41,7 +42,7 @@ class Http @Inject constructor(val settings:KobaltSettings) {
fun percentProgressCallback(totalSize: Long) : (Long) -> Unit {
return { num: Long ->
val progress = num * 100 / totalSize
log(1, "\rUploaded: $progress%", newLine = false)
kobaltLog(1, "\rUploaded: $progress%", newLine = false)
}
}
@ -74,7 +75,7 @@ class Http @Inject constructor(val settings:KobaltSettings) {
requestBuilder.put(CountingFileRequestBody(file.file, file.mimeType, progressCallback)))
.build()
log(2, "Uploading $file to $url")
kobaltLog(2, "Uploading $file to $url")
val response = OkHttpClient.Builder().proxy(settings.proxyConfigs?.firstOrNull()?.toProxy()).build().newCall(request).execute()
if (! response.isSuccessful) {
error(response)

View file

@ -1,7 +1,7 @@
package com.beust.kobalt.maven
import com.beust.kobalt.misc.KFiles
import com.beust.kobalt.misc.log
import com.beust.kobalt.misc.kobaltLog
import java.io.File
import java.security.MessageDigest
import javax.xml.bind.DatatypeConverter
@ -31,13 +31,13 @@ public class Md5 {
var fileCount = 0
filesOrDirectories.filter { it.exists() }.forEach { file ->
if (file.isFile) {
log(2, " Calculating checksum of $file")
kobaltLog(2, " Calculating checksum of $file")
val bytes = toBytes(file)
md5.update(bytes, 0, bytes.size)
fileCount++
} else {
val files = KFiles.findRecursively(file) // , { f -> f.endsWith("java")})
log(2, " Calculating checksum of ${files.size} files in $file")
kobaltLog(2, " Calculating checksum of ${files.size} files in $file")
files.map {
File(file, it)
}.filter {

View file

@ -3,7 +3,7 @@ package com.beust.kobalt.maven
import com.beust.kobalt.SystemProperties
import com.beust.kobalt.api.Project
import com.beust.kobalt.misc.KFiles
import com.beust.kobalt.misc.log
import com.beust.kobalt.misc.kobaltLog
import com.google.inject.assistedinject.Assisted
import org.apache.maven.model.Developer
import org.apache.maven.model.Model
@ -30,7 +30,7 @@ class PomGenerator @Inject constructor(@Assisted val project: Project) {
val pomFile = SimpleDep(mavenId).toPomFileName()
val outputFile = File(outputDir, pomFile)
outputFile.writeText(generate(), Charset.defaultCharset())
log(1, " Created $outputFile")
kobaltLog(1, " Created $outputFile")
}
/**

View file

@ -12,7 +12,7 @@ import com.beust.kobalt.maven.LocalDep
import com.beust.kobalt.maven.LocalRepo
import com.beust.kobalt.maven.MavenId
import com.beust.kobalt.misc.Versions
import com.beust.kobalt.misc.log
import com.beust.kobalt.misc.kobaltLog
import com.beust.kobalt.misc.warn
import com.google.common.eventbus.EventBus
import com.google.inject.Inject
@ -102,7 +102,7 @@ class KobaltAether @Inject constructor (val settings: KobaltSettings, val aether
fun resolve(id: String, artifactScope: Scope? = null, filterScopes: Collection<Scope> = emptyList())
: DependencyResult {
log(ConsoleRepositoryListener.LOG_LEVEL, "Resolving $id")
kobaltLog(ConsoleRepositoryListener.LOG_LEVEL, "Resolving $id")
val result = resolveToArtifact(id, artifactScope, filterScopes)
if (result != null) {
return DependencyResult(AetherDependency(result.artifact), result.repository.toString())
@ -113,7 +113,7 @@ class KobaltAether @Inject constructor (val settings: KobaltSettings, val aether
fun resolveToArtifact(id: String, artifactScope: Scope? = null, filterScopes: Collection<Scope> = emptyList())
: AetherResult? {
log(ConsoleRepositoryListener.LOG_LEVEL, "Resolving $id")
kobaltLog(ConsoleRepositoryListener.LOG_LEVEL, "Resolving $id")
val results = aether.resolve(DefaultArtifact(MavenId.toKobaltId(id)), artifactScope, filterScopes)
if (results.size > 0) {
return results[0]
@ -287,11 +287,11 @@ class AetherDependency(val artifact: Artifact) : IClasspathDependency, Comparabl
if (!it.dependency.isOptional) {
result.add(AetherDependency(it.artifact))
} else {
log(ConsoleRepositoryListener.LOG_LEVEL, "Skipping optional dependency " + deps.root.artifact)
kobaltLog(ConsoleRepositoryListener.LOG_LEVEL, "Skipping optional dependency " + deps.root.artifact)
}
}
} else {
log(ConsoleRepositoryListener.LOG_LEVEL, "Skipping optional dependency " + deps.root.artifact)
kobaltLog(ConsoleRepositoryListener.LOG_LEVEL, "Skipping optional dependency " + deps.root.artifact)
}
} else {
warn("Couldn't resolve $artifact")

View file

@ -1,7 +1,7 @@
package com.beust.kobalt.maven.aether
import com.beust.kobalt.internal.eventbus.ArtifactDownloadedEvent
import com.beust.kobalt.misc.log
import com.beust.kobalt.misc.kobaltLog
import com.google.common.eventbus.EventBus
import org.eclipse.aether.AbstractRepositoryListener
import org.eclipse.aether.RepositoryEvent
@ -23,76 +23,76 @@ class ConsoleRepositoryListener @JvmOverloads constructor(out: PrintStream? = nu
}
override fun artifactDeployed(event: RepositoryEvent?) {
log(LOG_LEVEL, "Deployed " + event!!.artifact + " to " + event.repository)
kobaltLog(LOG_LEVEL, "Deployed " + event!!.artifact + " to " + event.repository)
}
override fun artifactDeploying(event: RepositoryEvent?) {
log(LOG_LEVEL, "Deploying " + event!!.artifact + " to " + event.repository)
kobaltLog(LOG_LEVEL, "Deploying " + event!!.artifact + " to " + event.repository)
}
override fun artifactDescriptorInvalid(event: RepositoryEvent?) {
log(LOG_LEVEL, "Invalid artifact descriptor for " + event!!.artifact + ": "
kobaltLog(LOG_LEVEL, "Invalid artifact descriptor for " + event!!.artifact + ": "
+ event.exception.message)
}
override fun artifactDescriptorMissing(event: RepositoryEvent?) {
log(LOG_LEVEL, "Missing artifact descriptor for " + event!!.artifact)
kobaltLog(LOG_LEVEL, "Missing artifact descriptor for " + event!!.artifact)
}
override fun artifactInstalled(event: RepositoryEvent?) {
log(LOG_LEVEL, "Installed " + event!!.artifact + " to " + event.file)
kobaltLog(LOG_LEVEL, "Installed " + event!!.artifact + " to " + event.file)
}
override fun artifactInstalling(event: RepositoryEvent?) {
log(LOG_LEVEL, "Installing " + event!!.artifact + " to " + event.file)
kobaltLog(LOG_LEVEL, "Installing " + event!!.artifact + " to " + event.file)
}
override fun artifactResolved(event: RepositoryEvent?) {
log(LOG_LEVEL, "Resolved artifact " + event!!.artifact + " from " + event.repository)
kobaltLog(LOG_LEVEL, "Resolved artifact " + event!!.artifact + " from " + event.repository)
}
override fun artifactDownloading(event: RepositoryEvent?) {
log(LOG_LEVEL, "Downloading artifact " + event!!.artifact + " from " + event.repository)
kobaltLog(LOG_LEVEL, "Downloading artifact " + event!!.artifact + " from " + event.repository)
}
override fun artifactDownloaded(event: RepositoryEvent?) {
if (event?.file != null && event?.artifact != null) {
val artifact = event!!.artifact
log(1, "Downloaded artifact " + artifact + " from " + event.repository)
kobaltLog(1, "Downloaded artifact " + artifact + " from " + event.repository)
eventBus.post(ArtifactDownloadedEvent(artifact.toString(), event.repository))
}
}
override fun artifactResolving(event: RepositoryEvent?) {
log(LOG_LEVEL, "Resolving artifact " + event!!.artifact)
kobaltLog(LOG_LEVEL, "Resolving artifact " + event!!.artifact)
}
override fun metadataDeployed(event: RepositoryEvent?) {
log(LOG_LEVEL, "Deployed " + event!!.metadata + " to " + event.repository)
kobaltLog(LOG_LEVEL, "Deployed " + event!!.metadata + " to " + event.repository)
}
override fun metadataDeploying(event: RepositoryEvent?) {
log(LOG_LEVEL, "Deploying " + event!!.metadata + " to " + event.repository)
kobaltLog(LOG_LEVEL, "Deploying " + event!!.metadata + " to " + event.repository)
}
override fun metadataInstalled(event: RepositoryEvent?) {
log(LOG_LEVEL, "Installed " + event!!.metadata + " to " + event.file)
kobaltLog(LOG_LEVEL, "Installed " + event!!.metadata + " to " + event.file)
}
override fun metadataInstalling(event: RepositoryEvent?) {
log(LOG_LEVEL, "Installing " + event!!.metadata + " to " + event.file)
kobaltLog(LOG_LEVEL, "Installing " + event!!.metadata + " to " + event.file)
}
override fun metadataInvalid(event: RepositoryEvent?) {
log(LOG_LEVEL, "Invalid metadata " + event!!.metadata)
kobaltLog(LOG_LEVEL, "Invalid metadata " + event!!.metadata)
}
override fun metadataResolved(event: RepositoryEvent?) {
log(LOG_LEVEL, "Resolved metadata " + event!!.metadata + " from " + event.repository)
kobaltLog(LOG_LEVEL, "Resolved metadata " + event!!.metadata + " from " + event.repository)
}
override fun metadataResolving(event: RepositoryEvent?) {
log(LOG_LEVEL, "Resolving metadata " + event!!.metadata + " from " + event.repository)
kobaltLog(LOG_LEVEL, "Resolving metadata " + event!!.metadata + " from " + event.repository)
}
}

View file

@ -1,7 +1,7 @@
package com.beust.kobalt.maven.aether
import com.beust.kobalt.misc.KobaltLogger
import com.beust.kobalt.misc.log
import com.beust.kobalt.misc.kobaltLog
import org.eclipse.aether.transfer.AbstractTransferListener
import org.eclipse.aether.transfer.MetadataNotFoundException
import org.eclipse.aether.transfer.TransferEvent
@ -27,7 +27,7 @@ class ConsoleTransferListener @JvmOverloads constructor(out: PrintStream? = null
override fun transferInitiated(event: TransferEvent?) {
val message = if (event!!.requestType == TransferEvent.RequestType.PUT) "Uploading" else "Downloading"
log(2, message + ": " + event.resource.repositoryUrl + event.resource.resourceName)
kobaltLog(2, message + ": " + event.resource.repositoryUrl + event.resource.resourceName)
}
override fun transferProgressed(event: TransferEvent?) {
@ -92,7 +92,7 @@ class ConsoleTransferListener @JvmOverloads constructor(out: PrintStream? = null
throughput = " at " + format.format(kbPerSec) + " KB/sec"
}
log(2, type + ": " + resource.repositoryUrl + resource.resourceName + " (" + len
kobaltLog(2, type + ": " + resource.repositoryUrl + resource.resourceName + " (" + len
+ throughput + ")")
}
}

View file

@ -38,17 +38,17 @@ class CheckVersions @Inject constructor(val depManager: DependencyManager,
newVersions.add(artifact.groupId + ":" + artifact.artifactId + ":" + highest)
}
} catch(e: KobaltException) {
log(1, " Cannot resolve ${dep.shortId}. ignoring")
kobaltLog(1, " Cannot resolve ${dep.shortId}. ignoring")
}
}
}
}
if (newVersions.size > 0) {
log(1, " New versions found:")
newVersions.forEach { log(1, " $it") }
kobaltLog(1, " New versions found:")
newVersions.forEach { kobaltLog(1, " $it") }
} else {
log(1, " All dependencies up to date")
kobaltLog(1, " All dependencies up to date")
}
executor.shutdown()
}

View file

@ -70,7 +70,7 @@ class GithubApi2 @Inject constructor(
class RetrofitError(var message: String = "", var errors : List<Error> = arrayListOf())
fun uploadRelease(packageName: String, tagName: String, zipFile: File) {
log(1, "Uploading release ${zipFile.name}")
kobaltLog(1, "Uploading release ${zipFile.name}")
val username = localProperties.get(PROPERTY_USERNAME, DOC_URL)
val accessToken = localProperties.get(PROPERTY_ACCESS_TOKEN, DOC_URL)
@ -86,7 +86,7 @@ class GithubApi2 @Inject constructor(
uploadAsset(accessToken, body.uploadUrl!!, Http.TypedFile("application/zip", zipFile), tagName)
.toBlocking()
.forEach { action ->
log(1, "\n${zipFile.name} successfully uploaded")
kobaltLog(1, "\n${zipFile.name} successfully uploaded")
}
}
}
@ -131,7 +131,7 @@ class GithubApi2 @Inject constructor(
warn("Didn't receive any body in the response to GitHub.getReleases()")
}
} catch(e: Exception) {
log(1, "Couldn't retrieve releases from github: " + e.message)
kobaltLog(1, "Couldn't retrieve releases from github: " + e.message)
e.printStackTrace()
// val error = parseRetrofitError(e)
// val details = if (error.errors != null) {
@ -141,7 +141,7 @@ class GithubApi2 @Inject constructor(
// }
// // TODO: If the credentials didn't work ("bad credentials"), should start again
// // using cbeust/kobalt, like above. Right now, just bailing.
// log(2, "Couldn't retrieve releases from github, ${error.message ?: e}: "
// kobaltLog(2, "Couldn't retrieve releases from github, ${error.message ?: e}: "
// + details?.code + " field: " + details?.field)
}
result

View file

@ -7,14 +7,14 @@ import java.nio.file.StandardCopyOption
class Io(val dryRun: Boolean = false) {
fun mkdirs(dir: String) {
log("mkdirs $dir")
kobaltLog("mkdirs $dir")
if (! dryRun) {
File(dir).mkdirs()
}
}
fun rm(path: String) {
log("rm $path")
kobaltLog("rm $path")
if (! dryRun) {
File(path).deleteRecursively()
@ -22,7 +22,7 @@ class Io(val dryRun: Boolean = false) {
}
fun moveFile(from: File, toDir: File) {
log("mv $from $toDir")
kobaltLog("mv $from $toDir")
if (! dryRun) {
require(from.exists(), { -> "$from should exist" })
require(from.isFile, { -> "$from should be a file" })
@ -34,7 +34,7 @@ class Io(val dryRun: Boolean = false) {
}
fun rename(from: File, to: File) {
log("rename $from $to")
kobaltLog("rename $from $to")
moveFile(from, to.parentFile)
if (from.name != to.name) {
File(to, from.name).renameTo(to)
@ -42,7 +42,7 @@ class Io(val dryRun: Boolean = false) {
}
fun copyDirectory(from: File, toDir: File) {
log("cp -r $from $toDir")
kobaltLog("cp -r $from $toDir")
if (! dryRun) {
KFiles.copyRecursively(from, toDir)
@ -56,7 +56,7 @@ class Io(val dryRun: Boolean = false) {
fun rmDir(dir: File, keep: (File) -> Boolean = { t -> false }) = rmDir(dir, keep, " ")
private fun rmDir(dir: File, keep: (File) -> Boolean, indent : String) {
log("rm -rf $dir")
kobaltLog("rm -rf $dir")
require(dir.isDirectory, { -> println("$dir should be a directory")})
@ -66,21 +66,21 @@ class Io(val dryRun: Boolean = false) {
it.deleteRecursively()
}
else {
log(indent + "rm $it")
kobaltLog(indent + "rm $it")
if (! dryRun) it.delete()
}
}
}
fun mkdir(dir: File) {
log("mkdir $dir")
kobaltLog("mkdir $dir")
if (! dryRun) {
dir.mkdirs()
}
}
private fun log(s: String) {
log(1, "[Io] $s")
private fun kobaltLog(s: String) {
kobaltLog(1, "[Io] $s")
}
}

View file

@ -47,14 +47,14 @@ public class JarUtils {
}
if (foundFile.isDirectory) {
log(2, " Writing contents of directory $foundFile")
kobaltLog(2, " Writing contents of directory $foundFile")
// Directory
val includedFile = IncludedFile(From(""), To(""), listOf(IFileSpec.GlobSpec("**")))
addSingleFile(localFile.path, includedFile, outputStream, expandJarFiles)
} else {
if (file.expandJarFiles && foundFile.name.endsWith(".jar") && ! file.from.contains("resources")) {
log(2, " Writing contents of jar file $foundFile")
kobaltLog(2, " Writing contents of jar file $foundFile")
val stream = JarInputStream(FileInputStream(localFile))
var entry = stream.nextEntry
while (entry != null) {
@ -100,7 +100,7 @@ public class JarUtils {
while (enumEntries.hasMoreElements()) {
val file = enumEntries.nextElement()
if (file.name == fileName) {
log(2, "Found $fileName in ${zip.name}")
kobaltLog(2, "Found $fileName in ${zip.name}")
zip.getInputStream(file).use { ins ->
return CharStreams.toString(InputStreamReader(ins, "UTF-8"))
}

View file

@ -135,7 +135,7 @@ class KFiles {
val seen = hashSetOf<java.nio.file.Path>()
allDirs.forEach { dir ->
if (! dir.exists()) {
log(2, "Couldn't find directory $dir")
kobaltLog(2, "Couldn't find directory $dir")
} else {
val files = findRecursively(dir, function)
files.map { Paths.get(it) }.forEach {
@ -144,7 +144,7 @@ class KFiles {
result.add(File(dir, rel.toFile().path).path)
seen.add(rel)
} else {
log(2, "Skipped file already seen in previous flavor: $rel")
kobaltLog(2, "Skipped file already seen in previous flavor: $rel")
}
}
}
@ -212,7 +212,7 @@ class KFiles {
dstFile.mkdirs()
} else {
if (Features.USE_TIMESTAMPS && dstFile.exists() && Md5.toMd5(src) == Md5.toMd5(dstFile)) {
log(3, " Identical files, not copying $src to $dstFile")
kobaltLog(3, " Identical files, not copying $src to $dstFile")
} else {
val target = src.copyTo(dstFile, true)
if (target.length() != src.length()) {
@ -242,34 +242,34 @@ class KFiles {
*/
fun findBuildScriptLocation(buildFile: BuildFile, jarFile: String) : String {
val result = joinDir(buildFile.dotKobaltDir.absolutePath, KFiles.SCRIPT_BUILD_DIR, jarFile)
log(2, "Script jar file: $result")
kobaltLog(2, "Script jar file: $result")
return result
}
fun saveFile(file: File, text: String) {
file.absoluteFile.parentFile.mkdirs()
file.writeText(text)
log(2, "Created $file")
kobaltLog(2, "Created $file")
}
private fun isWindows() = System.getProperty("os.name").contains("Windows");
fun copy(from: Path?, to: Path?, option: StandardCopyOption = StandardCopyOption.REPLACE_EXISTING) {
if (isWindows() && to!!.toFile().exists()) {
log(2, "Windows detected, not overwriting $to")
kobaltLog(2, "Windows detected, not overwriting $to")
} else {
try {
if (from != null && to != null) {
if (!Files.exists(to) || Md5.toMd5(from.toFile()) != Md5.toMd5(to.toFile())) {
log(3, "Copy from $from to $to")
kobaltLog(3, "Copy from $from to $to")
Files.copy(from, to, option)
} else {
log(3, " Not copying, indentical files: $from $to")
kobaltLog(3, " Not copying, indentical files: $from $to")
}
}
} catch(ex: IOException) {
// Windows is anal about this
log(1, "Couldn't copy $from to $to: ${ex.message}")
kobaltLog(1, "Couldn't copy $from to $to: ${ex.message}")
}
}
}
@ -326,7 +326,7 @@ class KFiles {
false
})
} else {
log(3, "Skipping nonexistent source directory $sourceDir")
kobaltLog(3, "Skipping nonexistent source directory $sourceDir")
}
}
return result

View file

@ -66,14 +66,14 @@ class KobaltExecutors {
progress(r)
result.add(r)
remainingMs -= (System.currentTimeMillis() - start)
log(3, "Received $r, remaining: $remainingMs ms")
kobaltLog(3, "Received $r, remaining: $remainingMs ms")
i++
}
if (remainingMs < 0) {
warn("Didn't receive all the results in time: $i / ${tasks.size}")
} else {
log(2, "Received all results in ${maxMs - remainingMs} ms")
kobaltLog(2, "Received all results in ${maxMs - remainingMs} ms")
}
executor.shutdown()

View file

@ -16,7 +16,7 @@ class KobaltWrapperProperties @Inject constructor() {
private val PROPERTY_DOWNLOAD_URL = "kobalt.downloadUrl"
fun create(version: String) {
log(2, "Creating $file with $version and ${defaultUrlFor(version)}")
kobaltLog(2, "Creating $file with $version and ${defaultUrlFor(version)}")
KFiles.saveFile(file, listOf(
"$PROPERTY_VERSION=$version"
// "$PROPERTY_DOWNLOAD_URL=${defaultUrlFor(version)}"

View file

@ -45,7 +45,8 @@ open class NewRunCommand(val info: RunCommandInfo) {
companion object {
val DEFAULT_SUCCESS = { output: List<String> -> }
// val DEFAULT_SUCCESS_VERBOSE = { output: List<String> -> log(2, "Success:\n " + output.joinToString("\n"))}
// val DEFAULT_SUCCESS_VERBOSE = { output: List<String> -> kobaltLog(2, "Success:\n " + output.joinToString
// ("\n"))}
// val defaultSuccess = DEFAULT_SUCCESS
val DEFAULT_ERROR = {
output: List<String> ->
@ -65,7 +66,7 @@ open class NewRunCommand(val info: RunCommandInfo) {
val pb = ProcessBuilder(allArgs)
pb.directory(info.directory)
log(2, "Running command in directory ${info.directory.absolutePath}" +
kobaltLog(2, "Running command in directory ${info.directory.absolutePath}" +
"\n " + allArgs.joinToString(" ").replace("\\", "/"))
pb.environment().let { pbEnv ->
info.env.forEach {

View file

@ -8,7 +8,7 @@ import java.util.concurrent.TimeUnit
open class RunCommand(val command: String) {
val DEFAULT_SUCCESS = { output: List<String> -> }
// val DEFAULT_SUCCESS_VERBOSE = { output: List<String> -> log(2, "Success:\n " + output.joinToString("\n"))}
// val DEFAULT_SUCCESS_VERBOSE = { output: List<String> -> kobaltLog(2, "Success:\n " + output.joinToString("\n"))}
val defaultSuccess = DEFAULT_SUCCESS
val DEFAULT_ERROR = {
output: List<String> -> error(output.joinToString("\n "))
@ -39,7 +39,7 @@ open class RunCommand(val command: String) {
val pb = ProcessBuilder(allArgs)
pb.directory(directory)
log(2, "Running command in directory ${directory.absolutePath}" +
kobaltLog(2, "Running command in directory ${directory.absolutePath}" +
"\n " + allArgs.joinToString(" "))
val process = pb.start()
pb.environment().let { pbEnv ->