From 7f735205790dc3accb9f810e72f6a250e4f23bad Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Sun, 29 May 2016 06:35:54 -0700 Subject: [PATCH 001/106] Revert the kobaltw.bat fix. --- kobaltw.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kobaltw.bat b/kobaltw.bat index 8ce6a621..52e2d636 100644 --- a/kobaltw.bat +++ b/kobaltw.bat @@ -1,2 +1,2 @@ @echo off -java -jar "%~dp0/../kobalt/wrapper/kobalt-wrapper.jar" %* +java -jar "%~dp0/kobalt/wrapper/kobalt-wrapper.jar" %* From 7b3e3269979051d0a25143a2a7a7bae40177e381 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Sun, 29 May 2016 06:36:15 -0700 Subject: [PATCH 002/106] 0.790. --- kobalt/wrapper/kobalt-wrapper.properties | 2 +- src/main/resources/kobalt.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties index 7fe637c5..6b21d471 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=0.789 \ No newline at end of file +kobalt.version=0.790 \ No newline at end of file diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index 08c3d2ee..104025b3 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=0.789 +kobalt.version=0.790 From 7d54179ae3d107afa52f71f2b479a1aec08065c3 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Sun, 29 May 2016 06:46:59 -0700 Subject: [PATCH 003/106] 0.791. --- kobalt/wrapper/kobalt-wrapper.properties | 2 +- src/main/resources/kobalt.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties index 6b21d471..a0d4a91f 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=0.790 \ No newline at end of file +kobalt.version=0.791 \ No newline at end of file diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index 104025b3..15eec2bd 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=0.790 +kobalt.version=0.791 From c2cf075b6ff6b3c945fbca58d772ae2df6939b81 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Sun, 29 May 2016 07:51:03 -0700 Subject: [PATCH 004/106] Added --forceIncremental. --- .../src/main/kotlin/com/beust/kobalt/Args.kt | 4 ++++ .../kotlin/com/beust/kobalt/internal/IncrementalManager.kt | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) 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 7501cec5..03c5e134 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 @@ -45,6 +45,10 @@ class Args { @Parameter(names = arrayOf("--log"), description = "Define the log level (1-3)") var log: Int = 1 + @Parameter(names = arrayOf("--forceIncremental"), + description = "Force the build to be incremental even if the build file was modified") + var forceIncremental: Boolean = false + @Parameter(names = arrayOf("--noIncremental"), description = "Turn off incremental builds") var noIncremental: Boolean = false diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/IncrementalManager.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/IncrementalManager.kt index bc53592e..6b134f42 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/IncrementalManager.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/IncrementalManager.kt @@ -93,7 +93,8 @@ class IncrementalManager @Inject constructor(val args: Args, @Assisted val fileN var upToDate = false var taskOutputChecksum : String? = null - if (args.noIncremental || (Kobalt.context?.internalContext?.buildFileOutOfDate as Boolean)) { + if (! args.forceIncremental && + (args.noIncremental || (Kobalt.context?.internalContext?.buildFileOutOfDate as Boolean))) { // // If the user turned off incremental builds or if the build file was modified, always run this task // From 0850444863a251bc44685fbb13fb0788e044fa79 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Sun, 29 May 2016 07:51:20 -0700 Subject: [PATCH 005/106] 0.792. --- kobalt/wrapper/kobalt-wrapper.properties | 2 +- src/main/resources/kobalt.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties index a0d4a91f..c9eb526d 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=0.791 \ No newline at end of file +kobalt.version=0.792 \ No newline at end of file diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index 15eec2bd..96acfe37 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=0.791 +kobalt.version=0.792 From 31b79c7e5085caedfdfe97f67f1af5aa978593e5 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Mon, 30 May 2016 12:22:08 -0700 Subject: [PATCH 006/106] [GITHUB-214] Extra "test-classes" directory in the classpath. Fix https://github.com/cbeust/kobalt/issues/214 --- .../kotlin/com/beust/kobalt/maven/DependencyManager.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/DependencyManager.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/DependencyManager.kt index 93d997ed..8bda7d28 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/DependencyManager.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/DependencyManager.kt @@ -208,9 +208,13 @@ class DependencyManager @Inject constructor(val executors: KobaltExecutors, val // Make sure that classes/ and test-classes/ are always at the top of this classpath, // so that older versions of that project on the classpath don't shadow them - val result = listOf(FileDependency(KFiles.makeOutputDir(project).absolutePath), - FileDependency(KFiles.makeOutputTestDir(project).absolutePath)) + - reorderDependencies(transitive) + val result : ArrayList = + arrayListOf(FileDependency(KFiles.makeOutputDir(project).absolutePath)) + if (isTest) { + result.add(FileDependency(KFiles.makeOutputTestDir(project).absolutePath)) + } + result.addAll(reorderDependencies(transitive)) + return result } From 6ac16074f03b7b0cce05affeae40543927130ec1 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Mon, 30 May 2016 12:22:18 -0700 Subject: [PATCH 007/106] private --- .../kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt b/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt index 0bbca05f..165c92c9 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt @@ -161,7 +161,7 @@ class KotlinCompiler @Inject constructor( } class KConfiguration @Inject constructor(val compiler: KotlinCompiler){ - val classpath = arrayListOf() + private val classpath = arrayListOf() val dependencies = arrayListOf() var source = arrayListOf() var output: File by Delegates.notNull() From f89688ae198969333b5c9c603433c0fc92d60f5a Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Mon, 30 May 2016 12:52:42 -0700 Subject: [PATCH 008/106] GITHUB-215: Bug in dependent project classpath. Fixes https://github.com/cbeust/kobalt/issues/215 --- .../kotlin/com/beust/kobalt/JarGenerator.kt | 7 +---- .../beust/kobalt/api/IDependencyManager.kt | 1 - .../beust/kobalt/maven/DependencyManager.kt | 27 +++++++++---------- .../plugin/application/ApplicationPlugin.kt | 5 +--- .../plugin/packaging/PackagingPlugin.kt | 3 +-- .../kobalt/plugin/packaging/WarGenerator.kt | 9 +++---- 6 files changed, 18 insertions(+), 34 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/JarGenerator.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/JarGenerator.kt index d7197526..39c4c2e1 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/JarGenerator.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/JarGenerator.kt @@ -2,10 +2,8 @@ package com.beust.kobalt import com.beust.kobalt.api.KobaltContext import com.beust.kobalt.api.Project -import com.beust.kobalt.api.ProjectDescription import com.beust.kobalt.archive.Archives import com.beust.kobalt.archive.Jar -import com.beust.kobalt.internal.JvmCompilerPlugin import com.beust.kobalt.maven.DependencyManager import com.beust.kobalt.misc.* import com.google.inject.Inject @@ -97,15 +95,12 @@ class JarGenerator @Inject constructor(val dependencyManager: DependencyManager) val seen = hashSetOf() @Suppress("UNCHECKED_CAST") - val dependentProjects = project.projectProperties.get(JvmCompilerPlugin.DEPENDENT_PROJECTS) - as List val allDependencies = project.compileDependencies + project.compileRuntimeDependencies + context.variant.buildType.compileDependencies + context.variant.buildType.compileRuntimeDependencies + context.variant.productFlavor.compileDependencies + context.variant.productFlavor.compileRuntimeDependencies - val transitiveDependencies = dependencyManager.calculateDependencies(project, context, dependentProjects, - allDependencies) + val transitiveDependencies = dependencyManager.calculateDependencies(project, context, allDependencies) transitiveDependencies.map { it.jarFile.get() }.forEach { file : File -> diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/IDependencyManager.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/IDependencyManager.kt index 76183629..9e47c0dc 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/IDependencyManager.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/IDependencyManager.kt @@ -34,6 +34,5 @@ interface IDependencyManager { * allDependencies is typically either compileDependencies or testDependencies */ fun calculateDependencies(project: Project?, context: KobaltContext, - dependentProjects: List = emptyList(), vararg allDependencies: List): List } \ No newline at end of file diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/DependencyManager.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/DependencyManager.kt index 8bda7d28..7fef033f 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/DependencyManager.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/DependencyManager.kt @@ -85,14 +85,13 @@ class DependencyManager @Inject constructor(val executors: KobaltExecutors, val * allDependencies is typically either compileDependencies or testDependencies */ override fun calculateDependencies(project: Project?, context: KobaltContext, - dependentProjects: List, vararg allDependencies: List): List { val result = arrayListOf() allDependencies.forEach { dependencies -> result.addAll(transitiveClosure(dependencies)) } result.addAll(runClasspathContributors(project, context)) - result.addAll(dependentProjectDependencies(dependentProjects, project, context)) + result.addAll(dependentProjectDependencies(project, context)) return result } @@ -169,27 +168,25 @@ class DependencyManager @Inject constructor(val executors: KobaltExecutors, val * If this project depends on other projects, we need to include their jar file and also * their own dependencies */ - private fun dependentProjectDependencies(projectDescriptions: List, + private fun dependentProjectDependencies( project: Project?, context: KobaltContext) : List { - val result = arrayListOf() - projectDescriptions.filter { - it.project.name == project?.name - }.forEach { pd -> - pd.dependsOn.forEach { p -> + if (project == null) { + return emptyList() + } else { + val result = arrayListOf() + project.projectExtra.dependsOn.forEach { p -> result.add(FileDependency(KFiles.joinDir(p.directory, p.classesDir(context)))) - val otherDependencies = calculateDependencies(p, context, projectDescriptions, - p.compileDependencies) + val otherDependencies = calculateDependencies(p, context, p.compileDependencies) result.addAll(otherDependencies) - } - } - return result + } + return result + } } private fun dependencies(project: Project, context: KobaltContext, isTest: Boolean) : List { val transitive = hashSetOf() - val projects = listOf(ProjectDescription(project, project.projectExtra.dependsOn)) with(project) { val deps = arrayListOf(compileDependencies, compileProvidedDependencies, context.variant.buildType.compileDependencies, @@ -202,7 +199,7 @@ class DependencyManager @Inject constructor(val executors: KobaltExecutors, val deps.add(testProvidedDependencies) } deps.filter { it.any() }.forEach { - transitive.addAll(calculateDependencies(project, context, projects, it)) + transitive.addAll(calculateDependencies(project, context, it)) } } diff --git a/src/main/kotlin/com/beust/kobalt/plugin/application/ApplicationPlugin.kt b/src/main/kotlin/com/beust/kobalt/plugin/application/ApplicationPlugin.kt index 3b871016..8f0c6e8d 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/application/ApplicationPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/application/ApplicationPlugin.kt @@ -7,7 +7,6 @@ import com.beust.kobalt.api.annotation.Task import com.beust.kobalt.archive.Archives import com.beust.kobalt.archive.Jar import com.beust.kobalt.internal.ActorUtils -import com.beust.kobalt.internal.JvmCompilerPlugin import com.beust.kobalt.maven.DependencyManager import com.beust.kobalt.misc.KFiles import com.beust.kobalt.misc.KobaltExecutors @@ -106,12 +105,10 @@ class ApplicationPlugin @Inject constructor(val configActor: ConfigActor // If the jar file is not fat, we need to add the transitive closure of all dependencies // on the classpath val allTheDependencies = - dependencyManager.calculateDependencies(project, context, projDeps, + dependencyManager.calculateDependencies(project, context, allDependencies = project.compileDependencies).map { it.jarFile.get().path } allDeps.addAll(allTheDependencies) } diff --git a/src/main/kotlin/com/beust/kobalt/plugin/packaging/PackagingPlugin.kt b/src/main/kotlin/com/beust/kobalt/plugin/packaging/PackagingPlugin.kt index 16dea24c..79c5695e 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/packaging/PackagingPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/packaging/PackagingPlugin.kt @@ -118,8 +118,7 @@ class PackagingPlugin @Inject constructor(val dependencyManager : DependencyMana val analyzer = Analyzer().apply { jar = aQute.bnd.osgi.Jar(project.projectProperties.get(Archives.JAR_NAME) as String) val dependencies = project.compileDependencies + project.compileRuntimeDependencies - val dependentProjects = project.dependentProjects - dependencyManager.calculateDependencies(project, context, dependentProjects, dependencies).forEach { + dependencyManager.calculateDependencies(project, context, dependencies).forEach { addClasspath(it.jarFile.get()) } setProperty(Analyzer.BUNDLE_VERSION, project.version) diff --git a/src/main/kotlin/com/beust/kobalt/plugin/packaging/WarGenerator.kt b/src/main/kotlin/com/beust/kobalt/plugin/packaging/WarGenerator.kt index ad4b4f8d..a4826813 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/packaging/WarGenerator.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/packaging/WarGenerator.kt @@ -1,13 +1,12 @@ package com.beust.kobalt.plugin.packaging -import com.beust.kobalt.archive.Archives import com.beust.kobalt.IFileSpec import com.beust.kobalt.JarGenerator -import com.beust.kobalt.archive.War import com.beust.kobalt.api.IClasspathDependency import com.beust.kobalt.api.KobaltContext import com.beust.kobalt.api.Project -import com.beust.kobalt.api.ProjectDescription +import com.beust.kobalt.archive.Archives +import com.beust.kobalt.archive.War import com.beust.kobalt.maven.DependencyManager import com.beust.kobalt.misc.From import com.beust.kobalt.misc.IncludedFile @@ -40,9 +39,7 @@ class WarGenerator @Inject constructor(val dependencyManager: DependencyManager) // The transitive closure of libraries goes into WEB-INF/libs. // Copy them all in kobaltBuild/war/WEB-INF/libs and create one IncludedFile out of that directory // - val dependentProjects = listOf(ProjectDescription(project, project.projectExtra.dependsOn)) - val allDependencies = dependencyManager.calculateDependencies(project, context, dependentProjects, - project.compileDependencies) + val allDependencies = dependencyManager.calculateDependencies(project, context, project.compileDependencies) val outDir = project.buildDirectory + "/war" val fullDir = outDir + "/" + LIB From 276f9e9602aaf547503e2c1b76270471cc2c0aa5 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Mon, 30 May 2016 12:52:59 -0700 Subject: [PATCH 009/106] 0.793. --- kobalt/wrapper/kobalt-wrapper.properties | 2 +- src/main/resources/kobalt.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties index c9eb526d..6fb88aa9 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=0.792 \ No newline at end of file +kobalt.version=0.793 \ No newline at end of file diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index 96acfe37..27b9e069 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=0.792 +kobalt.version=0.793 From af846f2e20185a5a7552f192c8f107f49f648698 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 31 May 2016 20:35:45 -0700 Subject: [PATCH 010/106] Fix classpath. --- .../com/beust/kobalt/maven/DependencyManager.kt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/DependencyManager.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/DependencyManager.kt index 7fef033f..1ea41147 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/DependencyManager.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/DependencyManager.kt @@ -205,12 +205,13 @@ class DependencyManager @Inject constructor(val executors: KobaltExecutors, val // Make sure that classes/ and test-classes/ are always at the top of this classpath, // so that older versions of that project on the classpath don't shadow them - val result : ArrayList = - arrayListOf(FileDependency(KFiles.makeOutputDir(project).absolutePath)) - if (isTest) { - result.add(FileDependency(KFiles.makeOutputTestDir(project).absolutePath)) + val result = arrayListOf().apply { + if (isTest) { + add(FileDependency(KFiles.makeOutputDir(project).absolutePath)) + add(FileDependency(KFiles.makeOutputTestDir(project).absolutePath)) + } + addAll(reorderDependencies(transitive)) } - result.addAll(reorderDependencies(transitive)) return result } From ecfdb2cf4fead5d42d429aa974874b78440aa7c6 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 31 May 2016 20:36:00 -0700 Subject: [PATCH 011/106] 0.794. --- kobalt/wrapper/kobalt-wrapper.properties | 2 +- src/main/resources/kobalt.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties index 6fb88aa9..9656dbdc 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=0.793 \ No newline at end of file +kobalt.version=0.794 \ No newline at end of file diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index 27b9e069..067ef7cf 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=0.793 +kobalt.version=0.794 From 028bbc1a4d7e0f3dc7aaf2dc464effd1560e4526 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 31 May 2016 20:42:09 -0700 Subject: [PATCH 012/106] 0.795. --- kobalt/wrapper/kobalt-wrapper.properties | 2 +- src/main/resources/kobalt.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties index 9656dbdc..3db917e7 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=0.794 \ No newline at end of file +kobalt.version=0.795 \ No newline at end of file diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index 067ef7cf..b1c586e5 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=0.794 +kobalt.version=0.795 From c1d3d80dfa38b0ad45d667caad11c709363e84d4 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 31 May 2016 21:25:12 -0700 Subject: [PATCH 013/106] Warning. --- .../com/beust/kobalt/plugin/application/ApplicationPlugin.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/beust/kobalt/plugin/application/ApplicationPlugin.kt b/src/main/kotlin/com/beust/kobalt/plugin/application/ApplicationPlugin.kt index 8f0c6e8d..9f6a4e9f 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/application/ApplicationPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/application/ApplicationPlugin.kt @@ -11,7 +11,7 @@ import com.beust.kobalt.maven.DependencyManager import com.beust.kobalt.misc.KFiles import com.beust.kobalt.misc.KobaltExecutors import com.beust.kobalt.misc.RunCommand -import com.beust.kobalt.misc.warn +import com.beust.kobalt.misc.log import com.beust.kobalt.plugin.packaging.PackageConfig import com.beust.kobalt.plugin.packaging.PackagingPlugin import com.google.inject.Inject @@ -59,7 +59,7 @@ class ApplicationPlugin @Inject constructor(val configActor: ConfigActor 0) { return runContributor.run(project, context, dependencyManager.dependencies(project, context)) } else { - warn("Couldn't find a runner for project ${project.name}. Please make sure your build file contains " + + log(2, "Couldn't find a runner for project ${project.name}. Please make sure your build file contains " + "an application{} directive with a mainClass=... in it") return TaskResult() } From 37fc55247622d2161a357ee56a60a2dd64935a7d Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 31 May 2016 21:25:35 -0700 Subject: [PATCH 014/106] 0.796. --- kobalt/wrapper/kobalt-wrapper.properties | 2 +- src/main/resources/kobalt.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties index 3db917e7..a7844afe 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=0.795 \ No newline at end of file +kobalt.version=0.796 \ No newline at end of file diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index b1c586e5..ac14f83a 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=0.795 +kobalt.version=0.796 From 7b251f4d8eb1acdfc419d2b53b9fc34111023e07 Mon Sep 17 00:00:00 2001 From: DevCharly Date: Wed, 1 Jun 2016 11:59:30 +0200 Subject: [PATCH 015/106] fixed timestamps in created JAR files (was 1970-01-01 00:00) --- .../src/main/kotlin/com/beust/kobalt/misc/JarUtils.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/JarUtils.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/JarUtils.kt index 90b8aacc..70a8bbb4 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/JarUtils.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/JarUtils.kt @@ -55,7 +55,7 @@ public class JarUtils { if (!name.isEmpty()) { if (!name.endsWith("/")) name += "/" val entry = JarEntry(name) - entry.time = foundFile.lastModified() + entry.time = localFile.lastModified() try { outputStream.putNextEntry(entry) } catch(ex: ZipException) { @@ -81,7 +81,7 @@ public class JarUtils { } else { val entryFileName = file.to(foundFile.path).path.replace("\\", "/") val entry = JarEntry(entryFileName) - entry.time = foundFile.lastModified() + entry.time = localFile.lastModified() addEntry(FileInputStream(localFile), entry, outputStream, onError) } } From 557b4b6b4531eb95990946ad1708d1311bf375a0 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 31 May 2016 21:01:50 -0800 Subject: [PATCH 016/106] 0.797. --- kobalt/wrapper/kobalt-wrapper.properties | 2 +- src/main/resources/kobalt.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties index a7844afe..15f4add7 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=0.796 \ No newline at end of file +kobalt.version=0.797 \ No newline at end of file diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index ac14f83a..d766c785 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=0.796 +kobalt.version=0.797 From 27edec8f7a86697fc8e53a07336581fc7476fa94 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 31 May 2016 21:13:24 -0800 Subject: [PATCH 017/106] IDEA files: fix bogus paths pointing to .m2. --- kobalt.iml | 85 ++++++++-------- .../kobalt-plugin-api/kobalt-plugin-api.iml | 99 ++++++++++--------- 2 files changed, 92 insertions(+), 92 deletions(-) diff --git a/kobalt.iml b/kobalt.iml index 384e6859..da723b47 100644 --- a/kobalt.iml +++ b/kobalt.iml @@ -3,9 +3,7 @@ - - @@ -16,7 +14,7 @@ - + @@ -25,7 +23,7 @@ - + @@ -34,7 +32,7 @@ - + @@ -43,7 +41,7 @@ - + @@ -52,7 +50,7 @@ - + @@ -61,7 +59,7 @@ - + @@ -70,7 +68,7 @@ - + @@ -79,7 +77,7 @@ - + @@ -88,7 +86,7 @@ - + @@ -97,7 +95,7 @@ - + @@ -106,7 +104,7 @@ - + @@ -115,7 +113,7 @@ - + @@ -124,7 +122,7 @@ - + @@ -133,7 +131,7 @@ - + @@ -142,7 +140,7 @@ - + @@ -151,7 +149,7 @@ - + @@ -160,7 +158,7 @@ - + @@ -169,7 +167,7 @@ - + @@ -178,7 +176,7 @@ - + @@ -187,7 +185,7 @@ - + @@ -196,7 +194,7 @@ - + @@ -205,7 +203,7 @@ - + @@ -214,7 +212,7 @@ - + @@ -223,7 +221,7 @@ - + @@ -232,7 +230,7 @@ - + @@ -241,7 +239,7 @@ - + @@ -250,7 +248,7 @@ - + @@ -259,7 +257,7 @@ - + @@ -268,7 +266,7 @@ - + @@ -277,7 +275,7 @@ - + @@ -286,7 +284,7 @@ - + @@ -295,7 +293,7 @@ - + @@ -304,7 +302,7 @@ - + @@ -313,7 +311,7 @@ - + @@ -322,7 +320,7 @@ - + @@ -331,7 +329,7 @@ - + @@ -340,7 +338,7 @@ - + @@ -349,7 +347,7 @@ - + @@ -358,7 +356,7 @@ - + @@ -367,12 +365,13 @@ - + + - \ No newline at end of file + diff --git a/modules/kobalt-plugin-api/kobalt-plugin-api.iml b/modules/kobalt-plugin-api/kobalt-plugin-api.iml index 7e463927..96b5e27f 100644 --- a/modules/kobalt-plugin-api/kobalt-plugin-api.iml +++ b/modules/kobalt-plugin-api/kobalt-plugin-api.iml @@ -14,7 +14,7 @@ - + @@ -23,7 +23,7 @@ - + @@ -32,7 +32,7 @@ - + @@ -41,7 +41,7 @@ - + @@ -50,7 +50,7 @@ - + @@ -59,7 +59,7 @@ - + @@ -68,7 +68,7 @@ - + @@ -77,7 +77,7 @@ - + @@ -86,7 +86,7 @@ - + @@ -95,7 +95,7 @@ - + @@ -104,7 +104,7 @@ - + @@ -113,7 +113,7 @@ - + @@ -122,7 +122,7 @@ - + @@ -131,7 +131,7 @@ - + @@ -140,7 +140,7 @@ - + @@ -149,7 +149,7 @@ - + @@ -158,7 +158,7 @@ - + @@ -167,7 +167,7 @@ - + @@ -176,7 +176,7 @@ - + @@ -185,7 +185,7 @@ - + @@ -194,7 +194,7 @@ - + @@ -203,7 +203,7 @@ - + @@ -212,7 +212,7 @@ - + @@ -221,7 +221,7 @@ - + @@ -230,7 +230,7 @@ - + @@ -239,7 +239,7 @@ - + @@ -248,7 +248,7 @@ - + @@ -257,7 +257,7 @@ - + @@ -266,7 +266,7 @@ - + @@ -275,7 +275,7 @@ - + @@ -284,7 +284,7 @@ - + @@ -293,7 +293,7 @@ - + @@ -302,7 +302,7 @@ - + @@ -311,7 +311,7 @@ - + @@ -320,7 +320,7 @@ - + @@ -329,7 +329,7 @@ - + @@ -338,7 +338,7 @@ - + @@ -347,7 +347,7 @@ - + @@ -356,7 +356,7 @@ - + @@ -365,7 +365,7 @@ - + @@ -374,7 +374,7 @@ - + @@ -383,7 +383,7 @@ - + @@ -392,7 +392,7 @@ - + @@ -401,7 +401,7 @@ - + @@ -410,7 +410,7 @@ - + @@ -419,7 +419,7 @@ - + @@ -428,7 +428,7 @@ - + @@ -437,11 +437,12 @@ - + + - \ No newline at end of file + From d198d5e6a14364e790b0a58721587a1e5cd00c4f Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 31 May 2016 21:44:02 -0800 Subject: [PATCH 018/106] Return all the tasks in the getDependencies() command. --- .../beust/kobalt/app/remote/DependencyData.kt | 17 ++++++++++++----- .../com/beust/kobalt/app/remote/SparkServer.kt | 8 ++++---- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/com/beust/kobalt/app/remote/DependencyData.kt b/src/main/kotlin/com/beust/kobalt/app/remote/DependencyData.kt index 7a4f4eec..7f612aa9 100644 --- a/src/main/kotlin/com/beust/kobalt/app/remote/DependencyData.kt +++ b/src/main/kotlin/com/beust/kobalt/app/remote/DependencyData.kt @@ -36,6 +36,8 @@ class DependencyData @Inject constructor(val executors: KobaltExecutors, val dep val pluginDependencies = projectResult.pluginUrls.map { File(it.toURI()) }.map { FileDependency(it.absolutePath) } + + val allTasks = hashSetOf() projectResult.projects.forEach { project -> val compileDependencies = pluginDependencies.map { toDependencyData(it, "compile") } + allDeps(project.compileDependencies).map { toDependencyData(it, "compile") } + @@ -55,15 +57,16 @@ class DependencyData @Inject constructor(val executors: KobaltExecutors, val dep // Separate resource from source directories val sources = project.sourceDirectories.partition { KFiles.isResource(it) } val tests = project.sourceDirectoriesTest.partition { KFiles.isResource(it) } - val allTasks = taskManager.tasksByNames(project).values().map { + val projectTasks = taskManager.tasksByNames(project).values().map { TaskData(it.name, it.doc, it.group) } + allTasks.addAll(projectTasks) projectDatas.add(ProjectData(project.name, project.directory, dependentProjects, compileDependencies, testDependencies, sources.second.toSet(), tests.second.toSet(), sources.first.toSet(), tests.first.toSet(), - allTasks)) + projectTasks)) } - return GetDependenciesData(projectDatas, projectResult.taskResult.errorMessage) + return GetDependenciesData(projectDatas, allTasks, projectResult.taskResult.errorMessage) } ///// @@ -72,7 +75,9 @@ class DependencyData @Inject constructor(val executors: KobaltExecutors, val dep // class DependencyData(val id: String, val scope: String, val path: String) - class TaskData(val name: String, val description: String, val group: String) + data class TaskData(val name: String, val description: String, val group: String) { + override fun toString() = name + } class ProjectData(val name: String, val directory: String, val dependentProjects: List, @@ -81,5 +86,7 @@ class DependencyData @Inject constructor(val executors: KobaltExecutors, val dep val sourceResourceDirs: Set, val testResourceDirs: Set, val tasks: Collection) - class GetDependenciesData(val projects: List, val errorMessage: String?) + class GetDependenciesData(val projects: List = emptyList(), + val allTasks: Collection = emptySet(), + val errorMessage: String?) } diff --git a/src/main/kotlin/com/beust/kobalt/app/remote/SparkServer.kt b/src/main/kotlin/com/beust/kobalt/app/remote/SparkServer.kt index 71e34391..7913852b 100644 --- a/src/main/kotlin/com/beust/kobalt/app/remote/SparkServer.kt +++ b/src/main/kotlin/com/beust/kobalt/app/remote/SparkServer.kt @@ -36,7 +36,7 @@ class SparkServer(val initCallback: (String) -> List, val cleanUpCallba override fun run(port: Int) { Spark.port(port) - Spark.get("/ping", { req, res -> KobaltServer.OK }) + Spark.get("/ping", { req, res -> """ { "result" : "ok" } """ }) Spark.get("/quit", { req, res -> Executors.newFixedThreadPool(1).let { executor -> executor.submit { @@ -58,13 +58,13 @@ class SparkServer(val initCallback: (String) -> List, val cleanUpCallba dependencyData.dependenciesDataFor(buildFile, args) } catch(ex: Exception) { - DependencyData.GetDependenciesData(emptyList(), ex.message) + DependencyData.GetDependenciesData(errorMessage = ex.message) } finally { cleanUpCallback() } } else { - DependencyData.GetDependenciesData(emptyList(), - "buildFile wasn't passed in the query parameter") + DependencyData.GetDependenciesData( + errorMessage = "buildFile wasn't passed in the query parameter") } cleanUpCallback() result From 05984df3e7dc32c5c3c53977c6b41fcbb441934b Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 31 May 2016 21:45:51 -0800 Subject: [PATCH 019/106] 0.798. --- kobalt/wrapper/kobalt-wrapper.properties | 2 +- src/main/resources/kobalt.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties index 15f4add7..28414fb8 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=0.797 \ No newline at end of file +kobalt.version=0.798 \ No newline at end of file diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index d766c785..24ffe133 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=0.797 +kobalt.version=0.798 From 93fe8a25f157c393b48645b2024f17fa3fdc6668 Mon Sep 17 00:00:00 2001 From: DevCharly Date: Wed, 1 Jun 2016 18:57:59 +0200 Subject: [PATCH 020/106] fixed typo (Incerceptor -> Interceptor) --- .../com/beust/kobalt/api/IBuildDirectoryInterceptor.kt | 2 +- .../com/beust/kobalt/api/ISourceDirectoriesInterceptor.kt | 2 +- .../kotlin/com/beust/kobalt/internal/KobaltPluginXml.kt | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/IBuildDirectoryInterceptor.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/IBuildDirectoryInterceptor.kt index 5a317c0f..afb0f1ef 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/IBuildDirectoryInterceptor.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/IBuildDirectoryInterceptor.kt @@ -3,7 +3,7 @@ package com.beust.kobalt.api /** * Plug-ins can alter the build directory by implementing this interface. */ -interface IBuildDirectoryIncerceptor : IInterceptor { +interface IBuildDirectoryInterceptor : IInterceptor { fun intercept(project: Project, context: KobaltContext, buildDirectory: String) : String } diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/ISourceDirectoriesInterceptor.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/ISourceDirectoriesInterceptor.kt index aa39712b..33ec6e7c 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/ISourceDirectoriesInterceptor.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/ISourceDirectoriesInterceptor.kt @@ -5,7 +5,7 @@ import java.io.File /** * Plug-ins can alter the source directories by implementing this interface. */ -interface ISourceDirectoryIncerceptor : IInterceptor { +interface ISourceDirectoryInterceptor : IInterceptor { fun intercept(project: Project, context: KobaltContext, sourceDirectories: List) : List } diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/KobaltPluginXml.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/KobaltPluginXml.kt index 4df2409b..b22ad6ba 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/KobaltPluginXml.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/KobaltPluginXml.kt @@ -76,8 +76,8 @@ class PluginInfo(val xml: KobaltPluginXml, val pluginClassLoader: ClassLoader?, val repoContributors = arrayListOf() val compilerFlagContributors = arrayListOf() val compilerInterceptors = arrayListOf() - val sourceDirectoriesInterceptors = arrayListOf() - val buildDirectoryInterceptors = arrayListOf() + val sourceDirectoriesInterceptors = arrayListOf() + val buildDirectoryInterceptors = arrayListOf() val runnerContributors = arrayListOf() val testRunnerContributors = arrayListOf() val classpathInterceptors = arrayListOf() @@ -169,7 +169,7 @@ class PluginInfo(val xml: KobaltPluginXml, val pluginClassLoader: ClassLoader?, with(factory.instanceOf(forName(it))) { // Note: can't use "when" here since the same instance can implement multiple interfaces if (this is IBuildConfigFieldContributor) buildConfigFieldContributors.add(this) - if (this is IBuildDirectoryIncerceptor) buildDirectoryInterceptors.add(this) + if (this is IBuildDirectoryInterceptor) buildDirectoryInterceptors.add(this) if (this is IClasspathContributor) classpathContributors.add(this) if (this is IClasspathInterceptor) classpathInterceptors.add(this) if (this is ICompilerContributor) compilerContributors.add(this) @@ -182,7 +182,7 @@ class PluginInfo(val xml: KobaltPluginXml, val pluginClassLoader: ClassLoader?, if (this is IRepoContributor) repoContributors.add(this) if (this is IRunnerContributor) runnerContributors.add(this) if (this is ISourceDirectoryContributor) sourceDirContributors.add(this) - if (this is ISourceDirectoryIncerceptor) sourceDirectoriesInterceptors.add(this) + if (this is ISourceDirectoryInterceptor) sourceDirectoriesInterceptors.add(this) if (this is ITaskContributor) taskContributors.add(this) if (this is ITestRunnerContributor) testRunnerContributors.add(this) if (this is IMavenIdInterceptor) mavenIdInterceptors.add(this) From a08b8852e8262bc13d48b54ff3c0c72532dc115c Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 31 May 2016 23:43:26 -0800 Subject: [PATCH 021/106] GITHUB-212: Honor project dependencies for single task targets. Fixes https://github.com/cbeust/kobalt/issues/212 --- .../com/beust/kobalt/internal/TaskManager.kt | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt index 2039c9e1..7dc8c2eb 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt @@ -81,10 +81,11 @@ class TaskManager @Inject constructor(val args: Args, } } - fun runTargets(taskNames: List, projects: List): RunTargetResult { + fun runTargets(passedTaskNames: List, projects: List): RunTargetResult { var result = 0 val failedProjects = hashSetOf() val messages = Collections.synchronizedList(arrayListOf()) + val taskNames = calculateDependentTaskNames(passedTaskNames, projects) projects.forEach { project -> AsciiArt.logBox("Building ${project.name}") @@ -140,6 +141,28 @@ class TaskManager @Inject constructor(val args: Args, return RunTargetResult(result, messages) } + /** + * If the user wants to run a single task on a single project (e.g. "kobalt:assemble"), we need to + * see if that project depends on others and if it does, invoke these tasks on all of them. This + * function returns all these task names (including dependent). + */ + private fun calculateDependentTaskNames(taskNames: List, projects: List): List { + val projectMap = hashMapOf().apply { + projects.forEach { put(it.name, it)} + } + val result = ArrayList(taskNames) + taskNames.forEach { taskName -> + val ti = TaskInfo(taskName) + projectMap[ti.project]?.let { project -> + project.projectExtra.dependsOn.forEach { dp -> + result.add(TaskInfo(dp.projectName, ti.taskName).id) + } + } + } + + return result + } + val LOG_LEVEL = 3 /** From c8be1d8dd466a118166839e69156c9fc39c7c1b4 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 31 May 2016 23:43:37 -0800 Subject: [PATCH 022/106] 0.799. --- kobalt/wrapper/kobalt-wrapper.properties | 2 +- src/main/resources/kobalt.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties index 28414fb8..93d15fa3 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=0.798 \ No newline at end of file +kobalt.version=0.799 \ No newline at end of file diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index 24ffe133..8fc4d5bb 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=0.798 +kobalt.version=0.799 From 21e2d89fdcbc859a2bd511bad34acd44cf133264 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 31 May 2016 23:50:43 -0800 Subject: [PATCH 023/106] Actual transitive closure. --- .../com/beust/kobalt/internal/TaskManager.kt | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt index 7dc8c2eb..432e1471 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt @@ -151,13 +151,28 @@ class TaskManager @Inject constructor(val args: Args, projects.forEach { put(it.name, it)} } val result = ArrayList(taskNames) - taskNames.forEach { taskName -> - val ti = TaskInfo(taskName) - projectMap[ti.project]?.let { project -> - project.projectExtra.dependsOn.forEach { dp -> - result.add(TaskInfo(dp.projectName, ti.taskName).id) + val toProcess = ArrayList(taskNames) + val newToProcess = arrayListOf() + val seen = hashSetOf() + var stop = false + while (! stop) { + toProcess.forEach { taskName -> + val ti = TaskInfo(taskName) + projectMap[ti.project]?.let { project -> + project.projectExtra.dependsOn.forEach { dp -> + val newTask = TaskInfo(dp.projectName, ti.taskName).id + result.add(newTask) + if (! seen.contains(newTask)) { + newToProcess.add(newTask) + seen.add(newTask) + } + } } } + stop = newToProcess.isEmpty() + toProcess.clear() + toProcess.addAll(newToProcess) + newToProcess.clear() } return result From 68b499061da1032b6a8ab0298879d55cd0b101f5 Mon Sep 17 00:00:00 2001 From: evanchooly Date: Thu, 2 Jun 2016 00:37:16 -0400 Subject: [PATCH 024/106] fix pom uploading with retrofit --- .../beust/kobalt/plugin/publish/BintrayApi.kt | 138 ++++++++---------- 1 file changed, 59 insertions(+), 79 deletions(-) diff --git a/src/main/kotlin/com/beust/kobalt/plugin/publish/BintrayApi.kt b/src/main/kotlin/com/beust/kobalt/plugin/publish/BintrayApi.kt index d93da574..5fbe2791 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/publish/BintrayApi.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/publish/BintrayApi.kt @@ -6,26 +6,35 @@ import com.beust.kobalt.api.Project import com.beust.kobalt.maven.Gpg import com.beust.kobalt.maven.Http import com.beust.kobalt.maven.Md5 +import com.beust.kobalt.misc.CountingFileRequestBody import com.beust.kobalt.misc.KobaltExecutors import com.beust.kobalt.misc.error import com.beust.kobalt.misc.log import com.beust.kobalt.misc.warn +import com.google.gson.Gson import com.google.gson.JsonArray import com.google.gson.JsonObject -import com.google.gson.JsonParser +import com.google.gson.TypeAdapter +import com.google.gson.reflect.TypeToken import com.google.inject.assistedinject.Assisted -import okhttp3.* +import okhttp3.Credentials +import okhttp3.Interceptor +import okhttp3.OkHttpClient +import okhttp3.RequestBody +import okhttp3.ResponseBody import retrofit2.Call +import retrofit2.Converter import retrofit2.Retrofit -import retrofit2.converter.gson.GsonConverterFactory -import retrofit2.http.* -import retrofit2.http.Headers +import retrofit2.http.Body +import retrofit2.http.GET +import retrofit2.http.POST +import retrofit2.http.PUT +import retrofit2.http.Path import java.io.File +import java.lang.reflect.Type import javax.annotation.Nullable import javax.inject.Inject -class BintrayResponse() - class BintrayApi @Inject constructor(val http: Http, @Nullable @Assisted("username") val username: String?, @Nullable @Assisted("password") val password: String?, @@ -34,7 +43,6 @@ class BintrayApi @Inject constructor(val http: Http, companion object { const val BINTRAY_URL_API = "https://api.bintray.com" - const val BINTRAY_URL_API_CONTENT = BINTRAY_URL_API + "/content" } interface IFactory { @@ -52,18 +60,6 @@ class BintrayApi @Inject constructor(val http: Http, fun createPackage(@Path("owner") owner: String, @Body content: JsonObject): Call - @Multipart - @Headers("Content-Type: application/xml") - @PUT("/content/{owner}/maven/{repo}/{version}/{group}/{artifact}/{version}/{name}") - fun uploadPom(@Path("owner") owner: String, - @Path("repo") repo: String, - @Path("group", encoded = true) group: String, - @Path("artifact") artifact: String, - @Path("version") version: String, - @Path("name") name: String, - @Part file: MultipartBody.Part): Call - - @Multipart @PUT("/content/{owner}/maven/{repo}/{version}/{group}/{artifact}/{version}/{name}") fun uploadArtifact(@Path("owner") owner: String, @Path("repo") repo: String, @@ -71,9 +67,7 @@ class BintrayApi @Inject constructor(val http: Http, @Path("artifact") artifact: String, @Path("version") version: String, @Path("name") name: String, - @Part file: MultipartBody.Part): Call - - + @Body file: File): Call } private val service: Api @@ -84,7 +78,7 @@ class BintrayApi @Inject constructor(val http: Http, // level = HttpLoggingInterceptor.Level.BASIC // }) builder.interceptors().add(Interceptor { chain -> - var original = chain.request(); + val original = chain.request(); chain.proceed(original.newBuilder() .header("Authorization", Credentials.basic(username, password)) @@ -96,7 +90,7 @@ class BintrayApi @Inject constructor(val http: Http, service = Retrofit.Builder() .client(okHttpClient) .baseUrl(BintrayApi.BINTRAY_URL_API) - .addConverterFactory(GsonConverterFactory.create()) + .addConverterFactory(ConverterFactory()) .build() .create(Api::class.java) } @@ -180,33 +174,20 @@ class BintrayApi @Inject constructor(val http: Http, val results = arrayListOf() filesToUpload.forEachIndexed { i, file -> - val type = MediaType.parse("multipart/form-data") + val owner = org ?: username!! + val repo = project.name + val group = project.group!!.replace('.', '/') + val artifact = project.artifactId!! + val version = project.version!! - val body = MultipartBody.Part.createFormData("artifact", file.name, RequestBody.create(type, file)); - - if (file.extension != "pom") { - val upload = service.uploadArtifact(org ?: username!!, project.name, - project.group!!.replace('.', '/'), project.artifactId!!, project.version!!, file.name, body) - val result = upload.execute() - val error = result.errorBody()?.string() - if (result.errorBody() != null) { - errorMessages.add(error!!) - results.add(false) - } else { - results.add(true) - } + val result = service.uploadArtifact(owner, repo, group, artifact, version, file.name, file) + .execute() + val error = result.errorBody()?.string() + if (result.errorBody() != null) { + errorMessages.add(error!!) + results.add(false) } else { - http.uploadFile(username, password, fileToPath(project, file) + optionPath, - Http.TypedFile(com.google.common.net.MediaType.ANY_APPLICATION_TYPE.toString(), file), - post = false, // Bintray requires PUT - success = { r: Response -> results.add(true) }, - error = { r: Response -> - results.add(false) - val jcResponse = parseResponse(r) - errorMessages.add(jcResponse.errorMessage!!) - }) -// service.uploadPom(org ?: username!!, project.name, project.group!!.replace('.', '/'), -// project.artifactId!!, project.version!!, file.name, body) + results.add(true) } log(1, " Uploading ${i + 1} / $fileCount " + dots(fileCount, results, file), false) @@ -228,37 +209,8 @@ class BintrayApi @Inject constructor(val http: Http, } } - fun fileToPath(project: Project, f: File) : String { - return listOf( - BINTRAY_URL_API_CONTENT, - org ?: username!!, - "maven", - project.name, - project.version!!, - project.group!!.replace(".", "/"), - project.artifactId!!, - project.version!!, - f.name) - .joinToString("/") - } - class BintrayResponse(val jo: JsonObject?, val errorMessage: String?) - fun parseResponse(r: Response): BintrayResponse { - val networkResponse = r.networkResponse() - if (networkResponse.code() != 200) { - val message = networkResponse.message() - try { - val errorObject = JsonParser().parse(r.body().string()).asJsonObject - return BintrayResponse(null, message + ": " + errorObject.get("message").asString) - } catch(ex: Exception) { - return BintrayResponse(null, message) - } - } else { - return BintrayResponse(JsonParser().parse(r.body().string()).asJsonObject, null) - } - } - fun JsonObject.addNonNull(name: String, value: String?) { if (value != null) { addProperty(name, value); @@ -266,3 +218,31 @@ class BintrayApi @Inject constructor(val http: Http, } } + +class ConverterFactory : Converter.Factory() { + override fun responseBodyConverter(type: Type, annotations: Array, retrofit: Retrofit): Converter? { + return GsonResponseBodyConverter(Gson(), Gson().getAdapter(TypeToken.get(type))) + } + + override fun requestBodyConverter(type: Type, parameterAnnotations: Array, methodAnnotations: Array, + retrofit: Retrofit?): Converter<*, RequestBody>? { + return RequestBodyConverter() + } +} + +class GsonResponseBodyConverter(private val gson: Gson, private val adapter: TypeAdapter) : Converter { + override fun convert(value: ResponseBody): Any { + val jsonReader = gson.newJsonReader(value.charStream()) + try { + return adapter.read(jsonReader) + } finally { + value.close() + } + } +} + +class RequestBodyConverter : Converter { + override fun convert(value: File): RequestBody { + return CountingFileRequestBody(value, "application/*", { }) + } +} \ No newline at end of file From b6414f77401facca69fe1f5f4012924be2afcb5e Mon Sep 17 00:00:00 2001 From: DevCharly Date: Thu, 2 Jun 2016 17:26:55 +0200 Subject: [PATCH 025/106] fixed wrapper path in dist/kobaltw.bat --- dist/kobaltw.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/kobaltw.bat b/dist/kobaltw.bat index 52e2d636..8ce6a621 100644 --- a/dist/kobaltw.bat +++ b/dist/kobaltw.bat @@ -1,2 +1,2 @@ @echo off -java -jar "%~dp0/kobalt/wrapper/kobalt-wrapper.jar" %* +java -jar "%~dp0/../kobalt/wrapper/kobalt-wrapper.jar" %* From 2328287e03a82a697e6b44c030518455cd2a8175 Mon Sep 17 00:00:00 2001 From: DevCharly Date: Thu, 2 Jun 2016 17:58:38 +0200 Subject: [PATCH 026/106] support using plugins from directories (e.g. from IDE output folder, which makes plugin development easier) val p = plugins("my-plugin/classes") --- .../src/main/kotlin/com/beust/kobalt/Plugins.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/Plugins.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/Plugins.kt index c31837b0..dec39a1c 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/Plugins.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/Plugins.kt @@ -12,6 +12,7 @@ import com.beust.kobalt.misc.KFiles import com.beust.kobalt.misc.KobaltExecutors import com.beust.kobalt.misc.log import com.google.inject.Provider +import java.io.File import java.lang.reflect.Method import java.lang.reflect.Modifier import java.net.URLClassLoader @@ -160,9 +161,14 @@ class Plugins @Inject constructor (val taskManagerProvider : Provider Date: Wed, 1 Jun 2016 21:07:44 -0800 Subject: [PATCH 027/106] Comments. --- .../src/main/kotlin/com/beust/kobalt/Plugins.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/Plugins.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/Plugins.kt index dec39a1c..a31ddf41 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/Plugins.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/Plugins.kt @@ -161,10 +161,13 @@ class Plugins @Inject constructor (val taskManagerProvider : Provider Date: Wed, 1 Jun 2016 21:07:58 -0800 Subject: [PATCH 028/106] Minor fixes to KobaltClient. --- .../beust/kobalt/app/remote/KobaltClient.kt | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/com/beust/kobalt/app/remote/KobaltClient.kt b/src/main/kotlin/com/beust/kobalt/app/remote/KobaltClient.kt index 2b0cb10b..237c0ccb 100644 --- a/src/main/kotlin/com/beust/kobalt/app/remote/KobaltClient.kt +++ b/src/main/kotlin/com/beust/kobalt/app/remote/KobaltClient.kt @@ -17,6 +17,7 @@ import okhttp3.OkHttpClient import retrofit2.Call import retrofit2.Retrofit import retrofit2.converter.gson.GsonConverterFactory +import retrofit2.http.GET import retrofit2.http.POST import retrofit2.http.Query import java.io.* @@ -31,7 +32,10 @@ fun main(argv: Array) { } interface Api { - @POST("/getDependencies") + @GET("/ping") + fun ping() : Call + + @POST("/v0/getDependencies") fun getDependencies(@Query("buildFile") buildFile: String) : Call> } @@ -40,16 +44,25 @@ class KobaltClient : Runnable { private val service = Retrofit.Builder() .client(OkHttpClient.Builder().build()) - .baseUrl("http://localhost:1252") + .baseUrl("http://localhost:1238") .addConverterFactory(GsonConverterFactory.create()) .build() .create(Api::class.java) override fun run() { + +// val pong = service.ping().execute() +// println("Result from ping: " + pong) + val buildFile = Paths.get(SystemProperties.homeDir, "kotlin/klaxon/kobalt/src/Build.kt").toString() val dependencies = service.getDependencies(buildFile) - val results = dependencies.execute() - println("Dependencies: $results") + val response = dependencies.execute() + if (response.isSuccessful) { + println("Dependencies: $response") + } else { + println("Error calling getDependencies: " + response.errorBody().string()) + } + println("") } } From 48b5ad631dddd7db2676c05eb7e14d3ab74d6828 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Wed, 1 Jun 2016 21:09:28 -0800 Subject: [PATCH 029/106] 0.800. --- kobalt/wrapper/kobalt-wrapper.properties | 2 +- src/main/resources/kobalt.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties index 93d15fa3..f75c46b8 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=0.799 \ No newline at end of file +kobalt.version=0.800 \ No newline at end of file diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index 8fc4d5bb..3a5436f9 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=0.799 +kobalt.version=0.800 From 6e32b4ade20ac446299c95bf4dd7204025c36a70 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Wed, 1 Jun 2016 21:23:41 -0800 Subject: [PATCH 030/106] Update to Kotlin 1.0.2. --- kobalt.iml | 4 ++-- kobalt/src/Build.kt | 2 +- modules/kobalt-plugin-api/kobalt-plugin-api.iml | 8 ++++---- .../kotlin/com/beust/kobalt/internal/KobaltSettingsXml.kt | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/kobalt.iml b/kobalt.iml index da723b47..e9146d07 100644 --- a/kobalt.iml +++ b/kobalt.iml @@ -84,9 +84,9 @@ - + - + diff --git a/kobalt/src/Build.kt b/kobalt/src/Build.kt index afd4efe7..9fe73d5e 100644 --- a/kobalt/src/Build.kt +++ b/kobalt/src/Build.kt @@ -126,7 +126,7 @@ val kobaltApp = project(kobaltPluginApi, wrapper) { dependencies { // Used by the plugins - compile("org.jetbrains.kotlin:kotlin-compiler-embeddable:1.0.0") + compile("org.jetbrains.kotlin:kotlin-compiler-embeddable:1.0.2") // Used by the main app compile("com.github.spullara.mustache.java:compiler:0.9.1", diff --git a/modules/kobalt-plugin-api/kobalt-plugin-api.iml b/modules/kobalt-plugin-api/kobalt-plugin-api.iml index 96b5e27f..40595e33 100644 --- a/modules/kobalt-plugin-api/kobalt-plugin-api.iml +++ b/modules/kobalt-plugin-api/kobalt-plugin-api.iml @@ -12,9 +12,9 @@ - + - + @@ -390,9 +390,9 @@ - + - + diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/KobaltSettingsXml.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/KobaltSettingsXml.kt index 7bc02011..0bfb06ba 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/KobaltSettingsXml.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/KobaltSettingsXml.kt @@ -27,7 +27,7 @@ class KobaltSettingsXml { var proxy: ProxyXml? = null @XmlElement(name = "kobalt-compiler-version") @JvmField - var kobaltCompilerVersion: String = "1.0.0" + var kobaltCompilerVersion: String = "1.0.2" @XmlElement(name = "kobalt-compiler-repo") @JvmField var kobaltCompilerRepo: String? = null From d04879dde5dc012da9ae5f5d4f4fc1130b70e765 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Wed, 1 Jun 2016 21:39:28 -0800 Subject: [PATCH 031/106] GITHUB-220: Apt fix Fixes https://github.com/cbeust/kobalt/issues/220 --- .../kotlin/com/beust/kobalt/plugin/apt/AptPlugin.kt | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/com/beust/kobalt/plugin/apt/AptPlugin.kt b/src/main/kotlin/com/beust/kobalt/plugin/apt/AptPlugin.kt index 4c7f5e7c..386574e5 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/apt/AptPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/apt/AptPlugin.kt @@ -28,7 +28,10 @@ class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, va val result = if (config != null) { listOf(File( - KFiles.joinDir(KFiles.KOBALT_BUILD_DIR, config.outputDir, context.variant.toIntermediateDir()))) + KFiles.joinDir(project.directory, + KFiles.KOBALT_BUILD_DIR, + config.outputDir, + context.variant.toIntermediateDir()))) } else { emptyList() } @@ -54,13 +57,6 @@ class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, va val result = arrayListOf() configurationFor(project)?.let { config -> aptDependencies[project.name]?.let { aptDependencies -> - val deps = aptDependencies.map { dependencyManager.create(it) } - - val dependencies = context.dependencyManager.calculateDependencies(null, context, emptyList(), deps) - .map { it.jarFile.get().path } - - result.add("-processorpath") - result.add((dependencies).joinToString(":")) result.add("-s") result.add(generated(project, context, config.outputDir)) } From c71195e31dbd5abbb69ff459579b0ce2d107b26c Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Wed, 1 Jun 2016 21:39:46 -0800 Subject: [PATCH 032/106] 0.801. --- kobalt/wrapper/kobalt-wrapper.properties | 2 +- src/main/resources/kobalt.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties index f75c46b8..763cecf5 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=0.800 \ No newline at end of file +kobalt.version=0.801 \ No newline at end of file diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index 3a5436f9..6a120d3c 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=0.800 +kobalt.version=0.801 From b1b9c0472c33ffde2bc5938cf2a9f634baaef80b Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Wed, 1 Jun 2016 23:08:08 -0800 Subject: [PATCH 033/106] GITHUB-216: Source directories were leaking across projects. Fixes https://github.com/cbeust/kobalt/issues/216 --- .../beust/kobalt/internal/JvmCompilerPlugin.kt | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JvmCompilerPlugin.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JvmCompilerPlugin.kt index 41de8408..a67b976b 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JvmCompilerPlugin.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JvmCompilerPlugin.kt @@ -146,7 +146,6 @@ open class JvmCompilerPlugin @Inject constructor( @IncrementalTask(name = TASK_COMPILE_TEST, description = "Compile the tests", group = GROUP_BUILD, dependsOn = arrayOf(TASK_COMPILE)) fun taskCompileTest(project: Project): IncrementalTaskInfo { - sourceTestDirectories.addAll(context.variant.sourceDirectories(project, context, SourceSet.of(isTest = true))) return IncrementalTaskInfo( inputChecksum = { Md5.toMd5Directories(context.testSourceDirectories(project).map { File(project.directory, it.path)}) @@ -159,12 +158,12 @@ open class JvmCompilerPlugin @Inject constructor( ) } + private fun sourceDirectories(project: Project, context: KobaltContext) + = context.variant.sourceDirectories(project, context, SourceSet.of(isTest = false)) + @IncrementalTask(name = JvmCompilerPlugin.TASK_COMPILE, description = "Compile the project", group = GROUP_BUILD, runAfter = arrayOf(TASK_CLEAN)) fun taskCompile(project: Project): IncrementalTaskInfo { - // Set up the source files now that we have the variant - sourceDirectories.addAll(context.variant.sourceDirectories(project, context, SourceSet.of(isTest = false))) - return IncrementalTaskInfo( inputChecksum = { Md5.toMd5Directories(context.sourceDirectories(project).map { File(project.directory, it.path) }) @@ -205,8 +204,8 @@ open class JvmCompilerPlugin @Inject constructor( if (sourceFiles.size > 0) { // TODO: createCompilerActionInfo recalculates the source files, only compute them // once and pass them - val info = createCompilerActionInfo(project, context, compiler, isTest, sourceDirectories, - sourceSuffixes = compiler.sourceSuffixes) + val info = createCompilerActionInfo(project, context, compiler, isTest, + sourceDirectories(project, context), sourceSuffixes = compiler.sourceSuffixes) val thisResult = compiler.compile(project, context, info) results.add(thisResult) if (!thisResult.success && failedResult == null) { @@ -251,7 +250,7 @@ open class JvmCompilerPlugin @Inject constructor( it.compilersFor(project, context).forEach { compiler -> result = docGenerator.generateDoc(project, context, createCompilerActionInfo(project, context, compiler, - isTest = false, sourceDirectories = sourceDirectories, + isTest = false, sourceDirectories = sourceDirectories(project, context), sourceSuffixes = compiler.sourceSuffixes)) } } @@ -359,13 +358,10 @@ open class JvmCompilerPlugin @Inject constructor( return result } - val sourceDirectories = arrayListOf() - val sourceTestDirectories = arrayListOf() - // ISourceDirectoryContributor override fun sourceDirectoriesFor(project: Project, context: KobaltContext) = if (accept(project)) { - sourceDirectories.toList() + sourceDirectories(project, context) } else { arrayListOf() } From 10d8fe0149e70ec61ebd5b52b92e7f72b5ca4a4f Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Wed, 1 Jun 2016 23:10:05 -0800 Subject: [PATCH 034/106] 0.802. --- kobalt/wrapper/kobalt-wrapper.properties | 2 +- src/main/resources/kobalt.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties index 763cecf5..2afa42ef 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=0.801 \ No newline at end of file +kobalt.version=0.802 \ No newline at end of file diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index 6a120d3c..f70a6c4a 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=0.801 +kobalt.version=0.802 From 744f2ab052083c5f2c6153a3ef42899127e47148 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 2 Jun 2016 02:49:00 -0800 Subject: [PATCH 035/106] Initialize variant so it's ready for plugins in apply(). --- .../src/main/kotlin/com/beust/kobalt/api/TaskContributor.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/TaskContributor.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/TaskContributor.kt index 7fa33775..63cc655a 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/TaskContributor.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/TaskContributor.kt @@ -53,6 +53,7 @@ class TaskContributor @Inject constructor(val incrementalManagerFactory: Increme runTask: (Project) -> IncrementalTaskInfo) { Variant.allVariants(project).forEach { variant -> val variantTaskName = variant.toTask(taskName) + context.variant = variant dynamicTasks.add(DynamicTask(plugin, variantTaskName, variantTaskName, group, project, dependsOn = dependsOn.map { variant.toTask(it) }, reverseDependsOn = reverseDependsOn.map { variant.toTask(it) }, From 995706c8b7c2ab6b5d5354c74fdf1a8786989461 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 2 Jun 2016 02:49:08 -0800 Subject: [PATCH 036/106] Better plugin class loading. --- .../beust/kobalt/internal/KobaltPluginXml.kt | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/KobaltPluginXml.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/KobaltPluginXml.kt index b22ad6ba..33c0176e 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/KobaltPluginXml.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/KobaltPluginXml.kt @@ -156,10 +156,22 @@ class PluginInfo(val xml: KobaltPluginXml, val pluginClassLoader: ClassLoader?, GuiceFactory() } - fun forName(className: String) = - if (pluginClassLoader != null) pluginClassLoader.loadClass(className) - else if (classLoader != null) classLoader.loadClass(className) - else Class.forName(className) + fun forName(className: String) : Class<*> { + fun loadClass(className: String, classLoader: ClassLoader?) : Class<*>? { + try { + return classLoader?.loadClass(className) + } catch(ex: ClassNotFoundException) { + return null + } + } + + val result = loadClass(className, classLoader) + ?: Class.forName(className) + ?: loadClass(className, pluginClassLoader) + ?: throw ClassNotFoundException(className) + + return result + } // // Populate pluginInfo with what was found in Kobalt's own kobalt-plugin.xml From 5b9ac78f245b15ff9d31caeee28c83ad7c01d8ae Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 2 Jun 2016 02:49:15 -0800 Subject: [PATCH 037/106] Bump retrofit. --- kobalt/src/Build.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kobalt/src/Build.kt b/kobalt/src/Build.kt index 9fe73d5e..810d6020 100644 --- a/kobalt/src/Build.kt +++ b/kobalt/src/Build.kt @@ -21,7 +21,7 @@ import java.nio.file.StandardCopyOption object Versions { val okhttp = "3.2.0" val okio = "1.6.0" - val retrofit = "2.0.0" + val retrofit = "2.0.2" val gson = "2.6.2" val aether = "1.1.0" val sonatypeAether = "1.13.1" From 3ca7b95584d1633ab3ac6156821daf58b90e3856 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 2 Jun 2016 02:49:26 -0800 Subject: [PATCH 038/106] 0.803. --- kobalt/wrapper/kobalt-wrapper.properties | 2 +- src/main/resources/kobalt.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties index 2afa42ef..14b61b0b 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=0.802 \ No newline at end of file +kobalt.version=0.803 \ No newline at end of file diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index f70a6c4a..bc268f7e 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=0.802 +kobalt.version=0.803 From 634e319e5c63a6d2b3bfcecb18f344e40568920c Mon Sep 17 00:00:00 2001 From: evanchooly Date: Thu, 2 Jun 2016 22:28:04 -0400 Subject: [PATCH 039/106] readd support for auto-publishing --- .../beust/kobalt/plugin/publish/BintrayApi.kt | 25 ++++++------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/src/main/kotlin/com/beust/kobalt/plugin/publish/BintrayApi.kt b/src/main/kotlin/com/beust/kobalt/plugin/publish/BintrayApi.kt index 5fbe2791..8bbd7058 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/publish/BintrayApi.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/publish/BintrayApi.kt @@ -60,13 +60,14 @@ class BintrayApi @Inject constructor(val http: Http, fun createPackage(@Path("owner") owner: String, @Body content: JsonObject): Call - @PUT("/content/{owner}/maven/{repo}/{version}/{group}/{artifact}/{version}/{name}") + @PUT("/content/{owner}/maven/{repo}/{version}/{group}/{artifact}/{version}/{name};publish={publish}") fun uploadArtifact(@Path("owner") owner: String, @Path("repo") repo: String, @Path("group", encoded = true) group: String, @Path("artifact") artifact: String, @Path("version") version: String, @Path("name") name: String, + @Path("publish") publish: Int, @Body file: File): Call } @@ -122,18 +123,18 @@ class BintrayApi @Inject constructor(val http: Http, return jsonObject } - fun uploadMaven(project: Project, files: List, config: BintrayConfig?): TaskResult { + fun uploadMaven(project: Project, files: List, config: BintrayConfig): TaskResult { validatePackage(project) return upload(project, files, config, generateMd5 = true) } - fun uploadFile(project: Project, file: File, config: BintrayConfig?, generateMd5: Boolean = false) = + fun uploadFile(project: Project, file: File, config: BintrayConfig, generateMd5: Boolean = false) = upload(project, arrayListOf(file), config, generateMd5) - private fun upload(project: Project, files: List, config: BintrayConfig?, generateMd5: Boolean = false): TaskResult { + private fun upload(project: Project, files: List, config: BintrayConfig, generateMd5: Boolean): TaskResult { val filesToUpload = arrayListOf() - if (config != null && config.sign) { + if (config.sign) { // Create the .asc files filesToUpload.addAll(gpg.runGpg(files)) } @@ -150,17 +151,6 @@ class BintrayApi @Inject constructor(val http: Http, } } - // - // If any configuration was given, apply them so the URL reflects them, e.g. ?publish=1 - // - val options = arrayListOf() - if (config?.publish == true) options.add("publish=1") - - val optionPath = StringBuffer() - if (options.size > 0) { - optionPath.append("?" + options.joinToString("&")) - } - val fileCount = filesToUpload.size if (fileCount > 0) { log(1, " Found $fileCount artifacts to upload") @@ -180,7 +170,8 @@ class BintrayApi @Inject constructor(val http: Http, val artifact = project.artifactId!! val version = project.version!! - val result = service.uploadArtifact(owner, repo, group, artifact, version, file.name, file) + val result = service.uploadArtifact(owner, repo, group, artifact, version, file.name, + if (config.publish) 1 else 0, file) .execute() val error = result.errorBody()?.string() if (result.errorBody() != null) { From 709dec19b3e4900f5ed2e2737e4d58a15e6d27bb Mon Sep 17 00:00:00 2001 From: Jared Burrows Date: Thu, 2 Jun 2016 21:20:18 -0700 Subject: [PATCH 040/106] Update deps --- kobalt/src/Build.kt | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/kobalt/src/Build.kt b/kobalt/src/Build.kt index 810d6020..0c9d4266 100644 --- a/kobalt/src/Build.kt +++ b/kobalt/src/Build.kt @@ -19,8 +19,6 @@ import java.nio.file.Paths import java.nio.file.StandardCopyOption object Versions { - val okhttp = "3.2.0" - val okio = "1.6.0" val retrofit = "2.0.2" val gson = "2.6.2" val aether = "1.1.0" @@ -74,11 +72,10 @@ val kobaltPluginApi = project { "com.google.inject:guice:4.0", "com.google.inject.extensions:guice-assistedinject:4.0", "javax.inject:javax.inject:1", - "com.google.guava:guava:19.0-rc2", + "com.google.guava:guava:19.0", "org.apache.maven:maven-model:${Versions.maven}", - "io.reactivex:rxjava:1.0.16", + "io.reactivex:rxjava:1.1.5", "com.google.code.gson:gson:${Versions.gson}", - "com.squareup.okio:okio:${Versions.okio}", "com.squareup.retrofit2:retrofit:${Versions.retrofit}", "com.squareup.retrofit2:converter-gson:${Versions.retrofit}", "com.beust:jcommander:1.48", @@ -137,7 +134,6 @@ val kobaltApp = project(kobaltPluginApi, wrapper) { "org.apache.maven:maven-model:${Versions.maven}", "com.google.code.findbugs:jsr305:3.0.1", "com.google.code.gson:gson:${Versions.gson}", - "com.squareup.okhttp3:okhttp:${Versions.okhttp}", "com.squareup.retrofit2:retrofit:${Versions.retrofit}", "com.squareup.retrofit2:converter-gson:${Versions.retrofit}", "org.codehaus.plexus:plexus-utils:3.0.22", From f4b56981ea0b94197ebae8caa3a633e6ad8f87e5 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 2 Jun 2016 21:53:13 -0700 Subject: [PATCH 041/106] Bump log level to investigate travis failures --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 46fdae3d..43e61725 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,4 +10,4 @@ jdk: install: true -script: ./kobaltw assemble test --log 1 +script: ./kobaltw assemble test --log 2 From 6873c1fba462f5f55c6973a024bf7f192f7282fb Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 2 Jun 2016 22:02:01 -0700 Subject: [PATCH 042/106] Clean up build file. --- kobalt/src/Build.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kobalt/src/Build.kt b/kobalt/src/Build.kt index 0c9d4266..adef42a6 100644 --- a/kobalt/src/Build.kt +++ b/kobalt/src/Build.kt @@ -19,13 +19,13 @@ import java.nio.file.Paths import java.nio.file.StandardCopyOption object Versions { + val okhttp = "3.2.0" + val okio = "1.6.0" val retrofit = "2.0.2" val gson = "2.6.2" val aether = "1.1.0" val sonatypeAether = "1.13.1" val maven = "3.3.9" - val jersey = "2.22.2" - val jetty = "8.1.19.v20160209" // "9.3.9.M1" } val wrapper = project { @@ -75,7 +75,9 @@ val kobaltPluginApi = project { "com.google.guava:guava:19.0", "org.apache.maven:maven-model:${Versions.maven}", "io.reactivex:rxjava:1.1.5", + "com.squareup.okio:okio:${Versions.okio}", "com.google.code.gson:gson:${Versions.gson}", + "com.squareup.okhttp3:okhttp:${Versions.okhttp}", "com.squareup.retrofit2:retrofit:${Versions.retrofit}", "com.squareup.retrofit2:converter-gson:${Versions.retrofit}", "com.beust:jcommander:1.48", From 7b8b0bbfc181048384349ae9571f6052cff50954 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 2 Jun 2016 21:28:27 -0800 Subject: [PATCH 043/106] Extract the compiler logic so apt can call it. --- .../beust/kobalt/internal/CompilerUtils.kt | 169 +++++++++++++++++ .../kobalt/internal/JvmCompilerPlugin.kt | 177 ++---------------- 2 files changed, 185 insertions(+), 161 deletions(-) create mode 100644 modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/CompilerUtils.kt diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/CompilerUtils.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/CompilerUtils.kt new file mode 100644 index 00000000..8d9b9294 --- /dev/null +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/CompilerUtils.kt @@ -0,0 +1,169 @@ +package com.beust.kobalt.internal + +import com.beust.kobalt.TaskResult +import com.beust.kobalt.api.* +import com.beust.kobalt.maven.DependencyManager +import com.beust.kobalt.misc.KFiles +import com.beust.kobalt.misc.log +import com.google.inject.Inject +import java.io.File +import java.util.* + +/** + * Central place to compile files, used by plug-ins and non plug-ins. + */ +class CompilerUtils @Inject constructor(val files: KFiles, + val dependencyManager: DependencyManager) { + + fun invokeCompiler(project: Project, context: KobaltContext, compiler: ICompiler, + sourceDirectories: List, isTest: Boolean): + Pair, TaskResult?> { + val results = arrayListOf() + var failedResult: TaskResult? = null + val contributedSourceDirs = + if (isTest) { + context.testSourceDirectories(project) + } else { + context.sourceDirectories(project) + } + val sourceFiles = KFiles.findSourceFiles(project.directory, + contributedSourceDirs.map { it.path }, compiler.sourceSuffixes) + if (sourceFiles.size > 0) { + // TODO: createCompilerActionInfo recalculates the source files, only compute them + // once and pass them + val info = createCompilerActionInfo(project, context, compiler, isTest, + sourceDirectories, sourceSuffixes = compiler.sourceSuffixes) + val thisResult = compiler.compile(project, context, info) + results.add(thisResult) + if (!thisResult.success && failedResult == null) { + failedResult = thisResult + } + } else { + log(2, "Compiler $compiler not running on ${project.name} since no source files were found") + } + + return Pair(results, failedResult) + } + + /** + * Create a CompilerActionInfo (all the information that a compiler needs to know) for the given parameters. + * Runs all the contributors and interceptors relevant to that task. + */ + fun createCompilerActionInfo(project: Project, context: KobaltContext, compiler: ICompiler, + isTest: Boolean, sourceDirectories: List, sourceSuffixes: List): CompilerActionInfo { + copyResources(project, context, SourceSet.of(isTest)) + + val fullClasspath = if (isTest) dependencyManager.testDependencies(project, context) + else dependencyManager.dependencies(project, context) + + // Remove all the excluded dependencies from the classpath + val classpath = fullClasspath.filter { + ! isDependencyExcluded(it, project.excludedDependencies) + } + + val buildDirectory = if (isTest) File(project.buildDirectory, KFiles.TEST_CLASSES_DIR) + else File(project.classesDir(context)) + buildDirectory.mkdirs() + + + val initialSourceDirectories = ArrayList(sourceDirectories) + // Source directories from the contributors + val contributedSourceDirs = + if (isTest) { + context.pluginInfo.testSourceDirContributors.flatMap { it.testSourceDirectoriesFor(project, context) } + } else { + context.pluginInfo.sourceDirContributors.flatMap { it.sourceDirectoriesFor(project, context) } + } + + initialSourceDirectories.addAll(contributedSourceDirs) + + // Transform them with the interceptors, if any + val allSourceDirectories = + if (isTest) { + initialSourceDirectories + } else { + context.pluginInfo.sourceDirectoriesInterceptors.fold(initialSourceDirectories.toList(), + { sd, interceptor -> interceptor.intercept(project, context, sd) }) + }.filter { + File(project.directory, it.path).exists() + }.filter { + ! KFiles.isResource(it.path) + }.distinct() + + // Now that we have all the source directories, find all the source files in them + val projectDirectory = File(project.directory) + val sourceFiles = if (compiler.canCompileDirectories) { + allSourceDirectories.map { File(projectDirectory, it.path).path } + } else { + files.findRecursively(projectDirectory, allSourceDirectories, + { file -> sourceSuffixes.any { file.endsWith(it) } }) + .map { File(projectDirectory, it).path } + } + + // Special treatment if we are compiling Kotlin files and the project also has a java source + // directory. In this case, also pass that java source directory to the Kotlin compiler as is + // so that it can parse its symbols + // Note: this should actually be queried on the compiler object so that this method, which + // is compiler agnostic, doesn't hardcode Kotlin specific stuff + val extraSourceFiles = arrayListOf() + if (sourceSuffixes.any { it.contains("kt")}) { + project.sourceDirectories.forEach { + val javaDir = KFiles.joinDir(project.directory, it) + if (File(javaDir).exists()) { + if (it.contains("java")) { + extraSourceFiles.add(javaDir) + // Add all the source directories contributed as potential Java directories too + // (except our own) + context.pluginInfo.sourceDirContributors +// .filter { it != this } + .forEach { + extraSourceFiles.addAll(it.sourceDirectoriesFor(project, context).map { it.path }) + } + + } + } + } + } + + val allSources = (sourceFiles + extraSourceFiles).distinct().filter { File(it).exists() } + + // Finally, alter the info with the compiler interceptors before returning it + val initialActionInfo = CompilerActionInfo(projectDirectory.path, classpath, allSources, + sourceSuffixes, buildDirectory, emptyList() /* the flags will be provided by flag contributors */) + val result = context.pluginInfo.compilerInterceptors.fold(initialActionInfo, { ai, interceptor -> + interceptor.intercept(project, context, ai) + }) + return result + } + + /** + * Copy the resources from a source directory to the build one + */ + private fun copyResources(project: Project, context: KobaltContext, sourceSet: SourceSet) { + var outputDir = sourceSet.outputDir + + val variantSourceDirs = context.variant.resourceDirectories(project, sourceSet) + if (variantSourceDirs.size > 0) { + JvmCompilerPlugin.lp(project, "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) + } + } else { + JvmCompilerPlugin.lp(project, "No resources to copy for $sourceSet") + } + } + + + /** + * Naïve implementation: just exclude all dependencies that start with one of the excluded dependencies. + * Should probably make exclusion more generic (full on string) or allow exclusion to be specified + * formally by groupId or artifactId. + */ + private fun isDependencyExcluded(id: IClasspathDependency, excluded: List) + = excluded.any { id.id.startsWith(it.id) } + +} diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JvmCompilerPlugin.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JvmCompilerPlugin.kt index a67b976b..3e52c46e 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JvmCompilerPlugin.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JvmCompilerPlugin.kt @@ -16,7 +16,6 @@ import com.beust.kobalt.misc.KobaltExecutors import com.beust.kobalt.misc.log import com.beust.kobalt.misc.warn import java.io.File -import java.util.* import javax.inject.Inject import javax.inject.Singleton @@ -30,7 +29,8 @@ open class JvmCompilerPlugin @Inject constructor( open val files: KFiles, open val dependencyManager: DependencyManager, open val executors: KobaltExecutors, - open val taskContributor : TaskContributor) + open val taskContributor : TaskContributor, + val compilerUtils: CompilerUtils) : BasePlugin(), ISourceDirectoryContributor, IProjectContributor, ITaskContributor by taskContributor { companion object { @@ -52,19 +52,19 @@ 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 override fun accept(project: Project) = true - /** - * Log with a project. - */ - protected fun lp(project: Project, s: String) { - log(2, "${project.name}: $s") - } - override fun apply(project: Project, context: KobaltContext) { super.apply(project, context) // cleanUpActors() @@ -112,37 +112,6 @@ open class JvmCompilerPlugin @Inject constructor( return TaskResult() } - /** - * Copy the resources from a source directory to the build one - */ - protected fun copyResources(project: Project, sourceSet: SourceSet) { - var outputDir = sourceSet.outputDir - - val variantSourceDirs = context.variant.resourceDirectories(project, sourceSet) - if (variantSourceDirs.size > 0) { - lp(project, "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) - } - } else { - lp(project, "No resources to copy for $sourceSet") - } - } - - protected fun compilerArgsFor(project: Project): List { - val result = project.projectProperties.get(COMPILER_ARGS) - if (result != null) { - @Suppress("UNCHECKED_CAST") - return result as List - } else { - return emptyList() - } - } - @IncrementalTask(name = TASK_COMPILE_TEST, description = "Compile the tests", group = GROUP_BUILD, dependsOn = arrayOf(TASK_COMPILE)) fun taskCompileTest(project: Project): IncrementalTaskInfo { @@ -193,27 +162,10 @@ open class JvmCompilerPlugin @Inject constructor( } else { val allCompilers = compilerContributors.flatMap { it.compilersFor(project, context)}.sorted() allCompilers.forEach { compiler -> - val contributedSourceDirs = - if (isTest) { - context.testSourceDirectories(project) - } else { - context.sourceDirectories(project) - } - val sourceFiles = KFiles.findSourceFiles(project.directory, - contributedSourceDirs.map { it.path }, compiler.sourceSuffixes) - if (sourceFiles.size > 0) { - // TODO: createCompilerActionInfo recalculates the source files, only compute them - // once and pass them - val info = createCompilerActionInfo(project, context, compiler, isTest, - sourceDirectories(project, context), sourceSuffixes = compiler.sourceSuffixes) - val thisResult = compiler.compile(project, context, info) - results.add(thisResult) - if (!thisResult.success && failedResult == null) { - failedResult = thisResult - } - } else { - log(2, "Compiler $compiler not running on ${project.name} since no source files were found") - } + val compilerResults = compilerUtils.invokeCompiler(project, context, compiler, + sourceDirectories(project, context), isTest) + results.addAll(compilerResults.first) + if (failedResult == null) failedResult = compilerResults.second } return if (failedResult != null) failedResult!! else if (results.size > 0) results[0] @@ -248,9 +200,9 @@ open class JvmCompilerPlugin @Inject constructor( var result: TaskResult? = null contributors.forEach { it.compilersFor(project, context).forEach { compiler -> - result = docGenerator.generateDoc(project, context, createCompilerActionInfo(project, context, - compiler, - isTest = false, sourceDirectories = sourceDirectories(project, context), + result = docGenerator.generateDoc(project, context, + compilerUtils.createCompilerActionInfo(project, context, compiler, + isTest = false, sourceDirectories = sourceDirectories(project, context), sourceSuffixes = compiler.sourceSuffixes)) } } @@ -261,103 +213,6 @@ open class JvmCompilerPlugin @Inject constructor( } } - /** - * Naïve implementation: just exclude all dependencies that start with one of the excluded dependencies. - * Should probably make exclusion more generic (full on string) or allow exclusion to be specified - * formally by groupId or artifactId. - */ - private fun isDependencyExcluded(id: IClasspathDependency, excluded: List) - = excluded.any { id.id.startsWith(it.id) } - - /** - * Create a CompilerActionInfo (all the information that a compiler needs to know) for the given parameters. - * Runs all the contributors and interceptors relevant to that task. - */ - protected fun createCompilerActionInfo(project: Project, context: KobaltContext, compiler: ICompiler, - isTest: Boolean, sourceDirectories: List, sourceSuffixes: List): CompilerActionInfo { - copyResources(project, SourceSet.of(isTest)) - - val fullClasspath = if (isTest) dependencyManager.testDependencies(project, context) - else dependencyManager.dependencies(project, context) - - // Remove all the excluded dependencies from the classpath - val classpath = fullClasspath.filter { - ! isDependencyExcluded(it, project.excludedDependencies) - } - - val buildDirectory = if (isTest) File(project.buildDirectory, KFiles.TEST_CLASSES_DIR) - else File(project.classesDir(context)) - buildDirectory.mkdirs() - - - val initialSourceDirectories = ArrayList(sourceDirectories) - // Source directories from the contributors - val contributedSourceDirs = - if (isTest) { - context.pluginInfo.testSourceDirContributors.flatMap { it.testSourceDirectoriesFor(project, context) } - } else { - context.pluginInfo.sourceDirContributors.flatMap { it.sourceDirectoriesFor(project, context) } - } - - initialSourceDirectories.addAll(contributedSourceDirs) - - // Transform them with the interceptors, if any - val allSourceDirectories = - if (isTest) { - initialSourceDirectories - } else { - context.pluginInfo.sourceDirectoriesInterceptors.fold(initialSourceDirectories.toList(), - { sd, interceptor -> interceptor.intercept(project, context, sd) }) - }.filter { - File(project.directory, it.path).exists() - }.filter { - ! KFiles.isResource(it.path) - }.distinct() - - // Now that we have all the source directories, find all the source files in them - val projectDirectory = File(project.directory) - val sourceFiles = if (compiler.canCompileDirectories) { - allSourceDirectories.map { File(projectDirectory, it.path).path } - } else { - files.findRecursively(projectDirectory, allSourceDirectories, - { file -> sourceSuffixes.any { file.endsWith(it) } }) - .map { File(projectDirectory, it).path } - } - - // Special treatment if we are compiling Kotlin files and the project also has a java source - // directory. In this case, also pass that java source directory to the Kotlin compiler as is - // so that it can parse its symbols - // Note: this should actually be queried on the compiler object so that this method, which - // is compiler agnostic, doesn't hardcode Kotlin specific stuff - val extraSourceFiles = arrayListOf() - if (sourceSuffixes.any { it.contains("kt")}) { - project.sourceDirectories.forEach { - val javaDir = KFiles.joinDir(project.directory, it) - if (File(javaDir).exists()) { - if (it.contains("java")) { - extraSourceFiles.add(javaDir) - // Add all the source directories contributed as potential Java directories too - // (except our own) - context.pluginInfo.sourceDirContributors.filter { it != this }.forEach { - extraSourceFiles.addAll(it.sourceDirectoriesFor(project, context).map { it.path }) - } - - } - } - } - } - - val allSources = (sourceFiles + extraSourceFiles).distinct().filter { File(it).exists() } - - // Finally, alter the info with the compiler interceptors before returning it - val initialActionInfo = CompilerActionInfo(projectDirectory.path, classpath, allSources, - sourceSuffixes, buildDirectory, emptyList() /* the flags will be provided by flag contributors */) - val result = context.pluginInfo.compilerInterceptors.fold(initialActionInfo, { ai, interceptor -> - interceptor.intercept(project, context, ai) - }) - return result - } - // ISourceDirectoryContributor override fun sourceDirectoriesFor(project: Project, context: KobaltContext) = if (accept(project)) { From 814eb5739665459610f1533c1140da75ee1f325a Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 2 Jun 2016 21:29:51 -0800 Subject: [PATCH 044/106] Refactor. --- .../main/kotlin/com/beust/kobalt/internal/CompilerUtils.kt | 7 ++++--- .../kotlin/com/beust/kobalt/internal/JvmCompilerPlugin.kt | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/CompilerUtils.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/CompilerUtils.kt index 8d9b9294..c078c996 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/CompilerUtils.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/CompilerUtils.kt @@ -15,9 +15,10 @@ import java.util.* class CompilerUtils @Inject constructor(val files: KFiles, val dependencyManager: DependencyManager) { + class CompilerResult(val successResults: List, val failedResult: TaskResult?) + fun invokeCompiler(project: Project, context: KobaltContext, compiler: ICompiler, - sourceDirectories: List, isTest: Boolean): - Pair, TaskResult?> { + sourceDirectories: List, isTest: Boolean): CompilerResult { val results = arrayListOf() var failedResult: TaskResult? = null val contributedSourceDirs = @@ -42,7 +43,7 @@ class CompilerUtils @Inject constructor(val files: KFiles, log(2, "Compiler $compiler not running on ${project.name} since no source files were found") } - return Pair(results, failedResult) + return CompilerResult(results, failedResult) } /** diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JvmCompilerPlugin.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JvmCompilerPlugin.kt index 3e52c46e..0e7bc9be 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JvmCompilerPlugin.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JvmCompilerPlugin.kt @@ -164,8 +164,8 @@ open class JvmCompilerPlugin @Inject constructor( allCompilers.forEach { compiler -> val compilerResults = compilerUtils.invokeCompiler(project, context, compiler, sourceDirectories(project, context), isTest) - results.addAll(compilerResults.first) - if (failedResult == null) failedResult = compilerResults.second + results.addAll(compilerResults.successResults) + if (failedResult == null) failedResult = compilerResults.failedResult } return if (failedResult != null) failedResult!! else if (results.size > 0) results[0] From a4a044c6b9836a3a9ff802d252bc97a228378a30 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 2 Jun 2016 23:37:39 -0800 Subject: [PATCH 045/106] kapt work. --- .../main/kotlin/com/beust/kobalt/Plugins.kt | 4 +- .../com/beust/kobalt/api/ITaskContributor.kt | 2 +- .../com/beust/kobalt/api/TaskContributor.kt | 2 +- .../beust/kobalt/internal/CompilerUtils.kt | 23 ++++-- .../plugin/application/ApplicationPlugin.kt | 2 +- .../com/beust/kobalt/plugin/apt/AptPlugin.kt | 72 ++++++++++++++++++- .../plugin/packaging/PackagingPlugin.kt | 2 +- 7 files changed, 93 insertions(+), 14 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/Plugins.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/Plugins.kt index a31ddf41..29e902e1 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/Plugins.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/Plugins.kt @@ -79,7 +79,9 @@ class Plugins @Inject constructor (val taskManagerProvider : Provider + taskManager.dynamicTasks.addAll(it.tasksFor(project, context)) + } } // Now that we have collected all static and dynamic tasks, turn them all into plug-in tasks diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/ITaskContributor.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/ITaskContributor.kt index 55eed61a..83621451 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/ITaskContributor.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/ITaskContributor.kt @@ -8,7 +8,7 @@ import com.beust.kobalt.internal.TaskResult2 * to implement this interface. */ interface ITaskContributor : IContributor { - fun tasksFor(context: KobaltContext) : List + fun tasksFor(project: Project, context: KobaltContext) : List } class DynamicTask(override val plugin: IPlugin, override val name: String, override val doc: String, diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/TaskContributor.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/TaskContributor.kt index 63cc655a..65eb529d 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/TaskContributor.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/TaskContributor.kt @@ -63,5 +63,5 @@ class TaskContributor @Inject constructor(val incrementalManagerFactory: Increme } } - override fun tasksFor(context: KobaltContext) : List = dynamicTasks + override fun tasksFor(project: Project, context: KobaltContext) : List = dynamicTasks } diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/CompilerUtils.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/CompilerUtils.kt index c078c996..9e0747b0 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/CompilerUtils.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/CompilerUtils.kt @@ -34,10 +34,10 @@ class CompilerUtils @Inject constructor(val files: KFiles, // once and pass them val info = createCompilerActionInfo(project, context, compiler, isTest, sourceDirectories, sourceSuffixes = compiler.sourceSuffixes) - val thisResult = compiler.compile(project, context, info) - results.add(thisResult) - if (!thisResult.success && failedResult == null) { - failedResult = thisResult + val thisResult = invokeCompiler(project, context, compiler, info) + results.addAll(thisResult.successResults) + if (failedResult == null) { + failedResult = thisResult.failedResult } } else { log(2, "Compiler $compiler not running on ${project.name} since no source files were found") @@ -46,6 +46,18 @@ class CompilerUtils @Inject constructor(val files: KFiles, return CompilerResult(results, failedResult) } + fun invokeCompiler(project: Project, context: KobaltContext, compiler: ICompiler, info: CompilerActionInfo) + : CompilerResult { + val results = arrayListOf() + var failedResult: TaskResult? = null + val thisResult = compiler.compile(project, context, info) + results.add(thisResult) + if (!thisResult.success && failedResult == null) { + failedResult = thisResult + } + return CompilerResult(results, failedResult) + } + /** * Create a CompilerActionInfo (all the information that a compiler needs to know) for the given parameters. * Runs all the contributors and interceptors relevant to that task. @@ -55,7 +67,7 @@ class CompilerUtils @Inject constructor(val files: KFiles, copyResources(project, context, SourceSet.of(isTest)) val fullClasspath = if (isTest) dependencyManager.testDependencies(project, context) - else dependencyManager.dependencies(project, context) + else dependencyManager.dependencies(project, context) // Remove all the excluded dependencies from the classpath val classpath = fullClasspath.filter { @@ -66,7 +78,6 @@ class CompilerUtils @Inject constructor(val files: KFiles, else File(project.classesDir(context)) buildDirectory.mkdirs() - val initialSourceDirectories = ArrayList(sourceDirectories) // Source directories from the contributors val contributedSourceDirs = diff --git a/src/main/kotlin/com/beust/kobalt/plugin/application/ApplicationPlugin.kt b/src/main/kotlin/com/beust/kobalt/plugin/application/ApplicationPlugin.kt index 9f6a4e9f..483a9f3f 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/application/ApplicationPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/application/ApplicationPlugin.kt @@ -127,6 +127,6 @@ class ApplicationPlugin @Inject constructor(val configActor: ConfigActor = taskContributor.dynamicTasks + override fun tasksFor(project: Project, context: KobaltContext): List = taskContributor.dynamicTasks } diff --git a/src/main/kotlin/com/beust/kobalt/plugin/apt/AptPlugin.kt b/src/main/kotlin/com/beust/kobalt/plugin/apt/AptPlugin.kt index 386574e5..cf2b93d5 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/apt/AptPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/apt/AptPlugin.kt @@ -2,12 +2,16 @@ package com.beust.kobalt.plugin.apt import com.beust.kobalt.api.* import com.beust.kobalt.api.annotation.Directive +import com.beust.kobalt.internal.ActorUtils +import com.beust.kobalt.internal.CompilerUtils import com.beust.kobalt.maven.DependencyManager import com.beust.kobalt.misc.KFiles import com.beust.kobalt.misc.log import com.google.common.collect.ArrayListMultimap import com.google.inject.Inject import java.io.File +import java.nio.file.Files +import java.util.* import javax.inject.Singleton /** @@ -18,8 +22,10 @@ import javax.inject.Singleton * (outputDir, etc...). */ @Singleton -class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, val configActor: ConfigActor) - : BasePlugin(), ICompilerFlagContributor, ISourceDirectoryContributor, IConfigActor by configActor { +class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, val configActor: ConfigActor, + val compilerUtils: CompilerUtils) + : BasePlugin(), ICompilerFlagContributor, ISourceDirectoryContributor, ITaskContributor, + IConfigActor by configActor { // ISourceDirectoryContributor @@ -45,6 +51,51 @@ class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, va override val name = PLUGIN_NAME + override fun apply(project: Project, context: KobaltContext) { + } + + // ITaskContributor + override fun tasksFor(project: Project, context: KobaltContext) : List { +// val kapt = kaptConfigs[project.name] +// if (kapt != null) { +// return listOf(DynamicTask(this, "kapt", "Run kapt", project = project, +// reverseDependsOn = listOf(JvmCompilerPlugin.TASK_COMPILE), +// group = AnnotationDefault.GROUP, +// closure = { project -> +// runApt(project, context) +// TaskResult() +// })) +// } else { + return emptyList() +// } +// + } + + private fun runApt(project: Project, context: KobaltContext) { + val kapt = kaptConfigs[project.name] + if (kapt != null) { + + val sourceDir = Files.createTempDirectory("kobalt").toFile() + val javaFile = File(sourceDir, "A.java").apply { + appendText("class A {}") + } + val compilerContributors = context.pluginInfo.compilerContributors + ActorUtils.selectAffinityActors(project, context, + context.pluginInfo.compilerContributors) + + val allCompilers = compilerContributors.flatMap { it.compilersFor(project, context) }.sorted() + val javaCompiler = allCompilers.filter { it.sourceSuffixes.contains("java") }[0] + + val dependencies = dependencyManager.calculateDependencies(project, context) + val info = CompilerActionInfo(sourceDir.absolutePath, dependencies, + listOf(javaFile.absolutePath), listOf("java"), File(sourceDir, "generated"), + listOf()) + + val results = compilerUtils.invokeCompiler(project, context, javaCompiler, info) + println("RESULTS: $results") + } + } + private fun generated(project: Project, context: KobaltContext, outputDir: String) = KFiles.joinAndMakeDir(project.directory, project.buildDirectory, outputDir, context.variant.toIntermediateDir()) @@ -55,6 +106,7 @@ class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, va if (!suffixesBeingCompiled.contains("java")) return emptyList() val result = arrayListOf() + configurationFor(project)?.let { config -> aptDependencies[project.name]?.let { aptDependencies -> result.add("-s") @@ -70,12 +122,16 @@ class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, va fun addAptDependency(dependencies: Dependencies, it: String) { aptDependencies.put(dependencies.project.name, it) } + + private val kaptConfigs: HashMap = hashMapOf() + + fun addKaptConfig(project: Project, kapt: KaptConfig) = kaptConfigs.put(project.name, kapt) } class AptConfig(var outputDir: String = "generated/source/apt") @Directive -public fun Project.apt(init: AptConfig.() -> Unit) { +fun Project.apt(init: AptConfig.() -> Unit) { AptConfig().let { it.init() (Kobalt.findPlugin(AptPlugin.PLUGIN_NAME) as AptPlugin).addConfiguration(this, it) @@ -88,3 +144,13 @@ fun Dependencies.apt(vararg dep: String) { (Kobalt.findPlugin(AptPlugin.PLUGIN_NAME) as AptPlugin).addAptDependency(this, it) } } + +class KaptConfig(var outputDir: String = "generated/source/apt") + +@Directive +fun Project.kapt(init: KaptConfig.() -> Unit) { + KaptConfig().let { + it.init() + (Kobalt.findPlugin(AptPlugin.PLUGIN_NAME) as AptPlugin).addKaptConfig(this, it) + } +} diff --git a/src/main/kotlin/com/beust/kobalt/plugin/packaging/PackagingPlugin.kt b/src/main/kotlin/com/beust/kobalt/plugin/packaging/PackagingPlugin.kt index 79c5695e..aba925bc 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/packaging/PackagingPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/packaging/PackagingPlugin.kt @@ -151,7 +151,7 @@ class PackagingPlugin @Inject constructor(val dependencyManager : DependencyMana } //ITaskContributor - override fun tasksFor(context: KobaltContext): List = taskContributor.dynamicTasks + override fun tasksFor(project: Project, context: KobaltContext): List = taskContributor.dynamicTasks } @Directive From e8910259285950aa3e6860ea4ae39bdd3de78a9e Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 2 Jun 2016 23:37:54 -0800 Subject: [PATCH 046/106] 0.804. --- kobalt/wrapper/kobalt-wrapper.properties | 2 +- src/main/resources/kobalt.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties index 14b61b0b..b1db3e5c 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=0.803 \ No newline at end of file +kobalt.version=0.804 \ No newline at end of file diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index bc268f7e..c97ce8f2 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=0.803 +kobalt.version=0.804 From 5645d54e3556ee8a0cad5d2feb7bde2d25764124 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Fri, 3 Jun 2016 02:06:23 -0800 Subject: [PATCH 047/106] If kapt{} detected, run javac before kotlinc. --- .../kobalt/internal/JvmCompilerPlugin.kt | 23 ++++++++++++++++++- .../com/beust/kobalt/plugin/apt/AptPlugin.kt | 6 ++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JvmCompilerPlugin.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JvmCompilerPlugin.kt index 0e7bc9be..94b2edc5 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JvmCompilerPlugin.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JvmCompilerPlugin.kt @@ -16,6 +16,7 @@ import com.beust.kobalt.misc.KobaltExecutors import com.beust.kobalt.misc.log import com.beust.kobalt.misc.warn import java.io.File +import java.util.* import javax.inject.Inject import javax.inject.Singleton @@ -161,12 +162,32 @@ open class JvmCompilerPlugin @Inject constructor( throw KobaltException("Couldn't find any compiler for project ${project.name}") } else { val allCompilers = compilerContributors.flatMap { it.compilersFor(project, context)}.sorted() - allCompilers.forEach { compiler -> + + /** + * Swap the Java and Kotlin compilers from the list. + */ + fun swapJavaAndKotlin(allCompilers: List): List { + val result = ArrayList(allCompilers) + var ik = -1 + var ij = -1 + allCompilers.withIndex().forEach { wi -> + if (wi.value.sourceSuffixes.contains("java")) ij = wi.index + if (wi.value.sourceSuffixes.contains("kt")) ik = wi.index + } + Collections.swap(result, ik, ij) + return result + } + + // If this project has a kapt{} directive, we want to run the Java compiler first + val hasKapt = project.projectProperties.get("kaptConfig") != null + var finalAllCompilers = if (hasKapt) swapJavaAndKotlin(allCompilers) else allCompilers + finalAllCompilers.forEach { compiler -> val compilerResults = compilerUtils.invokeCompiler(project, context, compiler, sourceDirectories(project, context), isTest) results.addAll(compilerResults.successResults) if (failedResult == null) failedResult = compilerResults.failedResult } + return if (failedResult != null) failedResult!! else if (results.size > 0) results[0] else TaskResult(true) diff --git a/src/main/kotlin/com/beust/kobalt/plugin/apt/AptPlugin.kt b/src/main/kotlin/com/beust/kobalt/plugin/apt/AptPlugin.kt index cf2b93d5..9a930ed9 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/apt/AptPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/apt/AptPlugin.kt @@ -47,6 +47,7 @@ class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, va companion object { const val PLUGIN_NAME = "Apt" + const val KAPT_CONFIG = "kaptConfig" } override val name = PLUGIN_NAME @@ -125,7 +126,10 @@ class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, va private val kaptConfigs: HashMap = hashMapOf() - fun addKaptConfig(project: Project, kapt: KaptConfig) = kaptConfigs.put(project.name, kapt) + fun addKaptConfig(project: Project, kapt: KaptConfig) { + project.projectProperties.put(KAPT_CONFIG, kapt) + kaptConfigs.put(project.name, kapt) + } } class AptConfig(var outputDir: String = "generated/source/apt") From e494e1a6b4af3845bfaaceba107d744825ac391a Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Fri, 3 Jun 2016 02:06:29 -0800 Subject: [PATCH 048/106] 0.805. --- kobalt/wrapper/kobalt-wrapper.properties | 2 +- src/main/resources/kobalt.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties index b1db3e5c..d53826ad 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=0.804 \ No newline at end of file +kobalt.version=0.805 \ No newline at end of file diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index c97ce8f2..d072c7d9 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=0.804 +kobalt.version=0.805 From f616bcee17d5616fa0c0249c52921d9aa9e18e21 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Fri, 3 Jun 2016 02:39:44 -0800 Subject: [PATCH 049/106] Clean up apt work. --- .../com/beust/kobalt/plugin/apt/AptPlugin.kt | 56 ++++++++++++------- 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/src/main/kotlin/com/beust/kobalt/plugin/apt/AptPlugin.kt b/src/main/kotlin/com/beust/kobalt/plugin/apt/AptPlugin.kt index 9a930ed9..0aede4b9 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/apt/AptPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/apt/AptPlugin.kt @@ -22,25 +22,26 @@ import javax.inject.Singleton * (outputDir, etc...). */ @Singleton -class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, val configActor: ConfigActor, - val compilerUtils: CompilerUtils) - : BasePlugin(), ICompilerFlagContributor, ISourceDirectoryContributor, ITaskContributor, - IConfigActor by configActor { +class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, val compilerUtils: CompilerUtils) + : BasePlugin(), ICompilerFlagContributor, ISourceDirectoryContributor, ITaskContributor { // ISourceDirectoryContributor override fun sourceDirectoriesFor(project: Project, context: KobaltContext): List { - val config = configurationFor(project) - val result = - if (config != null) { - listOf(File( - KFiles.joinDir(project.directory, - KFiles.KOBALT_BUILD_DIR, - config.outputDir, - context.variant.toIntermediateDir()))) - } else { - emptyList() - } + val result = arrayListOf() + aptConfigs[project.name]?.let { config -> + result.add(File( + KFiles.joinDir(project.directory, + KFiles.KOBALT_BUILD_DIR, + config.outputDir))) + } + + kaptConfigs[project.name]?.let { config -> + result.add(File( + KFiles.joinDir(project.directory, + KFiles.KOBALT_BUILD_DIR, + config.outputDir))) + } return result } @@ -48,6 +49,7 @@ class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, va companion object { const val PLUGIN_NAME = "Apt" const val KAPT_CONFIG = "kaptConfig" + const val APT_CONFIG = "aptConfig" } override val name = PLUGIN_NAME @@ -93,7 +95,6 @@ class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, va listOf()) val results = compilerUtils.invokeCompiler(project, context, javaCompiler, info) - println("RESULTS: $results") } } @@ -108,13 +109,22 @@ class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, va val result = arrayListOf() - configurationFor(project)?.let { config -> + fun addFlags(outputDir: String) { aptDependencies[project.name]?.let { aptDependencies -> result.add("-s") - result.add(generated(project, context, config.outputDir)) + result.add(generated(project, context, outputDir)) } - log(2, "New flags from apt: " + result.joinToString(" ")) } + + aptConfigs[project.name]?.let { config -> + addFlags(config.outputDir) + } + + kaptConfigs[project.name]?.let { config -> + addFlags(config.outputDir) + } + + log(2, "New flags from apt: " + result.joinToString(" ")) return result } @@ -124,8 +134,14 @@ class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, va aptDependencies.put(dependencies.project.name, it) } + private val aptConfigs: HashMap = hashMapOf() private val kaptConfigs: HashMap = hashMapOf() + fun addAptConfig(project: Project, kapt: AptConfig) { + project.projectProperties.put(APT_CONFIG, kapt) + aptConfigs.put(project.name, kapt) + } + fun addKaptConfig(project: Project, kapt: KaptConfig) { project.projectProperties.put(KAPT_CONFIG, kapt) kaptConfigs.put(project.name, kapt) @@ -138,7 +154,7 @@ class AptConfig(var outputDir: String = "generated/source/apt") fun Project.apt(init: AptConfig.() -> Unit) { AptConfig().let { it.init() - (Kobalt.findPlugin(AptPlugin.PLUGIN_NAME) as AptPlugin).addConfiguration(this, it) + (Kobalt.findPlugin(AptPlugin.PLUGIN_NAME) as AptPlugin).addAptConfig(this, it) } } From 048769f1ad55be00277db2ec06ee04c91ffc6563 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Fri, 3 Jun 2016 02:39:53 -0800 Subject: [PATCH 050/106] 0.806. --- kobalt/wrapper/kobalt-wrapper.properties | 2 +- src/main/resources/kobalt.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties index d53826ad..2ea7d725 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=0.805 \ No newline at end of file +kobalt.version=0.806 \ No newline at end of file diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index d072c7d9..7701b72c 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=0.805 +kobalt.version=0.806 From 9e563e3d8f8d0d994735a33dbbfbb57d97f748c1 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Mon, 6 Jun 2016 07:16:07 -0700 Subject: [PATCH 051/106] 0.807. --- kobalt/wrapper/kobalt-wrapper.properties | 2 +- src/main/resources/kobalt.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties index 2ea7d725..9b3419ae 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=0.806 \ No newline at end of file +kobalt.version=0.807 \ No newline at end of file diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index 7701b72c..0d60e190 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=0.806 +kobalt.version=0.807 From ec933143adb26c2a3d12c845bdadc61c71c6c27d Mon Sep 17 00:00:00 2001 From: DevCharly Date: Mon, 6 Jun 2016 16:43:18 +0200 Subject: [PATCH 052/106] exit Kobal process on exceptions (fixes #229) --- src/main/kotlin/com/beust/kobalt/Main.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/com/beust/kobalt/Main.kt b/src/main/kotlin/com/beust/kobalt/Main.kt index 576ec211..6222b686 100644 --- a/src/main/kotlin/com/beust/kobalt/Main.kt +++ b/src/main/kotlin/com/beust/kobalt/Main.kt @@ -115,7 +115,7 @@ private class Main @Inject constructor( val seconds = benchmarkSeconds { try { result = runWithArgs(jc, args, argv, pluginClassLoader) - } catch(ex: KobaltException) { + } catch(ex: Throwable) { error("", ex.cause ?: ex) result = 1 } From ca122ee55afe4ae38f0f4843a5f435b8194113be Mon Sep 17 00:00:00 2001 From: DevCharly Date: Tue, 7 Jun 2016 10:26:48 +0200 Subject: [PATCH 053/106] fixed creation of classes directory at wrong parent (project.buildDirectory is relative to project.directory!) --- .../src/main/kotlin/com/beust/kobalt/internal/CompilerUtils.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/CompilerUtils.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/CompilerUtils.kt index 9e0747b0..e1f9b3a9 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/CompilerUtils.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/CompilerUtils.kt @@ -76,7 +76,7 @@ class CompilerUtils @Inject constructor(val files: KFiles, val buildDirectory = if (isTest) File(project.buildDirectory, KFiles.TEST_CLASSES_DIR) else File(project.classesDir(context)) - buildDirectory.mkdirs() + File(project.directory, buildDirectory.path).mkdirs() val initialSourceDirectories = ArrayList(sourceDirectories) // Source directories from the contributors From 0f6820c30fc59c6d60e538f3c0852a63701eb78c Mon Sep 17 00:00:00 2001 From: DevCharly Date: Tue, 7 Jun 2016 10:29:02 +0200 Subject: [PATCH 054/106] fixed typo in log of Io.mkdir() --- .../src/main/kotlin/com/beust/kobalt/misc/Io.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/Io.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/Io.kt index 6f8694a9..a354043e 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/Io.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/Io.kt @@ -73,7 +73,7 @@ class Io(val dryRun: Boolean = false) { } fun mkdir(dir: File) { - log("rm -rf $dir") + log("mkdir $dir") if (! dryRun) { dir.mkdirs() } From a005a14db55263c0f8019f51a6e29be9e572ebc0 Mon Sep 17 00:00:00 2001 From: DevCharly Date: Tue, 7 Jun 2016 14:05:30 +0200 Subject: [PATCH 055/106] avoid adding empty "classes" directory entry to Jar file (this did add the empty "classes" directory to kobalt-0.xxx.jar) --- .../main/kotlin/com/beust/kobalt/misc/JarUtils.kt | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/JarUtils.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/JarUtils.kt index 70a8bbb4..dfd8cc70 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/JarUtils.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/JarUtils.kt @@ -51,19 +51,6 @@ public class JarUtils { log(2, "Writing contents of directory $foundFile") // Directory - var name = foundFile.name - if (!name.isEmpty()) { - if (!name.endsWith("/")) name += "/" - val entry = JarEntry(name) - entry.time = localFile.lastModified() - try { - outputStream.putNextEntry(entry) - } catch(ex: ZipException) { - log(2, "Can't add $name: ${ex.message}") - } finally { - outputStream.closeEntry() - } - } val includedFile = IncludedFile(From(foundFile.path), To(""), listOf(IFileSpec.GlobSpec("**"))) addSingleFile(".", includedFile, outputStream, expandJarFiles) } else { From cbbe9cbeb72f3e129b21209bdef9288a8b423b21 Mon Sep 17 00:00:00 2001 From: DevCharly Date: Tue, 7 Jun 2016 16:58:18 +0200 Subject: [PATCH 056/106] fixed fatJar for projects in subdirectories that depend on other projects E.g. building p2 (see below) failed with `java.lang.AssertionError: File should exist: p2\p1\kobaltBuild\classes` because `p2.directory is != "."` ``` val p1 = project { name = "p1" directory = name } val p2 = project(p1) { name = "p2" directory = name assemble { jar { fatJar = true } } } ``` --- .../src/main/kotlin/com/beust/kobalt/JarGenerator.kt | 2 +- .../src/main/kotlin/com/beust/kobalt/misc/JarUtils.kt | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/JarGenerator.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/JarGenerator.kt index 39c4c2e1..59f51deb 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/JarGenerator.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/JarGenerator.kt @@ -107,7 +107,7 @@ class JarGenerator @Inject constructor(val dependencyManager: DependencyManager) if (! seen.contains(file.path)) { seen.add(file.path) if (! KFiles.Companion.isExcluded(file, jar.excludes)) { - result.add(IncludedFile(specs = arrayListOf(IFileSpec.FileSpec(file.path)), + result.add(IncludedFile(specs = arrayListOf(IFileSpec.FileSpec(file.absolutePath)), expandJarFiles = true)) } } diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/JarUtils.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/JarUtils.kt index dfd8cc70..fedac00f 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/JarUtils.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/JarUtils.kt @@ -47,12 +47,12 @@ public class JarUtils { throw AssertionError("File should exist: $localFile") } - if (foundFile.isDirectory) { + if (localFile.isDirectory) { log(2, "Writing contents of directory $foundFile") // Directory - val includedFile = IncludedFile(From(foundFile.path), To(""), listOf(IFileSpec.GlobSpec("**"))) - addSingleFile(".", includedFile, outputStream, expandJarFiles) + 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") From d3a70a25a82e0f5dae19cf22865afc6430d76a04 Mon Sep 17 00:00:00 2001 From: DevCharly Date: Tue, 7 Jun 2016 17:28:20 +0200 Subject: [PATCH 057/106] delete jar if exception occurs while creating it (otherwise incremental build does not work on next run) --- .../com/beust/kobalt/archive/Archives.kt | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/archive/Archives.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/archive/Archives.kt index ca808318..66fe50e1 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/archive/Archives.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/archive/Archives.kt @@ -33,12 +33,19 @@ class Archives { val result = File(archiveDir.path, fullArchiveName) log(3, "Creating $result") if (! Features.USE_TIMESTAMPS || isOutdated(project.directory, includedFiles, result)) { - val outStream = outputStreamFactory(FileOutputStream(result)) - JarUtils.addFiles(project.directory, includedFiles, outStream, expandJarFiles) - log(2, text = "Added ${includedFiles.size} files to $result") - outStream.flush() - outStream.close() - log(1, " Created $result") + try { + outputStreamFactory(FileOutputStream(result)).use { + JarUtils.addFiles(project.directory, includedFiles, it, expandJarFiles) + log(2, text = "Added ${includedFiles.size} files to $result") + log(1, " Created $result") + } + } catch (e: Throwable) { + // make sure that incomplete archive is deleted + // otherwise incremental build does not work on next run + result.delete() + throw e + } + } else { log(3, " $result is up to date") } From f695fdf38cef2ed2b1ee92376760e0020cbdbe85 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Mon, 6 Jun 2016 01:47:40 -0800 Subject: [PATCH 058/106] Logs. --- .../src/main/kotlin/com/beust/kobalt/misc/JarUtils.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/JarUtils.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/JarUtils.kt index fedac00f..e0816e40 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/JarUtils.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/JarUtils.kt @@ -47,15 +47,15 @@ public class JarUtils { throw AssertionError("File should exist: $localFile") } - if (localFile.isDirectory) { - log(2, "Writing contents of directory $foundFile") + if (foundFile.isDirectory) { + log(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") + log(2, " Writing contents of jar file $foundFile") val stream = JarInputStream(FileInputStream(localFile)) var entry = stream.nextEntry while (entry != null) { From 5b2ed94655bfafb7e8005ad2a1b7ec899b9198c8 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Mon, 6 Jun 2016 21:03:13 -0800 Subject: [PATCH 059/106] 0.808. --- kobalt/wrapper/kobalt-wrapper.properties | 2 +- src/main/resources/kobalt.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties index 9b3419ae..44f48ee3 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=0.807 \ No newline at end of file +kobalt.version=0.808 \ No newline at end of file diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index 0d60e190..3eca8021 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=0.807 +kobalt.version=0.808 From ff1e3c2d13a5f603fc171b9654231ca381ea37b0 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Mon, 6 Jun 2016 22:08:30 -0800 Subject: [PATCH 060/106] GITHUB-230: Fail build if invalid project requested. Fixes https://github.com/cbeust/kobalt/issues/230 --- .../kobalt/internal/IncrementalManager.kt | 8 +-- .../com/beust/kobalt/internal/TaskManager.kt | 69 ++++++++++++++----- .../beust/kobalt/internal/TaskManagerTest.kt | 2 +- 3 files changed, 58 insertions(+), 21 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/IncrementalManager.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/IncrementalManager.kt index 6b134f42..a0211b9c 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/IncrementalManager.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/IncrementalManager.kt @@ -19,16 +19,16 @@ import java.nio.file.Files import java.nio.file.Paths import java.util.* -data class TaskInfo(val taskName: String, var inputChecksum: String? = null, var outputChecksum: String? = null) - -class BuildInfo(var tasks: List) - /** * Manage the file .kobalt/buildInfo.json, which keeps track of input and output checksums to manage * incremental builds. */ class IncrementalManager @Inject constructor(val args: Args, @Assisted val fileName : String) { + private data class TaskInfo(val taskName: String, var inputChecksum: String? = null, var outputChecksum: String? = null) + + private class BuildInfo(var tasks: List) + interface IFactory { fun create(@Assisted fileName: String = IncrementalManager.BUILD_INFO_FILE) : IncrementalManager } diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt index 432e1471..c590197d 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt @@ -81,11 +81,44 @@ class TaskManager @Inject constructor(val args: Args, } } - fun runTargets(passedTaskNames: List, projects: List): RunTargetResult { + fun runTargets(passedTaskNames: List, allProjects: List): RunTargetResult { + val taskInfos = calculateDependentTaskNames(passedTaskNames, allProjects) + val projectsToRun = findProjectsToRun(passedTaskNames, allProjects) + return runProjects(taskInfos, projectsToRun) + } + + /** + * Determine which projects to run based on the request tasks. Also make sure that all the requested projects + * exist. + */ + private fun findProjectsToRun(passedTaskNames: List, projects: List) : List { + + // Validate projects + val result = arrayListOf() + val projectMap = HashMap().apply { + projects.forEach { put(it.name, it)} + } + + // Extract all the projects we need to run from the tasks + val taskInfos = calculateDependentTaskNames(passedTaskNames, projects) + taskInfos.forEach { + val p = it.project + if (p != null) { + if (! projectMap.containsKey(p)) { + throw KobaltException("Unknown project: ${it.project}") + } + result.add(projectMap[it.project]!!) + } + } + + // If at least one task didn't specify a project, run them all + return if (result.any()) result else projects + } + + private fun runProjects(taskInfos: List, projects: List) : RunTargetResult { var result = 0 val failedProjects = hashSetOf() val messages = Collections.synchronizedList(arrayListOf()) - val taskNames = calculateDependentTaskNames(passedTaskNames, projects) projects.forEach { project -> AsciiArt.logBox("Building ${project.name}") @@ -112,7 +145,7 @@ class TaskManager @Inject constructor(val args: Args, log(3, " $it: " + tasksByNames.get(it)) } - val graph = createGraph2(project.name, taskNames, tasksByNames, + val graph = createGraph2(project.name, taskInfos, tasksByNames, dependsOn, reverseDependsOn, runBefore, runAfter, alwaysRunAfter, { task: ITask -> task.name }, { task: ITask -> task.plugin.accept(project) }) @@ -138,6 +171,7 @@ class TaskManager @Inject constructor(val args: Args, } } } + return RunTargetResult(result, messages) } @@ -146,11 +180,11 @@ class TaskManager @Inject constructor(val args: Args, * see if that project depends on others and if it does, invoke these tasks on all of them. This * function returns all these task names (including dependent). */ - private fun calculateDependentTaskNames(taskNames: List, projects: List): List { + private fun calculateDependentTaskNames(taskNames: List, projects: List): List { val projectMap = hashMapOf().apply { projects.forEach { put(it.name, it)} } - val result = ArrayList(taskNames) + val result = ArrayList(taskNames.map { TaskInfo(it) }) val toProcess = ArrayList(taskNames) val newToProcess = arrayListOf() val seen = hashSetOf() @@ -161,7 +195,7 @@ class TaskManager @Inject constructor(val args: Args, projectMap[ti.project]?.let { project -> project.projectExtra.dependsOn.forEach { dp -> val newTask = TaskInfo(dp.projectName, ti.taskName).id - result.add(newTask) + result.add(TaskInfo(newTask)) if (! seen.contains(newTask)) { newToProcess.add(newTask) seen.add(newTask) @@ -188,7 +222,8 @@ class TaskManager @Inject constructor(val args: Args, * we'll be adding to the graph while @toName extracts the name of a node. */ @VisibleForTesting - fun createGraph2(projectName: String, taskNames: List, nodeMap: Multimap, + fun createGraph2(projectName: String, passedTasks: List, + nodeMap: Multimap, dependsOn: Multimap, reverseDependsOn: Multimap, runBefore: Multimap, @@ -214,9 +249,9 @@ class TaskManager @Inject constructor(val args: Args, } // - // Turn the task names into the more useful TaskInfo and do some sanity checking on the way + // Keep only the tasks we need to run. // - val taskInfos = taskNames.map { TaskInfo(it) }.filter { + val taskInfos = passedTasks.filter { if (!nodeMap.keys().contains(it.taskName)) { throw KobaltException("Unknown task: $it") } @@ -300,14 +335,16 @@ class TaskManager @Inject constructor(val args: Args, // runBefore and runAfter (task ordering) are only considered for explicit tasks (tasks that were // explicitly requested by the user) // - runBefore[taskName].forEach { from -> - if (taskNames.contains(from)) { - addEdge(result, from, taskName, newToProcess, "runBefore") + passedTasks.map { it.id }.let { taskNames -> + runBefore[taskName].forEach { from -> + if (taskNames.contains(from)) { + addEdge(result, from, taskName, newToProcess, "runBefore") + } } - } - runAfter[taskName].forEach { to -> - if (taskNames.contains(to)) { - addEdge(result, taskName, to, newToProcess, "runAfter") + runAfter[taskName].forEach { to -> + if (taskNames.contains(to)) { + addEdge(result, taskName, to, newToProcess, "runAfter") + } } } seen.add(taskName) diff --git a/src/test/kotlin/com/beust/kobalt/internal/TaskManagerTest.kt b/src/test/kotlin/com/beust/kobalt/internal/TaskManagerTest.kt index ee1caa50..252e1228 100644 --- a/src/test/kotlin/com/beust/kobalt/internal/TaskManagerTest.kt +++ b/src/test/kotlin/com/beust/kobalt/internal/TaskManagerTest.kt @@ -80,7 +80,7 @@ class TaskManagerTest @Inject constructor(val taskManager: TaskManager) { } } - val graph = taskManager.createGraph2("", tasks, dependencies, + val graph = taskManager.createGraph2("", tasks.map { TaskManager.TaskInfo(it) }, dependencies, dependsOn, reverseDependsOn, runBefore, runAfter, alwaysRunAfter, { it }, { t -> true }) val result = DryRunGraphExecutor(graph).run() From 5a963252f8163748646383094c408ec137b5c359 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Mon, 6 Jun 2016 22:08:44 -0800 Subject: [PATCH 061/106] 0.809. --- kobalt/wrapper/kobalt-wrapper.properties | 2 +- src/main/resources/kobalt.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties index 44f48ee3..9c2b19c7 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=0.808 \ No newline at end of file +kobalt.version=0.809 \ No newline at end of file diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index 3eca8021..d81cd3a1 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=0.808 +kobalt.version=0.809 From 095a2310f041f94e51d5e0c7f4250d73754a18ac Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Mon, 6 Jun 2016 22:27:00 -0800 Subject: [PATCH 062/106] Remove travis caches. --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 43e61725..a28d171c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ -cache: - directories: - - $HOME/.m2 - - $HOME/.kobalt +#cache: +# directories: +# - $HOME/.m2 +# - $HOME/.kobalt language: java From 80a31bbb9b00d2dfc2e4cb0414f2e98014062f81 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 7 Jun 2016 00:43:41 -0800 Subject: [PATCH 063/106] Fix the build order. --- .../com/beust/kobalt/internal/TaskManager.kt | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt index c590197d..182eb26d 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt @@ -83,7 +83,7 @@ class TaskManager @Inject constructor(val args: Args, fun runTargets(passedTaskNames: List, allProjects: List): RunTargetResult { val taskInfos = calculateDependentTaskNames(passedTaskNames, allProjects) - val projectsToRun = findProjectsToRun(passedTaskNames, allProjects) + val projectsToRun = findProjectsToRun(taskInfos, allProjects) return runProjects(taskInfos, projectsToRun) } @@ -91,7 +91,7 @@ class TaskManager @Inject constructor(val args: Args, * Determine which projects to run based on the request tasks. Also make sure that all the requested projects * exist. */ - private fun findProjectsToRun(passedTaskNames: List, projects: List) : List { + private fun findProjectsToRun(taskInfos: List, projects: List) : List { // Validate projects val result = arrayListOf() @@ -100,7 +100,7 @@ class TaskManager @Inject constructor(val args: Args, } // Extract all the projects we need to run from the tasks - val taskInfos = calculateDependentTaskNames(passedTaskNames, projects) +// val orderedTaskInfos = calculateDependentTaskNames(taskInfos.map { it.id }, projects) taskInfos.forEach { val p = it.project if (p != null) { @@ -185,17 +185,17 @@ class TaskManager @Inject constructor(val args: Args, projects.forEach { put(it.name, it)} } val result = ArrayList(taskNames.map { TaskInfo(it) }) - val toProcess = ArrayList(taskNames) - val newToProcess = arrayListOf() - val seen = hashSetOf() + val toProcess = ArrayList(result) + val newToProcess = arrayListOf() + val seen = hashSetOf() var stop = false while (! stop) { - toProcess.forEach { taskName -> - val ti = TaskInfo(taskName) + toProcess.forEach { ti -> projectMap[ti.project]?.let { project -> project.projectExtra.dependsOn.forEach { dp -> - val newTask = TaskInfo(dp.projectName, ti.taskName).id - result.add(TaskInfo(newTask)) + val newTask = TaskInfo(dp.projectName, ti.taskName) + // Insert the project at the top of the list since we haven't added its dependents yet + result.add(0, newTask) if (! seen.contains(newTask)) { newToProcess.add(newTask) seen.add(newTask) From b2fea9b7e069bc4d43df1644ed965532c24a7344 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 7 Jun 2016 00:43:46 -0800 Subject: [PATCH 064/106] Rename. --- .../kobalt/internal/{GenericRunnerTest.kt => DependencyTest.kt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/test/kotlin/com/beust/kobalt/internal/{GenericRunnerTest.kt => DependencyTest.kt} (100%) diff --git a/src/test/kotlin/com/beust/kobalt/internal/GenericRunnerTest.kt b/src/test/kotlin/com/beust/kobalt/internal/DependencyTest.kt similarity index 100% rename from src/test/kotlin/com/beust/kobalt/internal/GenericRunnerTest.kt rename to src/test/kotlin/com/beust/kobalt/internal/DependencyTest.kt From 1ca58b95f2adfb8150c96d0c836cb2c98ea7a9ff Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 7 Jun 2016 00:43:51 -0800 Subject: [PATCH 065/106] toString(). --- .../src/main/kotlin/com/beust/kobalt/api/Project.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/Project.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/Project.kt index a004071a..2e2b5146 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/Project.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/Project.kt @@ -123,6 +123,8 @@ open class Project( }) return result } + + override fun toString() = "[Project $name]" } class Sources(val project: Project, val sources: HashSet) { From ff7402b24fc599c02a78c17d91e8814dfb0a5167 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 7 Jun 2016 00:44:00 -0800 Subject: [PATCH 066/106] 0.810. --- kobalt/wrapper/kobalt-wrapper.properties | 2 +- src/main/resources/kobalt.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties index 9c2b19c7..7cc8a907 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=0.809 \ No newline at end of file +kobalt.version=0.810 \ No newline at end of file diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index d81cd3a1..7816bbb6 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=0.809 +kobalt.version=0.810 From 5fcffb02412eaf77d78bc0ac6aae47ff2867feb9 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 7 Jun 2016 01:16:59 -0800 Subject: [PATCH 067/106] Test for build order. --- .../com/beust/kobalt/internal/TaskManager.kt | 4 +- .../beust/kobalt/internal/BuildOrderTest.kt | 41 +++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 src/test/kotlin/com/beust/kobalt/internal/BuildOrderTest.kt diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt index 182eb26d..668b3494 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt @@ -91,7 +91,7 @@ class TaskManager @Inject constructor(val args: Args, * Determine which projects to run based on the request tasks. Also make sure that all the requested projects * exist. */ - private fun findProjectsToRun(taskInfos: List, projects: List) : List { + fun findProjectsToRun(taskInfos: List, projects: List) : List { // Validate projects val result = arrayListOf() @@ -180,7 +180,7 @@ class TaskManager @Inject constructor(val args: Args, * see if that project depends on others and if it does, invoke these tasks on all of them. This * function returns all these task names (including dependent). */ - private fun calculateDependentTaskNames(taskNames: List, projects: List): List { + fun calculateDependentTaskNames(taskNames: List, projects: List): List { val projectMap = hashMapOf().apply { projects.forEach { put(it.name, it)} } diff --git a/src/test/kotlin/com/beust/kobalt/internal/BuildOrderTest.kt b/src/test/kotlin/com/beust/kobalt/internal/BuildOrderTest.kt new file mode 100644 index 00000000..dabdb163 --- /dev/null +++ b/src/test/kotlin/com/beust/kobalt/internal/BuildOrderTest.kt @@ -0,0 +1,41 @@ +package com.beust.kobalt.internal + +import com.beust.kobalt.TestModule +import com.beust.kobalt.api.Kobalt +import com.beust.kobalt.project +import org.testng.Assert +import org.testng.annotations.BeforeClass +import org.testng.annotations.DataProvider +import org.testng.annotations.Guice +import org.testng.annotations.Test +import javax.inject.Inject + +@Guice(modules = arrayOf(TestModule::class)) +class BuildOrderTest @Inject constructor(val taskManager: TaskManager) { + @BeforeClass + fun beforeClass() { + Kobalt.init(TestModule()) + } + + @DataProvider + fun tasks(): Array> { + return arrayOf( + arrayOf(listOf("p1:assemble"), listOf("p1:assemble")), + arrayOf(listOf("p2:assemble"), listOf("p1:assemble", "p2:assemble")), + arrayOf(listOf("p3:assemble"), listOf("p1:assemble", "p2:assemble", "p3:assemble")) + ) + } + + @Test(dataProvider = "tasks") + fun shouldBuildInRightOrder(tasks: List, expectedTasks: List) { + val p1 = project { name = "p1" } + val p2 = project(p1) { name = "p2" } + val p3 = project(p2) { name = "p3" } + + val allProjects = listOf(p1, p2, p3) + with(taskManager) { + val taskInfos = calculateDependentTaskNames(tasks, allProjects) + Assert.assertEquals(taskInfos.map { it.id }, expectedTasks) + } + } +} From 99ec5868775cc0c7a539f28ce6947074aa0b9ef2 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 7 Jun 2016 23:40:00 -0700 Subject: [PATCH 068/106] Fix test for Windows. --- src/test/kotlin/com/beust/kobalt/internal/DependencyTest.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/test/kotlin/com/beust/kobalt/internal/DependencyTest.kt b/src/test/kotlin/com/beust/kobalt/internal/DependencyTest.kt index fcf04494..a510cd66 100644 --- a/src/test/kotlin/com/beust/kobalt/internal/DependencyTest.kt +++ b/src/test/kotlin/com/beust/kobalt/internal/DependencyTest.kt @@ -16,8 +16,9 @@ import javax.inject.Inject * Test ITestJvmFlagContributor and ITestJvmFlagInterceptor. */ class DependencyTest @Inject constructor() { - private val A_JAR = "/tmp/a.jar" - private val B_JAR = "/tmp/b.jar" + private fun isWindows() = System.getProperty("os.name").toLowerCase().contains("ndows") + private val A_JAR = if (isWindows()) "c:\\tmp\\a.jar" else "/tmp/a.jar" + private val B_JAR = if (isWindows()) "c:\\tmp\\b.jar" else "/tmp/b.jar" private val project : Project get() = project { name = "dummy" } private val classpath = listOf(FileDependency(A_JAR)) From e5ff564345b7185a299dcf02e1de831df701411d Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Wed, 8 Jun 2016 05:33:56 -0700 Subject: [PATCH 069/106] Travis builds --- .travis.yml | 2 +- build-travis.sh | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 build-travis.sh diff --git a/.travis.yml b/.travis.yml index a28d171c..1190ebf4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,4 +10,4 @@ jdk: install: true -script: ./kobaltw assemble test --log 2 +script: ./build-travis.sh assemble test --log 2 diff --git a/build-travis.sh b/build-travis.sh new file mode 100644 index 00000000..9de48702 --- /dev/null +++ b/build-travis.sh @@ -0,0 +1 @@ +java -Xmx512m -jar $(dirname $0)/kobalt/wrapper/kobalt-wrapper.jar $* From cd51c85a40b70efb375a4af3a8ba1d96ad0eb309 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Wed, 8 Jun 2016 05:36:31 -0700 Subject: [PATCH 070/106] +x flag --- build-travis.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 build-travis.sh diff --git a/build-travis.sh b/build-travis.sh old mode 100644 new mode 100755 From 24f67b2866d06b791ef7c63df1deefa298aa4b30 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Wed, 8 Jun 2016 05:44:24 -0700 Subject: [PATCH 071/106] Reduce log level for Travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1190ebf4..9436fbf3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,4 +10,4 @@ jdk: install: true -script: ./build-travis.sh assemble test --log 2 +script: ./build-travis.sh assemble test --log 1 From 81a534fb295892becb93f9a1803ec3d98f32cbaf Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Wed, 8 Jun 2016 05:53:19 -0700 Subject: [PATCH 072/106] More memory --- build-travis.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-travis.sh b/build-travis.sh index 9de48702..e17e1a26 100755 --- a/build-travis.sh +++ b/build-travis.sh @@ -1 +1 @@ -java -Xmx512m -jar $(dirname $0)/kobalt/wrapper/kobalt-wrapper.jar $* +java -Xmx1024m -jar $(dirname $0)/kobalt/wrapper/kobalt-wrapper.jar $* From 9204c22bbd906a46ddecd82dc796938a6cc2ccf5 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Wed, 8 Jun 2016 06:00:01 -0700 Subject: [PATCH 073/106] More memory --- build-travis.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-travis.sh b/build-travis.sh index e17e1a26..fa06f810 100755 --- a/build-travis.sh +++ b/build-travis.sh @@ -1 +1 @@ -java -Xmx1024m -jar $(dirname $0)/kobalt/wrapper/kobalt-wrapper.jar $* +java -Xmx2048m -jar $(dirname $0)/kobalt/wrapper/kobalt-wrapper.jar $* From 80c24076ac3faa18736f7b447b7451680f5a4e06 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Wed, 8 Jun 2016 06:07:25 -0700 Subject: [PATCH 074/106] Build travis in two phases --- .travis.yml | 2 +- build-travis.sh | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9436fbf3..74c0ce9f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,4 +10,4 @@ jdk: install: true -script: ./build-travis.sh assemble test --log 1 +script: ./build-travis.sh diff --git a/build-travis.sh b/build-travis.sh index fa06f810..467849b9 100755 --- a/build-travis.sh +++ b/build-travis.sh @@ -1 +1,4 @@ -java -Xmx2048m -jar $(dirname $0)/kobalt/wrapper/kobalt-wrapper.jar $* +java -Xmx2048m -jar $(dirname $0)/kobalt/wrapper/kobalt-wrapper.jar $* assemble + +java -Xmx2048m -jar $(dirname $0)/kobalt/wrapper/kobalt-wrapper.jar $* test + From 00612cebf5f758c09bf9ceef3ed6973fe59d1e8e Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Wed, 8 Jun 2016 06:08:53 -0700 Subject: [PATCH 075/106] Restore caches --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 74c0ce9f..0c1d3b1d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ -#cache: -# directories: -# - $HOME/.m2 -# - $HOME/.kobalt +cache: + directories: + - $HOME/.m2 + - $HOME/.kobalt language: java From 5587eb33bcc7ad123139a6720317e28deefaa7db Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 7 Jun 2016 21:08:53 -0800 Subject: [PATCH 076/106] Formatting. --- .../kotlin/com/beust/kobalt/internal/IncrementalManager.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/IncrementalManager.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/IncrementalManager.kt index a0211b9c..fe3b6dbd 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/IncrementalManager.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/IncrementalManager.kt @@ -25,7 +25,8 @@ import java.util.* */ class IncrementalManager @Inject constructor(val args: Args, @Assisted val fileName : String) { - private data class TaskInfo(val taskName: String, var inputChecksum: String? = null, var outputChecksum: String? = null) + private data class TaskInfo(val taskName: String, var inputChecksum: String? = null, + var outputChecksum: String? = null) private class BuildInfo(var tasks: List) From a9b8594a8395e56fb07cce58ac7d4794fa64fb1d Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 7 Jun 2016 21:09:11 -0800 Subject: [PATCH 077/106] Change md5 implementation to checksum timestamps instead of files. --- .../src/main/kotlin/com/beust/kobalt/maven/Md5.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/Md5.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/Md5.kt index 339efaa1..6cfb4832 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/Md5.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/Md5.kt @@ -18,7 +18,13 @@ public class Md5 { // return DatatypeConverter.printHexBinary(md5.digest()).toLowerCase() // } - fun toMd5Directories(directories: List) : String? { + /** + * Calculate a checksum for all the files under the passed directories. The conversion from File to + * bytes can be customized by the @param{toBytes} parameter. The default implementation calculates + * a checksum of the last modified timestamp. + */ + fun toMd5Directories(directories: List, + toBytes: (File) -> ByteArray = { it.lastModified().toString().toByteArray() } ): String? { val ds = directories.filter { it.exists() } if (ds.size > 0) { MessageDigest.getInstance("MD5").let { md5 -> @@ -37,7 +43,7 @@ public class Md5 { it.isFile }.forEach { fileCount++ - val bytes = it.readBytes() + val bytes = toBytes(it) md5.update(bytes, 0, bytes.size) } } From 7ae8f190b17c9bb7d10768b097b9c0ef65cbbd15 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 7 Jun 2016 21:15:18 -0800 Subject: [PATCH 078/106] Reformat. --- .../plugin/packaging/PackagingPlugin.kt | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/main/kotlin/com/beust/kobalt/plugin/packaging/PackagingPlugin.kt b/src/main/kotlin/com/beust/kobalt/plugin/packaging/PackagingPlugin.kt index aba925bc..3b1dd5b9 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/packaging/PackagingPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/packaging/PackagingPlugin.kt @@ -67,17 +67,20 @@ class PackagingPlugin @Inject constructor(val dependencyManager : DependencyMana * skipped. */ override fun assemble(project: Project, context: KobaltContext) : IncrementalTaskInfo { - return IncrementalTaskInfo({ null }, { null }, { project -> - try { - packages.filter { it.project.name == project.name }.forEach { pkg -> - pkg.jars.forEach { jarGenerator.generateJar(pkg.project, context, it) } - pkg.wars.forEach { warGenerator.generateWar(pkg.project, context, it) } - pkg.zips.forEach { zipGenerator.generateZip(pkg.project, context, it) } - if (pkg.generatePom) { - pomFactory.create(project).generate() - } - } - TaskResult() + return IncrementalTaskInfo( + { null }, + { null }, + { project -> + try { + packages.filter { it.project.name == project.name }.forEach { packageConfig -> + packageConfig.jars.forEach { jarGenerator.generateJar(packageConfig.project, context, it) } + packageConfig.wars.forEach { warGenerator.generateWar(packageConfig.project, context, it) } + packageConfig.zips.forEach { zipGenerator.generateZip(packageConfig.project, context, it) } + if (packageConfig.generatePom) { + pomFactory.create(project).generate() + } + } + TaskResult() } catch(ex: Exception) { throw KobaltException(ex) }}, context) From a83e1f4a7d709b015adfc14199643f1384389c08 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 7 Jun 2016 21:48:47 -0800 Subject: [PATCH 079/106] Remove dependency on kotlinx.dom. --- kobalt/src/Build.kt | 3 +-- .../main/kotlin/com/beust/kobalt/maven/Pom.kt | 24 ++++++++++++++----- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/kobalt/src/Build.kt b/kobalt/src/Build.kt index adef42a6..8c2574f8 100644 --- a/kobalt/src/Build.kt +++ b/kobalt/src/Build.kt @@ -67,8 +67,7 @@ val kobaltPluginApi = project { developerConnection = "git@github.com:cbeust/kobalt.git") dependencies { - compile("org.jetbrains.kotlinx:kotlinx.dom:0.0.10", - + compile( "com.google.inject:guice:4.0", "com.google.inject.extensions:guice-assistedinject:4.0", "javax.inject:javax.inject:1", diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/Pom.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/Pom.kt index 48f6965e..a6263e22 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/Pom.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/Pom.kt @@ -3,11 +3,9 @@ package com.beust.kobalt.maven import com.beust.kobalt.misc.toString import com.beust.kobalt.misc.warn import com.google.inject.assistedinject.Assisted -import kotlinx.dom.childElements import org.w3c.dom.Element import org.w3c.dom.NodeList -import org.xml.sax.InputSource -import java.io.FileReader +import javax.xml.parsers.DocumentBuilderFactory import javax.xml.xpath.XPathConstants class Pom @javax.inject.Inject constructor(@Assisted val id: String, @@ -66,8 +64,8 @@ class Pom @javax.inject.Inject constructor(@Assisted val id: String, init { val DEPENDENCIES = XPATH.compile("/project/dependencies/dependency") + val document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(documentFile) - val document = kotlinx.dom.parseXml(InputSource(FileReader(documentFile))) groupId = XPATH.compile("/project/groupId").evaluate(document) artifactId = XPATH.compile("/project/artifactId").evaluate(document) version = XPATH.compile("/project/version").evaluate(document) @@ -75,11 +73,12 @@ class Pom @javax.inject.Inject constructor(@Assisted val id: String, var repositoriesList = XPATH.compile("/project/repositories").evaluate(document, XPathConstants.NODESET) as NodeList var repoElem = repositoriesList.item(0) as Element? - repositories = repoElem.childElements().map({ it.getElementsByTagName("url").item(0).textContent }) + repositories = childElements(repoElem).map({ it.getElementsByTagName("url").item(0) + .textContent }) val propertiesList = XPATH.compile("/project/properties").evaluate(document, XPathConstants.NODESET) as NodeList var propsElem = propertiesList.item(0) as Element? - propsElem.childElements().forEach { + childElements(propsElem).forEach { properties.put(it.nodeName, it.textContent) } @@ -111,5 +110,18 @@ class Pom @javax.inject.Inject constructor(@Assisted val id: String, } } + private fun childElements(repoElem: Element?): List { + val result = arrayListOf() + if (repoElem != null) { + for (i in 0..repoElem.childNodes.length - 1) { + val elem = repoElem.childNodes.item(i) + if (elem is Element) { + result.add(elem) + } + } + } + return result + } + override fun toString() = toString("Pom", "id", id) } From 82b5c636d0a7c776b3215e4ea49f8b62ea804b60 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 7 Jun 2016 22:32:12 -0800 Subject: [PATCH 080/106] Better look up of the compiler jar file. --- .../beust/kobalt/internal/KotlinJarFiles.kt | 21 +++++++++++++++++++ .../kobalt/plugin/kotlin/KotlinCompiler.kt | 8 +++++-- .../kobalt/plugin/kotlin/KotlinPlugin.kt | 8 ++++--- 3 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/KotlinJarFiles.kt diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/KotlinJarFiles.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/KotlinJarFiles.kt new file mode 100644 index 00000000..3f29427a --- /dev/null +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/KotlinJarFiles.kt @@ -0,0 +1,21 @@ +package com.beust.kobalt.internal + +import com.beust.kobalt.maven.DependencyManager +import com.google.inject.Inject +import java.io.File + +/** + * The jar files that Kotlin needs to run. + */ +class KotlinJarFiles @Inject constructor(val dependencyManager: DependencyManager, + val settings: KobaltSettings){ + private fun getKotlinCompilerJar(name: String): File { + val id = "org.jetbrains.kotlin:kotlin-$name:${settings.kobaltCompilerVersion}" + val dep = dependencyManager.create(id) + return dep.jarFile.get().absoluteFile + } + + val stdlib: File get() = getKotlinCompilerJar("stdlib") + val runtime: File get() = getKotlinCompilerJar("runtime") + val compiler: File get() = getKotlinCompilerJar("compiler-embeddable") +} diff --git a/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt b/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt index 165c92c9..212176b0 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt @@ -5,6 +5,7 @@ import com.beust.kobalt.api.* import com.beust.kobalt.internal.ICompilerAction import com.beust.kobalt.internal.JvmCompiler import com.beust.kobalt.internal.KobaltSettings +import com.beust.kobalt.internal.KotlinJarFiles import com.beust.kobalt.kotlin.ParentLastClassLoader import com.beust.kobalt.maven.DependencyManager import com.beust.kobalt.maven.dependency.FileDependency @@ -34,7 +35,8 @@ class KotlinCompiler @Inject constructor( val dependencyManager: DependencyManager, val executors: KobaltExecutors, val settings: KobaltSettings, - val jvmCompiler: JvmCompiler) { + val jvmCompiler: JvmCompiler, + val kotlinJarFiles: KotlinJarFiles) { val compilerAction = object: ICompilerAction { override fun compile(projectName: String?, info: CompilerActionInfo): TaskResult { @@ -88,7 +90,9 @@ class KotlinCompiler @Inject constructor( log(2, "Calling kotlinc " + allArgs.joinToString(" ")) val result : TaskResult = if (true) { - val classLoader = ParentLastClassLoader(cp.map { it.toURI().toURL() }) + val compilerJar = listOf(kotlinJarFiles.compiler.toURI().toURL()) + + val classLoader = ParentLastClassLoader(compilerJar) val compiler = classLoader.loadClass("org.jetbrains.kotlin.cli.common.CLICompiler") val compilerMain = compiler.declaredMethods.filter { it.name == "doMainNoExit" && it.parameterTypes.size == 2 diff --git a/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinPlugin.kt b/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinPlugin.kt index 4d210fa4..c0d975f3 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinPlugin.kt @@ -7,6 +7,7 @@ import com.beust.kobalt.api.annotation.Directive import com.beust.kobalt.internal.BaseJvmPlugin import com.beust.kobalt.internal.JvmCompilerPlugin import com.beust.kobalt.internal.KobaltSettings +import com.beust.kobalt.internal.KotlinJarFiles import com.beust.kobalt.maven.DependencyManager import com.beust.kobalt.maven.dependency.FileDependency import com.beust.kobalt.misc.KFiles @@ -19,7 +20,8 @@ import javax.inject.Singleton @Singleton class KotlinPlugin @Inject constructor(val executors: KobaltExecutors, val dependencyManager: DependencyManager, - val settings: KobaltSettings, override val configActor: ConfigActor) + val settings: KobaltSettings, override val configActor: ConfigActor, + val kotlinJarFiles: KotlinJarFiles) : BaseJvmPlugin(configActor), IDocContributor, IClasspathContributor, ICompilerContributor, IBuildConfigContributor { companion object { @@ -105,8 +107,8 @@ class KotlinPlugin @Inject constructor(val executors: KobaltExecutors, val depen override fun classpathEntriesFor(project: Project?, context: KobaltContext): List = if (project == null || accept(project)) { // All Kotlin projects automatically get the Kotlin runtime added to their class path - listOf(getKotlinCompilerJar("kotlin-stdlib"), getKotlinCompilerJar("kotlin-runtime")) - .map { FileDependency(it) } + listOf(kotlinJarFiles.stdlib, kotlinJarFiles.runtime) + .map { FileDependency(it.absolutePath) } } else { emptyList() } From 1b065c8d50e1b5277bd99aa368706400e33bdbf5 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 7 Jun 2016 22:40:05 -0800 Subject: [PATCH 081/106] Clean up the streams. --- .../kobalt/plugin/kotlin/KotlinCompiler.kt | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt b/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt index 212176b0..7626cefc 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt @@ -94,27 +94,26 @@ class KotlinCompiler @Inject constructor( val classLoader = ParentLastClassLoader(compilerJar) val compiler = classLoader.loadClass("org.jetbrains.kotlin.cli.common.CLICompiler") - val compilerMain = compiler.declaredMethods.filter { - it.name == "doMainNoExit" && it.parameterTypes.size == 2 - }[0] val kCompiler = classLoader.loadClass("org.jetbrains.kotlin.cli.jvm.K2JVMCompiler") // // In order to capture the error stream, I need to invoke CLICompiler.exec(), which // is the first method that accepts a PrintStream for the errors in parameter // - val baos = ByteArrayOutputStream() - val ps = PrintStream(baos) - val execMethod = compiler.declaredMethods.filter { - it.name == "exec" && it.parameterTypes.size == 2 - }[0] - val exitCode = execMethod.invoke(kCompiler.newInstance(), ps, allArgs.toTypedArray()) - val errorString = baos.toString(Charset.defaultCharset().toString()) + ByteArrayOutputStream().use { baos -> + PrintStream(baos).use { ps -> + val execMethod = compiler.declaredMethods.filter { + it.name == "exec" && it.parameterTypes.size == 2 + }[0] + val exitCode = execMethod.invoke(kCompiler.newInstance(), ps, allArgs.toTypedArray()) + val errorString = baos.toString(Charset.defaultCharset().toString()) - // The return value is an enum - val nameMethod = exitCode.javaClass.getMethod("name") - val success = "OK" == nameMethod.invoke(exitCode).toString() - TaskResult(success, errorString) + // The return value is an enum + val nameMethod = exitCode.javaClass.getMethod("name") + val success = "OK" == nameMethod.invoke(exitCode).toString() + TaskResult(success, errorString) + } + } } else { val exitCode = CLICompiler.doMainNoExit(K2JVMCompiler(), allArgs.toTypedArray()) TaskResult(exitCode == ExitCode.OK) From aaf5e4826b9a18c111d3e5bdeb7abd705019d1d4 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 7 Jun 2016 22:41:01 -0800 Subject: [PATCH 082/106] Refactor. --- .../com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt b/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt index 7626cefc..cad94b0f 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt @@ -90,17 +90,17 @@ class KotlinCompiler @Inject constructor( log(2, "Calling kotlinc " + allArgs.joinToString(" ")) val result : TaskResult = if (true) { - val compilerJar = listOf(kotlinJarFiles.compiler.toURI().toURL()) - - val classLoader = ParentLastClassLoader(compilerJar) - val compiler = classLoader.loadClass("org.jetbrains.kotlin.cli.common.CLICompiler") - val kCompiler = classLoader.loadClass("org.jetbrains.kotlin.cli.jvm.K2JVMCompiler") - // // In order to capture the error stream, I need to invoke CLICompiler.exec(), which // is the first method that accepts a PrintStream for the errors in parameter // ByteArrayOutputStream().use { baos -> + val compilerJar = listOf(kotlinJarFiles.compiler.toURI().toURL()) + + val classLoader = ParentLastClassLoader(compilerJar) + val compiler = classLoader.loadClass("org.jetbrains.kotlin.cli.common.CLICompiler") + val kCompiler = classLoader.loadClass("org.jetbrains.kotlin.cli.jvm.K2JVMCompiler") + PrintStream(baos).use { ps -> val execMethod = compiler.declaredMethods.filter { it.name == "exec" && it.parameterTypes.size == 2 From a493cbc11e72452b2e9b0f8f83c1e0d00b0b0b6a Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Wed, 8 Jun 2016 02:07:16 -0800 Subject: [PATCH 083/106] vals. --- .../main/kotlin/com/beust/kobalt/maven/DependencyManager.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/DependencyManager.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/DependencyManager.kt index 1ea41147..93d4c705 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/DependencyManager.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/DependencyManager.kt @@ -111,9 +111,9 @@ class DependencyManager @Inject constructor(val executors: KobaltExecutors, val */ fun transitiveClosure(dependencies : List, indent : String = " "): List { - var executor = executors.newExecutor("JvmCompiler}", 10) + val executor = executors.newExecutor("JvmCompiler}", 10) - var result = hashSetOf() + val result = hashSetOf() dependencies.forEach { projectDependency -> log(ConsoleRepositoryListener.LOG_LEVEL, "$indent Resolving $projectDependency") From 3da2b70558c6d8d4f38808953f5ed262c9516105 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Wed, 8 Jun 2016 02:36:32 -0800 Subject: [PATCH 084/106] Log. --- .../src/main/kotlin/com/beust/kobalt/JarGenerator.kt | 2 +- .../kotlin/com/beust/kobalt/internal/IncrementalManager.kt | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/JarGenerator.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/JarGenerator.kt index 59f51deb..a8ac7c41 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/JarGenerator.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/JarGenerator.kt @@ -91,7 +91,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, "Creating fat jar") + log(2, "Finding included files for far jar") val seen = hashSetOf() @Suppress("UNCHECKED_CAST") diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/IncrementalManager.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/IncrementalManager.kt index fe3b6dbd..c1ea7dc0 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/IncrementalManager.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/IncrementalManager.kt @@ -126,7 +126,8 @@ class IncrementalManager @Inject constructor(val args: Args, @Assisted val fileN if (outputChecksum == taskOutputChecksum) { upToDate = true } else { - logIncremental(LEVEL, "Incremental task $taskName output is out of date, running it") + logIncremental(LEVEL, "Incremental task $taskName output is out of date" + + " (different output checksums), running it") } } } else { @@ -134,7 +135,7 @@ class IncrementalManager @Inject constructor(val args: Args, @Assisted val fileN logIncremental(LEVEL, "Project ${project.name} depends on dirty project, running $taskName") } else { logIncremental(LEVEL, "Incremental task $taskName input is out of date, running it" - + " old: $inputChecksum new: ${iti.inputChecksum()}") + + " (different input checksums old: $inputChecksum new: ${iti.inputChecksum()})") } project.projectExtra.isDirty = true } From a5fbae6c65e3dc52589c11eea53d49e927297737 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Wed, 8 Jun 2016 02:36:53 -0800 Subject: [PATCH 085/106] Rename. --- .../src/main/kotlin/com/beust/kobalt/maven/Md5.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/Md5.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/Md5.kt index 6cfb4832..6ed088a4 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/Md5.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/Md5.kt @@ -19,17 +19,17 @@ public class Md5 { // } /** - * Calculate a checksum for all the files under the passed directories. The conversion from File to + * Calculate a checksum for all the files/directories. The conversion from File to * bytes can be customized by the @param{toBytes} parameter. The default implementation calculates * a checksum of the last modified timestamp. */ - fun toMd5Directories(directories: List, + fun toMd5Directories(filesOrDirectories: List, toBytes: (File) -> ByteArray = { it.lastModified().toString().toByteArray() } ): String? { - val ds = directories.filter { it.exists() } + val ds = filesOrDirectories.filter { it.exists() } if (ds.size > 0) { MessageDigest.getInstance("MD5").let { md5 -> var fileCount = 0 - directories.filter { it.exists() }.forEach { file -> + filesOrDirectories.filter { it.exists() }.forEach { file -> if (file.isFile) { val bytes = file.readBytes() md5.update(bytes, 0, bytes.size) From 937e095eb77e22632e70185ab9f74b25d9b1ec2c Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Wed, 8 Jun 2016 02:37:05 -0800 Subject: [PATCH 086/106] Not needed. --- .../src/main/kotlin/com/beust/kobalt/misc/JarUtils.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/JarUtils.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/JarUtils.kt index e0816e40..a17c2196 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/JarUtils.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/JarUtils.kt @@ -9,7 +9,6 @@ import java.util.jar.JarEntry import java.util.jar.JarFile import java.util.jar.JarInputStream import java.util.zip.ZipEntry -import java.util.zip.ZipException import java.util.zip.ZipFile import java.util.zip.ZipOutputStream From 2b78c0765d4bfb31efd2c7e3dd0cc1ae3c4a7b29 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Wed, 8 Jun 2016 02:37:14 -0800 Subject: [PATCH 087/106] val. --- .../kotlin/com/beust/kobalt/app/LanguageTemplateGenerator.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/kotlin/com/beust/kobalt/app/LanguageTemplateGenerator.kt b/src/main/kotlin/com/beust/kobalt/app/LanguageTemplateGenerator.kt index a47a4d1a..403c8f5c 100644 --- a/src/main/kotlin/com/beust/kobalt/app/LanguageTemplateGenerator.kt +++ b/src/main/kotlin/com/beust/kobalt/app/LanguageTemplateGenerator.kt @@ -3,7 +3,6 @@ package com.beust.kobalt.app import com.beust.kobalt.Args import com.beust.kobalt.api.ITemplate import com.beust.kobalt.api.ITemplateContributor -import com.beust.kobalt.app.Mustache import com.beust.kobalt.maven.Pom import com.beust.kobalt.misc.KFiles import com.beust.kobalt.misc.log @@ -85,7 +84,7 @@ abstract class LanguageTemplateGenerator : ITemplate { private fun importPom(pomFile: File, mainDeps: ArrayList, testDeps: ArrayList, map: HashMap) { - var pom = Pom("imported", pomFile.absoluteFile) + val pom = Pom("imported", pomFile.absoluteFile) with(map) { put("group", pom.groupId ?: PACKAGE_NAME) put("artifactId", pom.artifactId ?: PACKAGE_NAME) From b4c2594f391cc9df4810af294ecce92b5e2edaa5 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Wed, 8 Jun 2016 02:37:34 -0800 Subject: [PATCH 088/106] Fix PomTest. --- .../kotlin/com/beust/kobalt/maven/PomTest.kt | 53 ++++++++++++------- .../pom-norepositories-properties.xml | 0 src/test/resources/{ => PomTest}/pom.xml | 0 3 files changed, 34 insertions(+), 19 deletions(-) rename src/test/resources/{ => PomTest}/pom-norepositories-properties.xml (100%) rename src/test/resources/{ => PomTest}/pom.xml (100%) diff --git a/src/test/kotlin/com/beust/kobalt/maven/PomTest.kt b/src/test/kotlin/com/beust/kobalt/maven/PomTest.kt index 27fa07c2..7cd3feeb 100644 --- a/src/test/kotlin/com/beust/kobalt/maven/PomTest.kt +++ b/src/test/kotlin/com/beust/kobalt/maven/PomTest.kt @@ -10,42 +10,57 @@ import com.google.inject.Inject import org.testng.Assert import org.testng.annotations.Test import java.io.File +import java.io.FileOutputStream +import java.nio.file.Files class PomTest @Inject constructor() : KobaltTest() { @Test fun importPom() { - val pomSrc = File("src/test/resources/pom.xml") - val pom = Pom("testing", pomSrc); + resourceToFile("PomTest/pom.xml").let { pomSrc -> + with(Pom("testing", pomSrc)) { + Assert.assertEquals(groupId, "com.foo.bob") + Assert.assertEquals(artifactId, "rawr") + Assert.assertEquals(name, "rawr") + Assert.assertEquals(version, "1.2.3") + Assert.assertEquals(properties["commons.version"], "2.1.1") + Assert.assertEquals(properties["guice.version"], "4.0") - Assert.assertEquals(pom.groupId, "com.foo.bob") - Assert.assertEquals(pom.artifactId, "rawr") - Assert.assertEquals(pom.name, "rawr") - Assert.assertEquals(pom.version, "1.2.3") - Assert.assertEquals(pom.properties.get("commons.version"), "2.1.1") - Assert.assertEquals(pom.properties.get("guice.version"), "4.0") + validateGeneratedFile(this, pomSrc) + } - validateGeneratedFile(pom, pomSrc) + } } @Test fun importBasicPom() { - val pomSrc = File("src/test/resources/pom-norepositories-properties.xml") - val pom = Pom("testing", pomSrc); + resourceToFile("PomTest/pom-norepositories-properties.xml").let { pomSrc -> + with(Pom("testing", pomSrc)) { + Assert.assertEquals(groupId, "com.foo.bob") + Assert.assertEquals(artifactId, "rawr") + Assert.assertEquals(name, "rawr") + Assert.assertEquals(version, "1.2.3") + Assert.assertTrue(properties.isEmpty()) + Assert.assertTrue(repositories.isEmpty()) - Assert.assertEquals(pom.groupId, "com.foo.bob") - Assert.assertEquals(pom.artifactId, "rawr") - Assert.assertEquals(pom.name, "rawr") - Assert.assertEquals(pom.version, "1.2.3") - Assert.assertTrue(pom.properties.isEmpty()) - Assert.assertTrue(pom.repositories.isEmpty()) + validateGeneratedFile(this, pomSrc) + } + } + } - validateGeneratedFile(pom, pomSrc) + private fun resourceToFile(fileName: String) : File { + val ins = javaClass.classLoader.getResourceAsStream(fileName) + val result = Files.createTempFile("kobaltTest", "").toFile() + FileOutputStream(result).use { + ins.copyTo(it) + } + return result } private fun validateGeneratedFile(pom: Pom, pomSrc: File) { val temp = File(System.getProperty("java.io.tmpdir")) val original = System.getProperty("user.dir") System.setProperty("user.dir", temp.absolutePath) + val pomFile = File(temp, "pom.xml") pomFile.deleteOnExit() pomSrc.copyTo(pomFile, true) @@ -60,7 +75,7 @@ class PomTest @Inject constructor() : KobaltTest() { ProjectGenerator(Kobalt.INJECTOR.getInstance(PluginInfo::class.java)).run(args, javaClass.classLoader) - var contents = file.readText() + val contents = file.readText() Assert.assertTrue(contents.contains("group = \"${pom.groupId}\""), "Should find the group defined") Assert.assertTrue(contents.contains("name = \"${pom.name}\""), "Should find the name defined") Assert.assertTrue(contents.contains("version = \"${pom.version}\""), "Should find the version defined") diff --git a/src/test/resources/pom-norepositories-properties.xml b/src/test/resources/PomTest/pom-norepositories-properties.xml similarity index 100% rename from src/test/resources/pom-norepositories-properties.xml rename to src/test/resources/PomTest/pom-norepositories-properties.xml diff --git a/src/test/resources/pom.xml b/src/test/resources/PomTest/pom.xml similarity index 100% rename from src/test/resources/pom.xml rename to src/test/resources/PomTest/pom.xml From 4010bd3ca1c4c875dc70cfc216740baa1fc6ff81 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Wed, 8 Jun 2016 02:44:17 -0800 Subject: [PATCH 089/106] Comments. --- src/test/kotlin/com/beust/kobalt/maven/PomTest.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/test/kotlin/com/beust/kobalt/maven/PomTest.kt b/src/test/kotlin/com/beust/kobalt/maven/PomTest.kt index 7cd3feeb..2d52413d 100644 --- a/src/test/kotlin/com/beust/kobalt/maven/PomTest.kt +++ b/src/test/kotlin/com/beust/kobalt/maven/PomTest.kt @@ -13,7 +13,11 @@ import java.io.File import java.io.FileOutputStream import java.nio.file.Files -class PomTest @Inject constructor() : KobaltTest() { +/** + * If a user calls --init on a project with a pom.xml in it, make sure that pom.xml is correctly reflected in the + * generated Build.kt. + */ +class PomImportTest @Inject constructor() : KobaltTest() { @Test fun importPom() { resourceToFile("PomTest/pom.xml").let { pomSrc -> @@ -27,7 +31,6 @@ class PomTest @Inject constructor() : KobaltTest() { validateGeneratedFile(this, pomSrc) } - } } From ef7c3cd92c42324c727ebab73e04aab97c3ae1e8 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Wed, 8 Jun 2016 19:15:36 -0800 Subject: [PATCH 090/106] Format. --- .../main/kotlin/com/beust/kobalt/internal/IncrementalManager.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/IncrementalManager.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/IncrementalManager.kt index c1ea7dc0..f69e7107 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/IncrementalManager.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/IncrementalManager.kt @@ -80,6 +80,7 @@ class IncrementalManager @Inject constructor(val args: Args, @Assisted val fileN fun outputChecksumFor(taskName: String) : String? = taskInfoFor(taskInfos(), taskName).outputChecksum + /** * @param method is assumed to return an IncrementalTaskInfo. * @return a closure that invokes that method and decide whether to run the task or not based From 25629e4cf71f16118742659d52e1df3b79af3471 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Wed, 8 Jun 2016 20:22:37 -0800 Subject: [PATCH 091/106] val --- .../src/main/kotlin/com/beust/kobalt/internal/CompilerUtils.kt | 2 +- .../main/kotlin/com/beust/kobalt/internal/JvmCompilerPlugin.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/CompilerUtils.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/CompilerUtils.kt index e1f9b3a9..b24b1fbb 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/CompilerUtils.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/CompilerUtils.kt @@ -152,7 +152,7 @@ class CompilerUtils @Inject constructor(val files: KFiles, * Copy the resources from a source directory to the build one */ private fun copyResources(project: Project, context: KobaltContext, sourceSet: SourceSet) { - var outputDir = sourceSet.outputDir + val outputDir = sourceSet.outputDir val variantSourceDirs = context.variant.resourceDirectories(project, sourceSet) if (variantSourceDirs.size > 0) { diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JvmCompilerPlugin.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JvmCompilerPlugin.kt index 94b2edc5..7dbde4c4 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JvmCompilerPlugin.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JvmCompilerPlugin.kt @@ -180,7 +180,7 @@ open class JvmCompilerPlugin @Inject constructor( // If this project has a kapt{} directive, we want to run the Java compiler first val hasKapt = project.projectProperties.get("kaptConfig") != null - var finalAllCompilers = if (hasKapt) swapJavaAndKotlin(allCompilers) else allCompilers + val finalAllCompilers = if (hasKapt) swapJavaAndKotlin(allCompilers) else allCompilers finalAllCompilers.forEach { compiler -> val compilerResults = compilerUtils.invokeCompiler(project, context, compiler, sourceDirectories(project, context), isTest) From 3ed10c90e6e97f8f1227278fb66dd331104da6b8 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Wed, 8 Jun 2016 20:23:20 -0800 Subject: [PATCH 092/106] GITHUB-240: Fix mixed compilation. Fixes https://github.com/cbeust/kobalt/issues/240 --- .../beust/kobalt/internal/CompilerUtils.kt | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/CompilerUtils.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/CompilerUtils.kt index b24b1fbb..7a5053b8 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/CompilerUtils.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/CompilerUtils.kt @@ -3,6 +3,7 @@ package com.beust.kobalt.internal import com.beust.kobalt.TaskResult import com.beust.kobalt.api.* import com.beust.kobalt.maven.DependencyManager +import com.beust.kobalt.maven.dependency.FileDependency import com.beust.kobalt.misc.KFiles import com.beust.kobalt.misc.log import com.google.inject.Inject @@ -69,15 +70,18 @@ class CompilerUtils @Inject constructor(val files: KFiles, val fullClasspath = if (isTest) dependencyManager.testDependencies(project, context) else dependencyManager.dependencies(project, context) - // Remove all the excluded dependencies from the classpath - val classpath = fullClasspath.filter { - ! isDependencyExcluded(it, project.excludedDependencies) - } - + // The directory where the classes get compiled val buildDirectory = if (isTest) File(project.buildDirectory, KFiles.TEST_CLASSES_DIR) - else File(project.classesDir(context)) + else File(project.classesDir(context)) File(project.directory, buildDirectory.path).mkdirs() + // The classpath needs to contain $buildDirectory/classes as well so that projects that contain + // multiple languages can use classes compiled by the compiler run before them. + // We also need to remove all the excluded dependencies from the classpath + val classpath = fullClasspath.filter { + ! isDependencyExcluded(it, project.excludedDependencies) + } + FileDependency(buildDirectory.path) + val initialSourceDirectories = ArrayList(sourceDirectories) // Source directories from the contributors val contributedSourceDirs = @@ -137,7 +141,10 @@ class CompilerUtils @Inject constructor(val files: KFiles, } } - val allSources = (sourceFiles + extraSourceFiles).distinct().filter { File(it).exists() } + val allSources = (sourceFiles + extraSourceFiles) + .map { File(it).canonicalPath } + .distinct() + .filter { File(it).exists() } // Finally, alter the info with the compiler interceptors before returning it val initialActionInfo = CompilerActionInfo(projectDirectory.path, classpath, allSources, From 58ad7179d5bc137db948184a5c5418e44daa3f43 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Wed, 8 Jun 2016 20:23:44 -0800 Subject: [PATCH 093/106] 0.811. --- kobalt/wrapper/kobalt-wrapper.properties | 2 +- src/main/resources/kobalt.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties index 7cc8a907..e1d3489b 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=0.810 \ No newline at end of file +kobalt.version=0.811 \ No newline at end of file diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index 7816bbb6..3876ac68 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=0.810 +kobalt.version=0.811 From db15c8ef5b578da71691cd4fc530f432d0806e61 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 9 Jun 2016 05:37:24 -0800 Subject: [PATCH 094/106] Fix the build path. --- .../com/beust/kobalt/internal/CompilerUtils.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/CompilerUtils.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/CompilerUtils.kt index 7a5053b8..fb551133 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/CompilerUtils.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/CompilerUtils.kt @@ -75,12 +75,16 @@ class CompilerUtils @Inject constructor(val files: KFiles, else File(project.classesDir(context)) File(project.directory, buildDirectory.path).mkdirs() + // Remove all the excluded dependencies from the classpath + var classpath = fullClasspath.filter { + ! isDependencyExcluded(it, project.excludedDependencies) + } + // The classpath needs to contain $buildDirectory/classes as well so that projects that contain // multiple languages can use classes compiled by the compiler run before them. - // We also need to remove all the excluded dependencies from the classpath - val classpath = fullClasspath.filter { - ! isDependencyExcluded(it, project.excludedDependencies) - } + FileDependency(buildDirectory.path) + if (buildDirectory.exists()) { + classpath += FileDependency(buildDirectory.path) + } val initialSourceDirectories = ArrayList(sourceDirectories) // Source directories from the contributors From 7dea679e49d5ba82be0b8b603a7889bfd36c3291 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 9 Jun 2016 05:37:38 -0800 Subject: [PATCH 095/106] 0.812. --- kobalt/wrapper/kobalt-wrapper.properties | 2 +- src/main/resources/kobalt.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties index e1d3489b..4c4a8c68 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=0.811 \ No newline at end of file +kobalt.version=0.812 \ No newline at end of file diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index 3876ac68..0d662ce2 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=0.811 +kobalt.version=0.812 From 795949e8b5f9b300a109e489174dce19ba305cb3 Mon Sep 17 00:00:00 2001 From: DevCharly Date: Fri, 10 Jun 2016 17:52:08 +0200 Subject: [PATCH 096/106] no longer iterate over projects in TaskManager.installDynamicTasks() as discussed here https://github.com/cbeust/kobalt/issues/244#issuecomment-225211217 --- .../main/kotlin/com/beust/kobalt/internal/TaskManager.kt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt index 668b3494..c004c7be 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt @@ -419,11 +419,9 @@ class TaskManager @Inject constructor(val args: Args, private fun installDynamicTasks(projects: List) { dynamicTasks.forEach { task -> - projects.filter { task.plugin.accept(it) }.forEach { project -> - addTask(task.plugin, project, task.name, task.doc, task.group, - task.dependsOn, task.reverseDependsOn, task.runBefore, task.runAfter, task.alwaysRunAfter, - task.closure) - } + addTask(task.plugin, task.project, task.name, task.doc, task.group, + task.dependsOn, task.reverseDependsOn, task.runBefore, task.runAfter, task.alwaysRunAfter, + task.closure) } } From 5a540f3474346b8cc5887f6b2b5431507cbf84cc Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 9 Jun 2016 22:40:26 -0800 Subject: [PATCH 097/106] Not used. --- .../src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt index c004c7be..481d43d9 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt @@ -414,10 +414,10 @@ class TaskManager @Inject constructor(val args: Args, */ fun computePluginTasks(projects: List) { installAnnotationTasks(projects) - installDynamicTasks(projects) + installDynamicTasks() } - private fun installDynamicTasks(projects: List) { + private fun installDynamicTasks() { dynamicTasks.forEach { task -> addTask(task.plugin, task.project, task.name, task.doc, task.group, task.dependsOn, task.reverseDependsOn, task.runBefore, task.runAfter, task.alwaysRunAfter, From 7e983ed529c12a7c9adb480c036ddb8ec2a8da60 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Fri, 10 Jun 2016 21:52:21 -0800 Subject: [PATCH 098/106] GITHUB-231: Fix the incorrect order of builds. Fixes https://github.com/cbeust/kobalt/issues/231 --- .../com/beust/kobalt/internal/TaskManager.kt | 63 +++++++++-------- .../com/beust/kobalt/misc/Topological.kt | 13 ++-- .../com/beust/kobalt/app/BuildScriptUtil.kt | 5 +- .../beust/kobalt/internal/BuildOrderTest.kt | 68 ++++++++++++++++++- .../beust/kobalt/internal/DynamicGraphTest.kt | 6 +- 5 files changed, 113 insertions(+), 42 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt index 481d43d9..f4708c79 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt @@ -4,10 +4,7 @@ import com.beust.kobalt.* import com.beust.kobalt.api.* import com.beust.kobalt.api.annotation.IncrementalTask import com.beust.kobalt.api.annotation.Task -import com.beust.kobalt.misc.Strings -import com.beust.kobalt.misc.benchmarkMillis -import com.beust.kobalt.misc.kobaltError -import com.beust.kobalt.misc.log +import com.beust.kobalt.misc.* import com.google.common.annotations.VisibleForTesting import com.google.common.collect.ArrayListMultimap import com.google.common.collect.ListMultimap @@ -182,34 +179,40 @@ class TaskManager @Inject constructor(val args: Args, */ fun calculateDependentTaskNames(taskNames: List, projects: List): List { val projectMap = hashMapOf().apply { - projects.forEach { put(it.name, it)} - } - val result = ArrayList(taskNames.map { TaskInfo(it) }) - val toProcess = ArrayList(result) - val newToProcess = arrayListOf() - val seen = hashSetOf() - var stop = false - while (! stop) { - toProcess.forEach { ti -> - projectMap[ti.project]?.let { project -> - project.projectExtra.dependsOn.forEach { dp -> - val newTask = TaskInfo(dp.projectName, ti.taskName) - // Insert the project at the top of the list since we haven't added its dependents yet - result.add(0, newTask) - if (! seen.contains(newTask)) { - newToProcess.add(newTask) - seen.add(newTask) - } - } - } - } - stop = newToProcess.isEmpty() - toProcess.clear() - toProcess.addAll(newToProcess) - newToProcess.clear() + projects.forEach { project -> put(project.name, project)} } - return result + val allTaskInfos = HashSet(taskNames.map { TaskInfo(it) }) + with(Topological()) { + val toProcess = ArrayList(allTaskInfos) + val seen = HashSet(allTaskInfos) + val newTasks = hashSetOf() + while (toProcess.any()) { + toProcess.forEach { ti -> + val project = projectMap[ti.project] + val dependents = project!!.projectExtra.dependsOn + if (dependents.any()) { + dependents.forEach { depProject -> + val tiDep = TaskInfo(depProject.name, ti.taskName) + allTaskInfos.add(tiDep) + addEdge(ti, tiDep) + if (! seen.contains(tiDep)) { + newTasks.add(tiDep) + seen.add(tiDep) + } + } + } else { + allTaskInfos.add(ti) + addNode(ti) + } + } + toProcess.clear() + toProcess.addAll(newTasks) + newTasks.clear() + } + val result = sort() + return result + } } val LOG_LEVEL = 3 diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/Topological.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/Topological.kt index b0a92315..38c4c503 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/Topological.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/Topological.kt @@ -10,22 +10,25 @@ import java.util.* */ class Topological { private val dependingOn = ArrayListMultimap.create() + private val nodes = hashSetOf() + + fun addNode(t: T) = nodes.add(t) fun addEdge(t: T, other: T) { + addNode(t) + addNode(other) dependingOn.put(t, other) } - fun addEdge(t: T, others: Array) { - dependingOn.putAll(t, others.toMutableList()) - } - /** * @return the Ts sorted topologically. */ - fun sort(all: ArrayList) : List { + fun sort() : List { + val all = ArrayList(nodes) val result = arrayListOf() var dependMap = HashMultimap.create() dependingOn.keySet().forEach { dependMap.putAll(it, dependingOn.get(it))} + nodes.forEach { dependMap.putAll(it, emptyList())} while (all.size > 0) { val freeNodes = all.filter { dependMap.get(it).isEmpty() diff --git a/src/main/kotlin/com/beust/kobalt/app/BuildScriptUtil.kt b/src/main/kotlin/com/beust/kobalt/app/BuildScriptUtil.kt index fbeaef40..a077a9e6 100644 --- a/src/main/kotlin/com/beust/kobalt/app/BuildScriptUtil.kt +++ b/src/main/kotlin/com/beust/kobalt/app/BuildScriptUtil.kt @@ -20,7 +20,6 @@ import java.io.InputStream import java.lang.reflect.Modifier import java.net.URL import java.net.URLClassLoader -import java.util.* import java.util.jar.JarInputStream class BuildScriptUtil @Inject constructor(val plugins: Plugins, val files: KFiles, @@ -113,14 +112,14 @@ class BuildScriptUtil @Inject constructor(val plugins: Plugins, val files: KFile context.pluginInfo.projectContributors.forEach { contributor -> val descriptions = contributor.projects() descriptions.forEach { pd -> - all.add(pd.project) + topologicalProjects.addNode(pd.project) pd.dependsOn.forEach { dependsOn -> topologicalProjects.addEdge(pd.project, dependsOn) all.add(dependsOn) } } } - val result = topologicalProjects.sort(ArrayList(all)) + val result = topologicalProjects.sort() return result } diff --git a/src/test/kotlin/com/beust/kobalt/internal/BuildOrderTest.kt b/src/test/kotlin/com/beust/kobalt/internal/BuildOrderTest.kt index dabdb163..70051e82 100644 --- a/src/test/kotlin/com/beust/kobalt/internal/BuildOrderTest.kt +++ b/src/test/kotlin/com/beust/kobalt/internal/BuildOrderTest.kt @@ -3,7 +3,7 @@ package com.beust.kobalt.internal import com.beust.kobalt.TestModule import com.beust.kobalt.api.Kobalt import com.beust.kobalt.project -import org.testng.Assert +import org.assertj.core.api.Assertions.assertThat import org.testng.annotations.BeforeClass import org.testng.annotations.DataProvider import org.testng.annotations.Guice @@ -35,7 +35,71 @@ class BuildOrderTest @Inject constructor(val taskManager: TaskManager) { val allProjects = listOf(p1, p2, p3) with(taskManager) { val taskInfos = calculateDependentTaskNames(tasks, allProjects) - Assert.assertEquals(taskInfos.map { it.id }, expectedTasks) + assertThat(taskInfos.map { it.id }).isEqualTo(expectedTasks) } } + + @DataProvider + fun tasks2(): Array> { + return arrayOf( + arrayOf(listOf("p14:assemble"), + listOf(1, 2, 3, 4, 5, 8, 11, 6, 7, 9, 10, 12, 13, 14).map { "p$it:assemble"}) + ) + } + + @Test(dataProvider = "tasks2") + fun shouldBuildInRightOrder2(tasks: List, expectedTasks: List) { + val p1 = project { name ="p1" } + val p2 = project { name ="p2" } + val p3 = project { name ="p3" } + val p4 = project { name ="p4" } + val p5 = project { name ="p5" } + val p6 = project(p5) { name ="p6" } + val p7 = project(p5) { name ="p7" } + val p8 = project { name ="p8" } + val p9 = project(p6, p5, p2, p3) { name ="p9" } + val p10 = project(p9) { name ="p10" } + val p11 = project { name ="p11" } + val p12 = project(p1, p7, p9, p10, p11) { name ="p12" } + val p13 = project(p4, p8, p9, p12) { name ="p13" } + val p14 = project(p12, p13) { name ="p14" } + + fun appearsBefore(taskInfos: List, first: String, second: String) { + var sawFirst = false + var sawSecond = false + taskInfos.forEach { ti -> + if (ti.project == first) { + sawFirst = true + } + if (ti.project == second) { + assertThat(sawFirst) + .`as`("Expected to see $first before $second in ${taskInfos.map {it.project}}") + .isTrue() + sawSecond = true + } + } + assertThat(sawFirst).`as`("Didn't see $first").isTrue() + assertThat(sawSecond).`as`("Didn't see $second").isTrue() + } + + fun appearsBefore(taskInfos: List, firsts: List, second: String) { + firsts.forEach { first -> + appearsBefore(taskInfos, first, second) + } + } + + // 1, 2, 3, 4, 5, 8, 11, 6, 7, 9, 10, 12, 13, 14 + val allProjects = listOf(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14) + with(taskManager) { + val taskInfos = calculateDependentTaskNames(tasks, allProjects) + assertThat(taskInfos.size).isEqualTo(expectedTasks.size) + appearsBefore(taskInfos, "p5", "p6") + appearsBefore(taskInfos, "p5", "p7") + appearsBefore(taskInfos, "p9", "p10") + appearsBefore(taskInfos, listOf("p1", "p7", "p9", "p10", "p11"), "p12") + appearsBefore(taskInfos, listOf("p4", "p8", "p9", "p12"), "p13") + appearsBefore(taskInfos, listOf("p12", "p13"), "p14") + } + } + } diff --git a/src/test/kotlin/com/beust/kobalt/internal/DynamicGraphTest.kt b/src/test/kotlin/com/beust/kobalt/internal/DynamicGraphTest.kt index 07b2ffd2..6298c994 100644 --- a/src/test/kotlin/com/beust/kobalt/internal/DynamicGraphTest.kt +++ b/src/test/kotlin/com/beust/kobalt/internal/DynamicGraphTest.kt @@ -125,8 +125,10 @@ class DynamicGraphTest { addEdge("b2", "a2") addEdge("c1", "b1") addEdge("c1", "b2") - val sorted = sort(arrayListOf("a1", "a2", "b1", "b2", "c1", "x", "y")) - Assert.assertEquals(sorted, arrayListOf("a1", "a2", "x", "y", "b1", "b2", "c1")) + addNode("x") + addNode("y") + val sorted = sort() + Assert.assertEquals(sorted, arrayListOf("a1", "a2", "x", "y", "b2", "b1", "c1")) } } From 95ad0d101f9ce88c25f5534ffd08b338a11e044d Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Fri, 10 Jun 2016 22:13:34 -0800 Subject: [PATCH 099/106] 0.813. --- kobalt/wrapper/kobalt-wrapper.properties | 2 +- src/main/resources/kobalt.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties index 4c4a8c68..d85fc85c 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=0.812 \ No newline at end of file +kobalt.version=0.813 \ No newline at end of file diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index 0d662ce2..e984c33f 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=0.812 +kobalt.version=0.813 From f8746460be0587d7389bf16ce1b25260411910a4 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Fri, 10 Jun 2016 22:18:48 -0800 Subject: [PATCH 100/106] Typo. --- .../src/main/kotlin/com/beust/kobalt/JarGenerator.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/JarGenerator.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/JarGenerator.kt index a8ac7c41..d99c59f5 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/JarGenerator.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/JarGenerator.kt @@ -91,7 +91,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 far jar") + log(2, "Finding included files for fat jar") val seen = hashSetOf() @Suppress("UNCHECKED_CAST") From e276f3b6d5a27d8b92678030b31476331f35cf6a Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Fri, 10 Jun 2016 22:19:00 -0800 Subject: [PATCH 101/106] Handle tasks with no project. --- .../com/beust/kobalt/internal/TaskManager.kt | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt index f4708c79..54dfa9eb 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt @@ -190,20 +190,22 @@ class TaskManager @Inject constructor(val args: Args, while (toProcess.any()) { toProcess.forEach { ti -> val project = projectMap[ti.project] - val dependents = project!!.projectExtra.dependsOn - if (dependents.any()) { - dependents.forEach { depProject -> - val tiDep = TaskInfo(depProject.name, ti.taskName) - allTaskInfos.add(tiDep) - addEdge(ti, tiDep) - if (! seen.contains(tiDep)) { - newTasks.add(tiDep) - seen.add(tiDep) + if (project != null) { + val dependents = project.projectExtra.dependsOn + if (dependents.any()) { + dependents.forEach { depProject -> + val tiDep = TaskInfo(depProject.name, ti.taskName) + allTaskInfos.add(tiDep) + addEdge(ti, tiDep) + if (!seen.contains(tiDep)) { + newTasks.add(tiDep) + seen.add(tiDep) + } } + } else { + allTaskInfos.add(ti) + addNode(ti) } - } else { - allTaskInfos.add(ti) - addNode(ti) } } toProcess.clear() From cd77dc39a4d1484c4f341ef92ee5160b5fe819ea Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Sat, 11 Jun 2016 14:54:14 -0700 Subject: [PATCH 102/106] Forgot simple case. --- .../com/beust/kobalt/internal/TaskManager.kt | 18 ++++++++++++++---- .../beust/kobalt/internal/BuildOrderTest.kt | 1 + 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt index 54dfa9eb..6d8e478c 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/TaskManager.kt @@ -187,6 +187,14 @@ class TaskManager @Inject constructor(val args: Args, val toProcess = ArrayList(allTaskInfos) val seen = HashSet(allTaskInfos) val newTasks = hashSetOf() + + fun maybeAdd(taskInfo: TaskInfo) { + if (!seen.contains(taskInfo)) { + newTasks.add(taskInfo) + seen.add(taskInfo) + } + } + while (toProcess.any()) { toProcess.forEach { ti -> val project = projectMap[ti.project] @@ -197,15 +205,17 @@ class TaskManager @Inject constructor(val args: Args, val tiDep = TaskInfo(depProject.name, ti.taskName) allTaskInfos.add(tiDep) addEdge(ti, tiDep) - if (!seen.contains(tiDep)) { - newTasks.add(tiDep) - seen.add(tiDep) - } + maybeAdd(tiDep) } } else { allTaskInfos.add(ti) addNode(ti) } + } else { + // No project specified for this task, run that task in all the projects + projects.forEach { + maybeAdd(TaskInfo(it.name, ti.taskName)) + } } } toProcess.clear() diff --git a/src/test/kotlin/com/beust/kobalt/internal/BuildOrderTest.kt b/src/test/kotlin/com/beust/kobalt/internal/BuildOrderTest.kt index 70051e82..1beab1a3 100644 --- a/src/test/kotlin/com/beust/kobalt/internal/BuildOrderTest.kt +++ b/src/test/kotlin/com/beust/kobalt/internal/BuildOrderTest.kt @@ -20,6 +20,7 @@ class BuildOrderTest @Inject constructor(val taskManager: TaskManager) { @DataProvider fun tasks(): Array> { return arrayOf( + arrayOf(listOf("assemble"), listOf("p1:assemble", "p2:assemble", "p3:assemble")), arrayOf(listOf("p1:assemble"), listOf("p1:assemble")), arrayOf(listOf("p2:assemble"), listOf("p1:assemble", "p2:assemble")), arrayOf(listOf("p3:assemble"), listOf("p1:assemble", "p2:assemble", "p3:assemble")) From bf74f310b1412008c7f09bb23ab10fcfdd15ca7a Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Sat, 11 Jun 2016 14:57:45 -0700 Subject: [PATCH 103/106] Refactor test. --- .../com/beust/kobalt/internal/BuildOrderTest.kt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/test/kotlin/com/beust/kobalt/internal/BuildOrderTest.kt b/src/test/kotlin/com/beust/kobalt/internal/BuildOrderTest.kt index 1beab1a3..eaf33a9f 100644 --- a/src/test/kotlin/com/beust/kobalt/internal/BuildOrderTest.kt +++ b/src/test/kotlin/com/beust/kobalt/internal/BuildOrderTest.kt @@ -17,13 +17,16 @@ class BuildOrderTest @Inject constructor(val taskManager: TaskManager) { Kobalt.init(TestModule()) } + private fun toExpectedList(vararg projectNames: Int) = projectNames.map { "p$it:assemble"}.toList() + @DataProvider fun tasks(): Array> { + return arrayOf( - arrayOf(listOf("assemble"), listOf("p1:assemble", "p2:assemble", "p3:assemble")), - arrayOf(listOf("p1:assemble"), listOf("p1:assemble")), - arrayOf(listOf("p2:assemble"), listOf("p1:assemble", "p2:assemble")), - arrayOf(listOf("p3:assemble"), listOf("p1:assemble", "p2:assemble", "p3:assemble")) + arrayOf(listOf("assemble"), toExpectedList(1, 2, 3)), + arrayOf(listOf("p1:assemble"), toExpectedList(1)), + arrayOf(listOf("p2:assemble"), toExpectedList(1, 2)), + arrayOf(listOf("p3:assemble"), toExpectedList(1, 2, 3)) ) } @@ -43,8 +46,7 @@ class BuildOrderTest @Inject constructor(val taskManager: TaskManager) { @DataProvider fun tasks2(): Array> { return arrayOf( - arrayOf(listOf("p14:assemble"), - listOf(1, 2, 3, 4, 5, 8, 11, 6, 7, 9, 10, 12, 13, 14).map { "p$it:assemble"}) + arrayOf(listOf("p14:assemble"), toExpectedList(1, 2, 3, 4, 5, 8, 11, 6, 7, 9, 10, 12, 13, 14)) ) } From b287615c11a95754f2e57cbbd8e90ffc3364728c Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Sat, 11 Jun 2016 14:58:31 -0700 Subject: [PATCH 104/106] 0.814. --- kobalt/wrapper/kobalt-wrapper.properties | 2 +- src/main/resources/kobalt.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties index d85fc85c..25ce6fa8 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=0.813 \ No newline at end of file +kobalt.version=0.814 \ No newline at end of file diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index e984c33f..c6f13ab1 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=0.813 +kobalt.version=0.814 From 13de09465146e5666bfd0e2ebfa0000545811882 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Sun, 12 Jun 2016 19:44:12 -0700 Subject: [PATCH 105/106] Refactor test. --- .../beust/kobalt/internal/BuildOrderTest.kt | 42 +++++++++---------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/src/test/kotlin/com/beust/kobalt/internal/BuildOrderTest.kt b/src/test/kotlin/com/beust/kobalt/internal/BuildOrderTest.kt index eaf33a9f..835d342c 100644 --- a/src/test/kotlin/com/beust/kobalt/internal/BuildOrderTest.kt +++ b/src/test/kotlin/com/beust/kobalt/internal/BuildOrderTest.kt @@ -20,15 +20,11 @@ class BuildOrderTest @Inject constructor(val taskManager: TaskManager) { private fun toExpectedList(vararg projectNames: Int) = projectNames.map { "p$it:assemble"}.toList() @DataProvider - fun tasks(): Array> { - - return arrayOf( - arrayOf(listOf("assemble"), toExpectedList(1, 2, 3)), - arrayOf(listOf("p1:assemble"), toExpectedList(1)), - arrayOf(listOf("p2:assemble"), toExpectedList(1, 2)), - arrayOf(listOf("p3:assemble"), toExpectedList(1, 2, 3)) - ) - } + fun tasks() = arrayOf( + arrayOf(listOf("assemble"), toExpectedList(1, 2, 3)), + arrayOf(listOf("p1:assemble"), toExpectedList(1)), + arrayOf(listOf("p2:assemble"), toExpectedList(1, 2)), + arrayOf(listOf("p3:assemble"), toExpectedList(1, 2, 3))) @Test(dataProvider = "tasks") fun shouldBuildInRightOrder(tasks: List, expectedTasks: List) { @@ -67,16 +63,16 @@ class BuildOrderTest @Inject constructor(val taskManager: TaskManager) { val p13 = project(p4, p8, p9, p12) { name ="p13" } val p14 = project(p12, p13) { name ="p14" } - fun appearsBefore(taskInfos: List, first: String, second: String) { + fun Collection.appearsBefore(first: String, second: String) { var sawFirst = false var sawSecond = false - taskInfos.forEach { ti -> + forEach { ti -> if (ti.project == first) { sawFirst = true } if (ti.project == second) { assertThat(sawFirst) - .`as`("Expected to see $first before $second in ${taskInfos.map {it.project}}") + .`as`("Expected to see $first before $second in ${map {it.project}}") .isTrue() sawSecond = true } @@ -85,23 +81,23 @@ class BuildOrderTest @Inject constructor(val taskManager: TaskManager) { assertThat(sawSecond).`as`("Didn't see $second").isTrue() } - fun appearsBefore(taskInfos: List, firsts: List, second: String) { + fun Collection.appearsBefore(firsts: List, second: String) { firsts.forEach { first -> - appearsBefore(taskInfos, first, second) + appearsBefore(first, second) } } - // 1, 2, 3, 4, 5, 8, 11, 6, 7, 9, 10, 12, 13, 14 val allProjects = listOf(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14) with(taskManager) { - val taskInfos = calculateDependentTaskNames(tasks, allProjects) - assertThat(taskInfos.size).isEqualTo(expectedTasks.size) - appearsBefore(taskInfos, "p5", "p6") - appearsBefore(taskInfos, "p5", "p7") - appearsBefore(taskInfos, "p9", "p10") - appearsBefore(taskInfos, listOf("p1", "p7", "p9", "p10", "p11"), "p12") - appearsBefore(taskInfos, listOf("p4", "p8", "p9", "p12"), "p13") - appearsBefore(taskInfos, listOf("p12", "p13"), "p14") + with(calculateDependentTaskNames(tasks, allProjects)) { + assertThat(size).isEqualTo(expectedTasks.size) + appearsBefore("p5", "p6") + appearsBefore("p5", "p7") + appearsBefore("p9", "p10") + appearsBefore(listOf("p1", "p7", "p9", "p10", "p11"), "p12") + appearsBefore(listOf("p4", "p8", "p9", "p12"), "p13") + appearsBefore(listOf("p12", "p13"), "p14") + } } } From d9b0e3a40c4ef99bde5f69cf9d3d9089e4722e5f Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Sun, 12 Jun 2016 21:55:32 -0800 Subject: [PATCH 106/106] TestNG 6.9.11. --- kobalt/src/Build.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kobalt/src/Build.kt b/kobalt/src/Build.kt index 8c2574f8..af5b0b66 100644 --- a/kobalt/src/Build.kt +++ b/kobalt/src/Build.kt @@ -156,7 +156,7 @@ val kobaltApp = project(kobaltPluginApi, wrapper) { } dependenciesTest { - compile("org.testng:testng:6.9.10", + compile("org.testng:testng:6.9.11", "org.assertj:assertj-core:3.4.1") }