diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/Args.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/Args.kt index 03c5e134..b8742a71 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/Args.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/Args.kt @@ -42,8 +42,9 @@ class Args { @Parameter(names = arrayOf("--listTemplates"), description = "List the available templates") var listTemplates: Boolean = false - @Parameter(names = arrayOf("--log"), description = "Define the log level (1-3)") - var log: Int = 1 + @Parameter(names = arrayOf("--log"), description = "Define the log level " + + "(${Constants.LOG_DEFAULT_LEVEL}-${Constants.LOG_MAX_LEVEL})") + var log: Int = Constants.LOG_DEFAULT_LEVEL @Parameter(names = arrayOf("--forceIncremental"), description = "Force the build to be incremental even if the build file was modified") diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/Constants.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/Constants.kt index 7a95109f..530560d9 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/Constants.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/Constants.kt @@ -3,12 +3,14 @@ package com.beust.kobalt import com.beust.kobalt.misc.KFiles object Constants { + const val LOG_DEFAULT_LEVEL = 1 + const val LOG_MAX_LEVEL = 3 val BUILD_FILE_NAME = "Build.kt" val BUILD_FILE_DIRECTORY = "kobalt/src" val BUILD_FILE_PATH = KFiles.joinDir(BUILD_FILE_DIRECTORY, BUILD_FILE_NAME) internal val DEFAULT_REPOS = listOf( -// "https://maven-central.storage.googleapis.com/", + // "https://maven-central.storage.googleapis.com/", "http://repo1.maven.org/maven2/", "https://jcenter.bintray.com/", "http://repository.jetbrains.com/all/" diff --git a/src/main/kotlin/com/beust/kobalt/Main.kt b/src/main/kotlin/com/beust/kobalt/Main.kt index 3174feb5..56f9e085 100644 --- a/src/main/kotlin/com/beust/kobalt/Main.kt +++ b/src/main/kotlin/com/beust/kobalt/Main.kt @@ -33,7 +33,11 @@ private fun parseArgs(argv: Array): Main.RunInfo { val args = Args() val result = JCommander(args) result.parse(*argv) - KobaltLogger.LOG_LEVEL = args.log + KobaltLogger.LOG_LEVEL = if (args.log < 0) { + Constants.LOG_DEFAULT_LEVEL + } else if (args.log > Constants.LOG_MAX_LEVEL) { + Constants.LOG_MAX_LEVEL + } else args.log return Main.RunInfo(result, args) } @@ -68,7 +72,7 @@ private class Main @Inject constructor( data class RunInfo(val jc: JCommander, val args: Args) - private fun installCommandLinePlugins(args: Args) : ClassLoader { + private fun installCommandLinePlugins(args: Args): ClassLoader { var pluginClassLoader = javaClass.classLoader val dependencies = arrayListOf() args.pluginIds?.let { @@ -117,7 +121,7 @@ private class Main @Inject constructor( } } - if (! args.update) { + if (!args.update) { log(1, if (result != 0) "BUILD FAILED: $result" else "BUILD SUCCESSFUL ($seconds seconds)") updateKobalt.checkForNewVersion(latestVersionFuture) @@ -156,9 +160,9 @@ private class Main @Inject constructor( } else if (args.serverMode) { // --server val port = serverFactory.create(args.force, args.port, - { buildFile -> projectFinder.initForBuildFile(BuildFile(Paths.get(buildFile), buildFile), args)}, + { buildFile -> projectFinder.initForBuildFile(BuildFile(Paths.get(buildFile), buildFile), args) }, { cleanUp() }) - .call() + .call() } else { // Options that don't need Build.kt to be parsed first if (args.gc) { @@ -183,7 +187,7 @@ private class Main @Inject constructor( if (args.projectInfo) { // --projectInfo allProjects.forEach { - resolveDependency.run(it.compileDependencies.map {it.id}) + resolveDependency.run(it.compileDependencies.map { it.id }) } } else if (args.dependencies != null) { // --resolve @@ -217,7 +221,7 @@ private class Main @Inject constructor( return result } - private fun findBuildFile() : File { + private fun findBuildFile(): File { val deprecatedLocation = File(Constants.BUILD_FILE_NAME) val result: File = if (deprecatedLocation.exists()) {