From 5d11395b7c2b1c297dc153fd8cc2976fcc1b4b0e Mon Sep 17 00:00:00 2001 From: Dmitry Zhuravlev Date: Fri, 14 Apr 2017 17:18:16 +0300 Subject: [PATCH 01/33] + server should send buildFileClasspath to plugin. close #410 --- .../src/main/kotlin/com/beust/kobalt/api/Kobalt.kt | 1 + .../com/beust/kobalt/app/remote/RemoteDependencyData.kt | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/Kobalt.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/Kobalt.kt index 527d35b2..5a1d952c 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/Kobalt.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/Kobalt.kt @@ -68,6 +68,7 @@ class Kobalt { fun addBuildFileClasspath(dep: String) { val dependencyManager = Kobalt.INJECTOR.getInstance(DependencyManager::class.java) + //FIXME buildFileClasspath collection never becomes clear! each synchronization will add the same dependencies to it buildFileClasspath.add(dependencyManager.create(dep)) } diff --git a/src/main/kotlin/com/beust/kobalt/app/remote/RemoteDependencyData.kt b/src/main/kotlin/com/beust/kobalt/app/remote/RemoteDependencyData.kt index bd1914ac..3f6a2a31 100644 --- a/src/main/kotlin/com/beust/kobalt/app/remote/RemoteDependencyData.kt +++ b/src/main/kotlin/com/beust/kobalt/app/remote/RemoteDependencyData.kt @@ -2,6 +2,7 @@ package com.beust.kobalt.app.remote import com.beust.kobalt.Args import com.beust.kobalt.api.IClasspathDependency +import com.beust.kobalt.api.Kobalt import com.beust.kobalt.api.Project import com.beust.kobalt.app.BuildFileCompiler import com.beust.kobalt.internal.DynamicGraph @@ -46,6 +47,8 @@ class RemoteDependencyData @Inject constructor(val executors: KobaltExecutors, v val buildFileCompiler = buildFileCompilerFactory.create(buildSources, pluginInfo) val projectResult = buildFileCompiler.compileBuildFiles(args) + val buildFileDependencies = Kobalt.buildFileClasspath.map {toDependencyData(it, "compile")} + val pluginDependencies = projectResult.pluginUrls.map { File(it.toURI()) }.map { DependencyData(it.name, "compile", it.absolutePath) } @@ -176,7 +179,7 @@ class RemoteDependencyData @Inject constructor(val executors: KobaltExecutors, v }) } - return GetDependenciesData(projectDatas, allTasks, pluginDependencies, findProjectResult.buildContentRoots, + return GetDependenciesData(projectDatas, allTasks, pluginDependencies, buildFileDependencies, findProjectResult.buildContentRoots, projectResult.taskResult.errorMessage) } @@ -202,6 +205,7 @@ class RemoteDependencyData @Inject constructor(val executors: KobaltExecutors, v class GetDependenciesData(val projects: List = emptyList(), val allTasks: Collection = emptySet(), val pluginDependencies: List = emptyList(), + val buildFileDependencies: List = emptyList(), val buildContentRoots: List = emptyList(), val errorMessage: String?) { companion object { From 876420b434d6f947b0e108730f86321cc062ff9a Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Fri, 14 Apr 2017 22:45:37 -0700 Subject: [PATCH 02/33] Fix for OSX and calling outsite of residing directory. --- dist/kobaltw | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dist/kobaltw b/dist/kobaltw index 4f39dc35..333738df 100755 --- a/dist/kobaltw +++ b/dist/kobaltw @@ -1,7 +1,11 @@ #!/usr/bin/env sh -DIRNAME=`dirname $(readlink -f "$0")` -if [[ "$(uname)" == "CYGWIN"* ]]; then - DIRNAME=`cygpath -d "$DIRNAME"` +case "$(uname)" in + CYGWIN*) DIRNAME=$(cygpath -d "$(dirname "$(readlink -f "$0")")");; + Darwin*) DIRNAME=$(dirname "$(readlink "$0")");; + *) DIRNAME=$(dirname "$(readlink -f "$0")");; +esac +if [ "$DIRNAME" = "." ]; then + DIRNAME="$(dirname "$0")" fi java -jar "${DIRNAME}/../kobalt/wrapper/kobalt-wrapper.jar" $* \ No newline at end of file From 1fb984ff63e58c696df63ae36e594f34d03cefb9 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Sat, 15 Apr 2017 07:49:35 -0700 Subject: [PATCH 03/33] 1.0.63. --- 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 f5e39865..e23fe5ec 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=1.0.62 +kobalt.version=1.0.63 diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index f5e39865..e23fe5ec 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=1.0.62 +kobalt.version=1.0.63 From 85460422e0797f266b4d4b88330d5606be608646 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Sat, 15 Apr 2017 07:51:44 -0700 Subject: [PATCH 04/33] GH-414: Authenticated repos not working. Fixes https://github.com/cbeust/kobalt/issues/414 --- .../kotlin/com/beust/kobalt/api/Kobalt.kt | 4 ++ .../kotlin/com/beust/kobalt/maven/Kurl.kt | 25 +---------- .../maven/aether/KobaltMavenResolver.kt | 42 ++++++++++++++++++- 3 files changed, 46 insertions(+), 25 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/Kobalt.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/Kobalt.kt index 527d35b2..f825efeb 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/Kobalt.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/Kobalt.kt @@ -5,6 +5,7 @@ import com.beust.kobalt.HostConfig import com.beust.kobalt.Plugins import com.beust.kobalt.internal.PluginInfo import com.beust.kobalt.maven.DependencyManager +import com.beust.kobalt.maven.aether.KobaltMavenResolver import com.google.inject.Guice import com.google.inject.Injector import com.google.inject.Module @@ -55,6 +56,9 @@ class Kobalt { // Repos from the build file result.addAll(reposFromBuildFiles) + result.forEach { + KobaltMavenResolver.initAuthentication(it) + } return result.toHashSet() } diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/Kurl.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/Kurl.kt index 6b9c0a62..909c18c5 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/Kurl.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/Kurl.kt @@ -1,9 +1,8 @@ package com.beust.kobalt.maven import com.beust.kobalt.HostConfig -import com.beust.kobalt.KobaltException +import com.beust.kobalt.maven.aether.KobaltMavenResolver import com.beust.kobalt.maven.dependency.FileDependency -import com.beust.kobalt.misc.LocalProperties import java.io.* import java.net.HttpURLConnection import java.net.URL @@ -21,27 +20,7 @@ class Kurl(val hostInfo: HostConfig) { } init { - // See if the URL needs to be authenticated. Look in local.properties for keys - // of the format authUrl..user=xxx and authUrl..password=xxx - val properties = LocalProperties().localProperties - val host = java.net.URL(hostInfo.url).host - properties.entries.forEach { - val key = it.key.toString() - if (key == "$KEY.$host.$VALUE_USER") { - hostInfo.username = properties.getProperty(key) - } else if (key == "$KEY.$host.$VALUE_PASSWORD") { - hostInfo.password = properties.getProperty(key) - } - } - fun error(s1: String, s2: String) { - throw KobaltException("Found \"$s1\" but not \"$s2\" in local.properties for $KEY.$host", - docUrl = "http://beust.com/kobalt/documentation/index.html#maven-repos-authenticated") - } - if (! hostInfo.username.isNullOrBlank() && hostInfo.password.isNullOrBlank()) { - error("username", "password") - } else if(hostInfo.username.isNullOrBlank() && ! hostInfo.password.isNullOrBlank()) { - error("password", "username") - } + KobaltMavenResolver.initAuthentication(hostInfo) } override fun toString() = hostInfo.toString() diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/aether/KobaltMavenResolver.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/aether/KobaltMavenResolver.kt index 376081df..18ed6659 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/aether/KobaltMavenResolver.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/aether/KobaltMavenResolver.kt @@ -2,11 +2,14 @@ package com.beust.kobalt.maven.aether import com.beust.kobalt.Args import com.beust.kobalt.HostConfig +import com.beust.kobalt.KobaltException import com.beust.kobalt.api.Kobalt import com.beust.kobalt.internal.KobaltSettings import com.beust.kobalt.internal.getProxy +import com.beust.kobalt.maven.Kurl import com.beust.kobalt.maven.LocalRepo import com.beust.kobalt.maven.MavenId +import com.beust.kobalt.misc.LocalProperties import com.google.common.eventbus.EventBus import com.google.inject.Inject import org.eclipse.aether.artifact.Artifact @@ -21,6 +24,7 @@ import org.eclipse.aether.resolution.DependencyRequest import org.eclipse.aether.resolution.DependencyResult import org.eclipse.aether.resolution.VersionRangeRequest import org.eclipse.aether.resolution.VersionRangeResult +import org.eclipse.aether.util.repository.AuthenticationBuilder import java.util.* class KobaltMavenResolver @Inject constructor(val settings: KobaltSettings, @@ -32,6 +36,31 @@ class KobaltMavenResolver @Inject constructor(val settings: KobaltSettings, MavenId.toId(it.groupId, it.artifactId, it.extension, it.classifier, it.version) } fun isRangeVersion(id: String) = id.contains(",") + + fun initAuthentication(hostInfo: HostConfig) { + // See if the URL needs to be authenticated. Look in local.properties for keys + // of the format authUrl..user=xxx and authUrl..password=xxx + val properties = LocalProperties().localProperties + val host = java.net.URL(hostInfo.url).host + properties.entries.forEach { + val key = it.key.toString() + if (key == "${Kurl.KEY}.$host.${Kurl.VALUE_USER}") { + hostInfo.username = properties.getProperty(key) + } else if (key == "${Kurl.KEY}.$host.${Kurl.VALUE_PASSWORD}") { + hostInfo.password = properties.getProperty(key) + } + } + fun error(s1: String, s2: String) { + throw KobaltException("Found \"$s1\" but not \"$s2\" in local.properties for ${Kurl.KEY}.$host", + docUrl = "http://beust.com/kobalt/documentation/index.html#maven-repos-authenticated") + } + if (! hostInfo.username.isNullOrBlank() && hostInfo.password.isNullOrBlank()) { + error("username", "password") + } else if(hostInfo.username.isNullOrBlank() && ! hostInfo.password.isNullOrBlank()) { + error("password", "username") + } + + } } fun resolveToArtifact(id: String, scope: Scope? = null, @@ -110,8 +139,17 @@ class KobaltMavenResolver @Inject constructor(val settings: KobaltSettings, private val system = Booter.newRepositorySystem() private val session = Booter.newRepositorySystemSession(system, localRepo.localRepo, settings, eventBus) - private fun createRepo(hostConfig: HostConfig) = - RemoteRepository.Builder(hostConfig.name, "default", hostConfig.url).build() + private fun createRepo(hostConfig: HostConfig) : RemoteRepository { + val builder = RemoteRepository.Builder(hostConfig.name, "default", hostConfig.url) + if (hostConfig.hasAuth()) { + val auth = AuthenticationBuilder() + .addUsername(hostConfig.username) + .addPassword(hostConfig.password) + .build() + builder.setAuthentication(auth) + } + return builder.build() + } private val kobaltRepositories: List get() = Kobalt.repos.map { From 30e71afbc8a8e09d523c949968d75b799e0e81f8 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Sat, 15 Apr 2017 07:52:02 -0700 Subject: [PATCH 05/33] 1.0.64. --- 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 e23fe5ec..36041074 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=1.0.63 +kobalt.version=1.0.64 diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index e23fe5ec..36041074 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=1.0.63 +kobalt.version=1.0.64 From 822a9701a6c9f228cfc70b225738c4d426266908 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Sun, 16 Apr 2017 18:24:26 -0700 Subject: [PATCH 06/33] Fix broken TestNG dependency. --- 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 a497aac2..76c1a7af 100644 --- a/kobalt/src/Build.kt +++ b/kobalt/src/Build.kt @@ -114,7 +114,7 @@ val kobaltPluginApi = project { "org.slf4j:slf4j-simple:${Versions.slf4j}", *mavenResolver("api", "spi", "util", "impl", "connector-basic", "transport-http", "transport-file"), "org.apache.maven:maven-aether-provider:3.3.9", - "org.testng.testng-remote:testng-remote:1.3.0", + "org.testng.testng-remote:testng-remote:1.3.2", "org.testng:testng:${Versions.testng}", "commons-io:commons-io:2.5", "org.junit.platform:junit-platform-surefire-provider:${Versions.junitPlatform}", From 4f9c5f383ed801b611b0cc87f194e010b0fcb5ef Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Sun, 16 Apr 2017 18:53:01 -0700 Subject: [PATCH 07/33] 1.0.65. --- 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 36041074..bd5e50a2 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=1.0.64 +kobalt.version=1.0.65 diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index 36041074..bd5e50a2 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=1.0.64 +kobalt.version=1.0.65 From cbb02e76150f4241d73f9471e2d5a9c4bf236c08 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Sun, 16 Apr 2017 19:08:22 -0700 Subject: [PATCH 08/33] 1.0.66. --- 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 bd5e50a2..c5750f12 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=1.0.65 +kobalt.version=1.0.66 diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index bd5e50a2..c5750f12 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=1.0.65 +kobalt.version=1.0.66 From a7006d5cd77cf2c7772305813ae340d2ba3c3e44 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Sun, 16 Apr 2017 19:21:50 -0700 Subject: [PATCH 09/33] kapt3 work. --- .../com/beust/kobalt/plugin/apt/AptPlugin.kt | 119 +++++++++++++++++- 1 file changed, 117 insertions(+), 2 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 b90c9f5a..039e22be 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/apt/AptPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/apt/AptPlugin.kt @@ -1,10 +1,19 @@ package com.beust.kobalt.plugin.apt +import com.beust.kobalt.Constants +import com.beust.kobalt.TaskResult import com.beust.kobalt.api.* import com.beust.kobalt.api.annotation.Directive +import com.beust.kobalt.api.annotation.Task +import com.beust.kobalt.homeDir +import com.beust.kobalt.internal.CompilerUtils import com.beust.kobalt.maven.DependencyManager +import com.beust.kobalt.maven.aether.Filters +import com.beust.kobalt.maven.aether.Scope +import com.beust.kobalt.maven.dependency.FileDependency import com.beust.kobalt.misc.KFiles import com.beust.kobalt.misc.warn +import com.beust.kobalt.plugin.kotlin.KotlinPlugin import com.google.common.collect.ArrayListMultimap import com.google.inject.Inject import java.io.File @@ -19,7 +28,8 @@ import javax.inject.Singleton * (outputDir, etc...). */ @Singleton -class AptPlugin @Inject constructor(val dependencyManager: DependencyManager) +class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, val kotlinPlugin: KotlinPlugin, + val compilerUtils: CompilerUtils) : BasePlugin(), ICompilerFlagContributor, ISourceDirectoryContributor { // ISourceDirectoryContributor @@ -49,6 +59,7 @@ class AptPlugin @Inject constructor(val dependencyManager: DependencyManager) override val name = PLUGIN_NAME override fun apply(project: Project, context: KobaltContext) { + super.apply(project, context) listOf(aptConfigs[project.name]?.outputDir, aptConfigs[project.name]?.outputDir) .filterNotNull() .distinct() @@ -66,6 +77,110 @@ class AptPlugin @Inject constructor(val dependencyManager: DependencyManager) KFiles.joinAndMakeDir(project.directory, project.buildDirectory, outputDir, context.variant.toIntermediateDir()) + private fun generatedSources(project: Project, context: KobaltContext, outputDir: String) = + KFiles.joinDir(generated(project, context, outputDir), "sources") + private fun generatedStubs(project: Project, context: KobaltContext, outputDir: String) = + KFiles.joinDir(generated(project, context, outputDir), "stubs") + private fun generatedClasses(project: Project, context: KobaltContext, outputDir: String) = + KFiles.joinDir(generated(project, context, outputDir), "classes") + +// @Task(name = "compileKapt", dependsOn = arrayOf("runKapt"), reverseDependsOn = arrayOf("compile")) + fun taskCompileKapt(project: Project) : TaskResult { + kaptConfigs[project.name]?.let { config -> + val sourceDirs = listOf( + generatedStubs(project, context, config.outputDir), + generatedSources(project, context, config.outputDir)) + val sourceFiles = KFiles.findSourceFiles(project.directory, sourceDirs, listOf("kt", "java")).toList() + val buildDirectory = File(KFiles.joinDir(project.directory, + generatedClasses(project, context, config.outputDir))) + val flags = listOf() + val cai = CompilerActionInfo(project.directory, allDependencies(), sourceFiles, listOf(".kt"), + buildDirectory, flags, emptyList(), forceRecompile = true) + + val cr = compilerUtils.invokeCompiler(project, context, kotlinPlugin.compiler, cai) + println("") + } + + return TaskResult() + } + + val annotationDependencyId = "org.jetbrains.kotlin:kotlin-annotation-processing:" + + Constants.KOTLIN_COMPILER_VERSION + + fun annotationProcessorDependency() = dependencyManager.create(annotationDependencyId) + + fun aptJarDependencies() : List { + val apDep = dependencyManager.create("net.thauvin.erik.:semver:0.9.6-beta") + val apDep2 = FileDependency(homeDir("t/semver-example-kotlin/lib/semver-0.9.7.jar")) + return listOf(apDep2) + } + + fun allDependencies(): List { + val allDeps = listOf(annotationProcessorDependency()) + aptJarDependencies() + + return allDeps + } + +// @Task(name = "runKapt", reverseDependsOn = arrayOf("compile"), runAfter = arrayOf("clean")) + fun taskRunKapt(project: Project) : TaskResult { + val flags = arrayListOf() + kaptConfigs[project.name]?.let { config -> + + fun kaptPluginFlag(flagValue: String): String { + return "plugin:org.jetbrains.kotlin.kapt3:$flagValue" + } + + val generated = generated(project, context, config.outputDir) + val generatedSources = generatedSources(project, context, config.outputDir) + File(generatedSources).mkdirs() + + val allDeps = allDependencies() + flags.add("-Xplugin") + flags.add(annotationProcessorDependency().jarFile.get().absolutePath) + flags.add("-P") + val kaptPluginFlags = arrayListOf() +// kaptPluginFlags.add(kaptPluginFlag("aptOnly=true")) + + kaptPluginFlags.add(kaptPluginFlag("sources=" + generatedSources)) + kaptPluginFlags.add(kaptPluginFlag("classes=" + generatedClasses(project, context, config.outputDir))) + kaptPluginFlags.add(kaptPluginFlag("stubs=" + generatedStubs(project, context, config.outputDir))) + kaptPluginFlags.add(kaptPluginFlag("verbose=true")) + kaptPluginFlags.add(kaptPluginFlag("aptOnly=false")) + val dependencies = dependencyManager.calculateDependencies(project, context, + Filters.EXCLUDE_OPTIONAL_FILTER, + listOf(Scope.COMPILE), + allDeps) + dependencies.forEach { + val jarFile = it.jarFile.get() + kaptPluginFlags.add(kaptPluginFlag("apclasspath=$jarFile")) + } + + flags.add(kaptPluginFlags.joinToString(",")) + listOf("-language-version", "1.1", " -api-version", "1.1").forEach { + flags.add(it) + } + val sourceFiles = +// KFiles.findSourceFiles(project.directory, +// listOf("src/tmp/kotlin"), +// listOf("kt")) +// .toList() + + KFiles.findSourceFiles(project.directory, project.sourceDirectories, listOf("kt")).toList() + + generatedSources +// + val buildDirectory = File(KFiles.joinDir(project.directory, generated)) + val cai = CompilerActionInfo(project.directory, allDeps, sourceFiles, listOf(".kt"), + buildDirectory, flags, emptyList(), forceRecompile = true) + + println("FLAGS: " + flags.joinToString("\n")) + println(" " + kaptPluginFlags.joinToString("\n ")) + val cr = compilerUtils.invokeCompiler(project, context, kotlinPlugin.compiler, cai) + println("") + } + + return TaskResult() + } + // ICompilerFlagContributor override fun compilerFlagsFor(project: Project, context: KobaltContext, currentFlags: List, suffixesBeingCompiled: List): List { @@ -76,7 +191,7 @@ class AptPlugin @Inject constructor(val dependencyManager: DependencyManager) fun addFlags(outputDir: String) { aptDependencies[project.name]?.let { result.add("-s") - result.add(generated(project, context, outputDir)) + result.add(generatedSources(project, context, outputDir)) } } From 6816ba8a3bc82e5909d983cd16dffeeeccda2ea7 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Sun, 16 Apr 2017 20:13:28 -0700 Subject: [PATCH 10/33] Sanitize repo names from repos(). --- .../src/main/kotlin/com/beust/kobalt/BuildScript.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/BuildScript.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/BuildScript.kt index 48ecc0e3..799964bf 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/BuildScript.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/BuildScript.kt @@ -74,7 +74,7 @@ data class ProxyConfig(val host: String = "", val port: Int = 0, val type: Strin fun toAetherProxy() = Proxy(type, host, port) // TODO make support for proxy auth } -data class HostConfig(var url: String = "", var name: String = url, var username: String? = null, +data class HostConfig(var url: String = "", var name: String, var username: String? = null, var password: String? = null) { fun hasAuth() : Boolean { return (! username.isNullOrBlank()) && (! password.isNullOrBlank()) @@ -95,8 +95,10 @@ fun repos(vararg repos : String) { newRepos(*repos) } +fun createRepoName(url: String) = url.replace("/", "_").replace("\\", "_").replace(":", "_") + fun newRepos(vararg repos: String) { - repos.forEach { Kobalt.addRepo(HostConfig(it)) } + repos.forEach { Kobalt.addRepo(HostConfig(it, createRepoName(it))) } } fun buildFileClasspath(vararg deps: String) { @@ -115,7 +117,7 @@ fun authRepos(vararg repos : HostConfig) { } @Directive -fun authRepo(init: HostConfig.() -> Unit) = HostConfig().apply { init() } +fun authRepo(init: HostConfig.() -> Unit) = HostConfig(name = "").apply { init() } @Directive fun glob(g: String) : IFileSpec.GlobSpec = IFileSpec.GlobSpec(g) From e9b8212dbdddc9a50221ca1b1e7bbfef13df6c78 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Sun, 16 Apr 2017 20:30:44 -0700 Subject: [PATCH 11/33] Fix build. --- .../kotlin/com/beust/kobalt/BuildScript.kt | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/BuildScript.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/BuildScript.kt index 799964bf..a6db65b3 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/BuildScript.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/BuildScript.kt @@ -74,8 +74,18 @@ data class ProxyConfig(val host: String = "", val port: Int = 0, val type: Strin fun toAetherProxy() = Proxy(type, host, port) // TODO make support for proxy auth } -data class HostConfig(var url: String = "", var name: String, var username: String? = null, - var password: String? = null) { +data class HostConfig(var url: String = "", var name: String = HostConfig.createRepoName(url), + var username: String? = null, var password: String? = null) { + + companion object { + /** + * For repos specified in the build file (repos()) that don't have an associated unique name, + * create such a name from the URL. This is a requirement from Maven Resolver, and failing to do + * this leads to very weird resolution errors. + */ + private fun createRepoName(url: String) = url.replace("/", "_").replace("\\", "_").replace(":", "_") + } + fun hasAuth() : Boolean { return (! username.isNullOrBlank()) && (! password.isNullOrBlank()) } @@ -95,10 +105,8 @@ fun repos(vararg repos : String) { newRepos(*repos) } -fun createRepoName(url: String) = url.replace("/", "_").replace("\\", "_").replace(":", "_") - fun newRepos(vararg repos: String) { - repos.forEach { Kobalt.addRepo(HostConfig(it, createRepoName(it))) } + repos.forEach { Kobalt.addRepo(HostConfig(it)) } } fun buildFileClasspath(vararg deps: String) { From 5720356814d5d4deaec66aa911f57ae1583976af Mon Sep 17 00:00:00 2001 From: Dmitry Zhuravlev Date: Mon, 17 Apr 2017 12:30:12 +0300 Subject: [PATCH 12/33] + added cleanup for buildFileClasspath collection + added FIXME: newBuildFileClasspath called twice --- .../src/main/kotlin/com/beust/kobalt/BuildScript.kt | 1 + .../src/main/kotlin/com/beust/kobalt/api/Kobalt.kt | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/BuildScript.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/BuildScript.kt index a6db65b3..4c35b9ed 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/BuildScript.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/BuildScript.kt @@ -116,6 +116,7 @@ fun buildFileClasspath(vararg deps: String) { } fun newBuildFileClasspath(vararg deps: String) { + //FIXME newBuildFileClasspath called twice deps.forEach { Kobalt.addBuildFileClasspath(it) } } diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/Kobalt.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/Kobalt.kt index 048f5540..7d37a0b8 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/Kobalt.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/Kobalt.kt @@ -72,7 +72,6 @@ class Kobalt { fun addBuildFileClasspath(dep: String) { val dependencyManager = Kobalt.INJECTOR.getInstance(DependencyManager::class.java) - //FIXME buildFileClasspath collection never becomes clear! each synchronization will add the same dependencies to it buildFileClasspath.add(dependencyManager.create(dep)) } @@ -136,6 +135,7 @@ class Kobalt { fun cleanUp() { buildSourceDirs.clear() + buildFileClasspath.clear() } } } From 0938bcc3bffb45ca4029e301711d0f2e80b679bb Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Mon, 17 Apr 2017 08:38:53 -0700 Subject: [PATCH 13/33] GH-413: Duplicate compilation. Fixes https://github.com/cbeust/kobalt/pull/413 --- .../beust/kobalt/app/remote/RemoteDependencyData.kt | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/com/beust/kobalt/app/remote/RemoteDependencyData.kt b/src/main/kotlin/com/beust/kobalt/app/remote/RemoteDependencyData.kt index 3f6a2a31..fcd0a80c 100644 --- a/src/main/kotlin/com/beust/kobalt/app/remote/RemoteDependencyData.kt +++ b/src/main/kotlin/com/beust/kobalt/app/remote/RemoteDependencyData.kt @@ -30,7 +30,7 @@ class RemoteDependencyData @Inject constructor(val executors: KobaltExecutors, v val taskManager: TaskManager) { fun dependenciesDataFor(buildSources: BuildSources, args: Args, - findProjectResult: BuildFileCompiler.FindProjectResult, + projectResult: BuildFileCompiler.FindProjectResult, progressListener: IProgressListener? = null, useGraph : Boolean = false): GetDependenciesData { val projectDatas = arrayListOf() @@ -43,10 +43,6 @@ class RemoteDependencyData @Inject constructor(val executors: KobaltExecutors, v fun allDeps(l: List, name: String) = dependencyManager.transitiveClosure(l, requiredBy = name) -// val buildFile = BuildFile(Paths.get(buildFilePath), "GetDependenciesCommand") - val buildFileCompiler = buildFileCompilerFactory.create(buildSources, pluginInfo) - val projectResult = buildFileCompiler.compileBuildFiles(args) - val buildFileDependencies = Kobalt.buildFileClasspath.map {toDependencyData(it, "compile")} val pluginDependencies = projectResult.pluginUrls.map { File(it.toURI()) }.map { @@ -179,8 +175,8 @@ class RemoteDependencyData @Inject constructor(val executors: KobaltExecutors, v }) } - return GetDependenciesData(projectDatas, allTasks, pluginDependencies, buildFileDependencies, findProjectResult.buildContentRoots, - projectResult.taskResult.errorMessage) + return GetDependenciesData(projectDatas, allTasks, pluginDependencies, buildFileDependencies, + projectResult.buildContentRoots, projectResult.taskResult.errorMessage) } ///// From e11bdfa2b956fff70835c915735adab52d6ca30c Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Mon, 17 Apr 2017 08:40:15 -0700 Subject: [PATCH 14/33] 1.0.67. --- 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 c5750f12..9061376b 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=1.0.66 +kobalt.version=1.0.67 \ No newline at end of file diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index c5750f12..aa4491ae 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=1.0.66 +kobalt.version=1.0.67 From afacd86267932562a6260106b6edea211ba38952 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Mon, 17 Apr 2017 09:27:17 -0700 Subject: [PATCH 15/33] =?UTF-8?q?GH-409:=20Run=20=E2=80=94update=20or=20?= =?UTF-8?q?=E2=80=94server=20even=20if=20the=20build=20file=20is=20incorre?= =?UTF-8?q?ct.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes https://github.com/cbeust/kobalt/issues/409 --- src/main/kotlin/com/beust/kobalt/Options.kt | 55 +++++++++++++++------ 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/src/main/kotlin/com/beust/kobalt/Options.kt b/src/main/kotlin/com/beust/kobalt/Options.kt index 16166e11..47ed91ac 100644 --- a/src/main/kotlin/com/beust/kobalt/Options.kt +++ b/src/main/kotlin/com/beust/kobalt/Options.kt @@ -3,6 +3,7 @@ package com.beust.kobalt import com.beust.jcommander.JCommander import com.beust.kobalt.api.Kobalt import com.beust.kobalt.api.PluginTask +import com.beust.kobalt.api.Project import com.beust.kobalt.app.ProjectFinder import com.beust.kobalt.app.ProjectGenerator import com.beust.kobalt.app.Templates @@ -44,10 +45,26 @@ class Options @Inject constructor( val p = if (args.buildFile != null) File(args.buildFile) else File(".") // val buildFile = BuildFile(Paths.get(p.absolutePath), p.name) val buildSources = if (p.isDirectory) BuildSources(p.absoluteFile) else SingleFileBuildSources(p) - var pluginClassLoader = javaClass.classLoader + val pluginClassLoader = javaClass.classLoader - val allProjectResult = projectFinder.initForBuildFile(buildSources, args) - val allProjects = allProjectResult.projects + // + // Attempt to parse the build file in order to correctly set up repos, plug-ins, etc... + // If the build file can't be parsed, don't give up just yet since some options don't need + // a correct build file to work. + // + var buildError: Throwable? = null + val allProjects = + try { + projectFinder.initForBuildFile(buildSources, args).projects + } catch(ex: Exception) { + buildError = ex + listOf() + } + + fun runIfSuccessfulBuild(buildError: Throwable?, action: () -> Unit) { + buildError?.let { throw it } + action() + } // Modify `args` with options found in buildScript { kobaltOptions(...) }, if any addOptionsFromBuild(args, Kobalt.optionsFromBuild) @@ -77,9 +94,11 @@ class Options @Inject constructor( }), Option( { -> args.projectInfo }, { // --projectInfo - allProjects.forEach { - it.compileDependencies.filter { it.isMaven }.forEach { - resolveDependency.run(it.id) + runIfSuccessfulBuild(buildError) { + allProjects.forEach { + it.compileDependencies.filter { it.isMaven }.forEach { + resolveDependency.run(it.id) + } } } }), @@ -93,7 +112,9 @@ class Options @Inject constructor( }), Option( { args.checkVersions }, { // --checkVersions - checkVersions.run(allProjects) + runIfSuccessfulBuild(buildError) { + checkVersions.run(allProjects) + } }), Option( { args.download }, { // --download @@ -121,17 +142,19 @@ class Options @Inject constructor( if (! buildSources.exists()) { throw KobaltException("Could not find build file: " + buildSources) } - val runTargetResult = taskManager.runTargets(args.targets, allProjects) - if (result == 0) { - result = if (runTargetResult.taskResult.success) 0 else 1 - } + runIfSuccessfulBuild(buildError) { + val runTargetResult = taskManager.runTargets(args.targets, allProjects) + if (result == 0) { + result = if (runTargetResult.taskResult.success) 0 else 1 + } - // Shutdown all plug-ins - plugins.shutdownPlugins() + // Shutdown all plug-ins + plugins.shutdownPlugins() - // Run the build report contributors - pluginInfo.buildReportContributors.forEach { - it.generateReport(Kobalt.context!!) + // Run the build report contributors + pluginInfo.buildReportContributors.forEach { + it.generateReport(Kobalt.context!!) + } } } return result From 9e1c9bd87bcdf4a7f044c927bb8fab200d829b5f Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Mon, 17 Apr 2017 16:27:12 -0700 Subject: [PATCH 16/33] Add support for kapt3. --- .../com/beust/kobalt/plugin/apt/AptPlugin.kt | 164 +++++++++++------- .../kobalt/plugin/kotlin/KotlinCompiler.kt | 83 +++++---- 2 files changed, 151 insertions(+), 96 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 039e22be..8c2873cf 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/apt/AptPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/apt/AptPlugin.kt @@ -3,8 +3,8 @@ package com.beust.kobalt.plugin.apt import com.beust.kobalt.Constants import com.beust.kobalt.TaskResult import com.beust.kobalt.api.* +import com.beust.kobalt.api.annotation.AnnotationDefault import com.beust.kobalt.api.annotation.Directive -import com.beust.kobalt.api.annotation.Task import com.beust.kobalt.homeDir import com.beust.kobalt.internal.CompilerUtils import com.beust.kobalt.maven.DependencyManager @@ -12,6 +12,7 @@ import com.beust.kobalt.maven.aether.Filters import com.beust.kobalt.maven.aether.Scope import com.beust.kobalt.maven.dependency.FileDependency import com.beust.kobalt.misc.KFiles +import com.beust.kobalt.misc.KobaltLogger import com.beust.kobalt.misc.warn import com.beust.kobalt.plugin.kotlin.KotlinPlugin import com.google.common.collect.ArrayListMultimap @@ -21,7 +22,7 @@ import java.util.* import javax.inject.Singleton /** - * The AptPlugin has two components: + * The AptPlugin manages both apt and kapt. Each of them has two components: * 1) A new apt directive inside a dependency{} block (similar to compile()) that declares where * the annotation processor is found * 2) An apt{} configuration on Project that lets the user configure how the annotation is performed @@ -30,13 +31,53 @@ import javax.inject.Singleton @Singleton class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, val kotlinPlugin: KotlinPlugin, val compilerUtils: CompilerUtils) - : BasePlugin(), ICompilerFlagContributor, ISourceDirectoryContributor { + : BasePlugin(), ICompilerFlagContributor, ISourceDirectoryContributor, IClasspathContributor, ITaskContributor { - // ISourceDirectoryContributor + companion object { + const val PLUGIN_NAME = "Apt" + const val KAPT_CONFIG = "kaptConfig" + const val APT_CONFIG = "aptConfig" + } + + override val name = PLUGIN_NAME + + var kaptConfig: KaptConfig? = null + + override fun apply(project: Project, context: KobaltContext) { + super.apply(project, context) + kaptConfig = kaptConfigs[project.name] + + // Delete the output directories + listOf(aptConfigs[project.name]?.outputDir, kaptConfig?.outputDir) + .filterNotNull() + .distinct() + .map { generatedDir(project, it) } + .forEach { + it.normalize().absolutePath.let { path -> + context.logger.log(project.name, 1, " Deleting " + path) + val success = it.deleteRecursively() + if (!success) warn(" Couldn't delete " + path) + } + } + } + + // IClasspathContributor + override fun classpathEntriesFor(project: Project?, context: KobaltContext): Collection { + val result = arrayListOf() + if (project != null && kaptConfig != null) { + kaptConfig?.let { config -> + val c = generatedClasses(project, context, config.outputDir) + File(c).mkdirs() + result.add(FileDependency(c)) + } + } + return result + } private fun generatedDir(project: Project, outputDir: String) : File - = File(KFiles.joinDir(project.directory, KFiles.KOBALT_BUILD_DIR, outputDir)) + = File(KFiles.joinDir(project.directory, KFiles.KOBALT_BUILD_DIR, outputDir)) + // ISourceDirectoryContributor override fun sourceDirectoriesFor(project: Project, context: KobaltContext): List { val result = arrayListOf() aptConfigs[project.name]?.let { config -> @@ -50,29 +91,6 @@ class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, va return result } - companion object { - const val PLUGIN_NAME = "Apt" - const val KAPT_CONFIG = "kaptConfig" - const val APT_CONFIG = "aptConfig" - } - - override val name = PLUGIN_NAME - - override fun apply(project: Project, context: KobaltContext) { - super.apply(project, context) - listOf(aptConfigs[project.name]?.outputDir, aptConfigs[project.name]?.outputDir) - .filterNotNull() - .distinct() - .map { generatedDir(project, it) } - .forEach { - it.normalize().absolutePath.let { path -> - context.logger.log(project.name, 1, " Deleting " + path) - val success = it.deleteRecursively() - if (!success) warn(" Couldn't delete " + path) - } - } - } - private fun generated(project: Project, context: KobaltContext, outputDir: String) = KFiles.joinAndMakeDir(project.directory, project.buildDirectory, outputDir, context.variant.toIntermediateDir()) @@ -84,13 +102,32 @@ class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, va private fun generatedClasses(project: Project, context: KobaltContext, outputDir: String) = KFiles.joinDir(generated(project, context, outputDir), "classes") -// @Task(name = "compileKapt", dependsOn = arrayOf("runKapt"), reverseDependsOn = arrayOf("compile")) + // ITaskContributor + override fun tasksFor(project: Project, context: KobaltContext): List { + val result = + if (kaptConfig != null) { + listOf( + DynamicTask(this, "runKapt", "Run kapt", AnnotationDefault.GROUP, project, + reverseDependsOn = listOf("compile"), runAfter = listOf("clean"), + closure = {p: Project -> taskRunKapt(p)}), + DynamicTask(this, "compileKapt", "Compile the sources generated by kapt", + AnnotationDefault.GROUP, project, + dependsOn = listOf("runKapt"), reverseDependsOn = listOf("compile"), + closure = {p: Project -> taskCompileKapt(p)}) + ) + } else { + emptyList() + } + return result + } + fun taskCompileKapt(project: Project) : TaskResult { + var success = true kaptConfigs[project.name]?.let { config -> val sourceDirs = listOf( generatedStubs(project, context, config.outputDir), generatedSources(project, context, config.outputDir)) - val sourceFiles = KFiles.findSourceFiles(project.directory, sourceDirs, listOf("kt", "java")).toList() + val sourceFiles = KFiles.findSourceFiles(project.directory, sourceDirs, listOf("kt")).toList() val buildDirectory = File(KFiles.joinDir(project.directory, generatedClasses(project, context, config.outputDir))) val flags = listOf() @@ -98,10 +135,10 @@ class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, va buildDirectory, flags, emptyList(), forceRecompile = true) val cr = compilerUtils.invokeCompiler(project, context, kotlinPlugin.compiler, cai) - println("") + success = cr.failedResult == null } - return TaskResult() + return TaskResult(success) } val annotationDependencyId = "org.jetbrains.kotlin:kotlin-annotation-processing:" + @@ -121,31 +158,41 @@ class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, va return allDeps } -// @Task(name = "runKapt", reverseDependsOn = arrayOf("compile"), runAfter = arrayOf("clean")) fun taskRunKapt(project: Project) : TaskResult { + var success = true val flags = arrayListOf() - kaptConfigs[project.name]?.let { config -> + kaptConfig?.let { config -> - fun kaptPluginFlag(flagValue: String): String { - return "plugin:org.jetbrains.kotlin.kapt3:$flagValue" - } val generated = generated(project, context, config.outputDir) - val generatedSources = generatedSources(project, context, config.outputDir) + val generatedSources = generatedSources(project, context, config.outputDir).replace("//", "/") File(generatedSources).mkdirs() + // + // Tell the Kotlin compiler to use the annotation plug-in + // val allDeps = allDependencies() flags.add("-Xplugin") flags.add(annotationProcessorDependency().jarFile.get().absolutePath) flags.add("-P") - val kaptPluginFlags = arrayListOf() -// kaptPluginFlags.add(kaptPluginFlag("aptOnly=true")) - kaptPluginFlags.add(kaptPluginFlag("sources=" + generatedSources)) - kaptPluginFlags.add(kaptPluginFlag("classes=" + generatedClasses(project, context, config.outputDir))) - kaptPluginFlags.add(kaptPluginFlag("stubs=" + generatedStubs(project, context, config.outputDir))) - kaptPluginFlags.add(kaptPluginFlag("verbose=true")) - kaptPluginFlags.add(kaptPluginFlag("aptOnly=false")) + // + // Pass options to the annotation plugin + // + fun kaptPluginFlag(flagValue: String) = "plugin:org.jetbrains.kotlin.kapt3:$flagValue" + val kaptPluginFlags = arrayListOf() + val verbose = KobaltLogger.LOG_LEVEL >= 2 + listOf("sources=" + generatedSources, + "classes=" + generatedClasses(project, context, config.outputDir), + "stubs=" + generatedStubs(project, context, config.outputDir), + "verbose=$verbose", + "aptOnly=true").forEach { + kaptPluginFlags.add(kaptPluginFlag(it)) + } + + // + // Dependencies for the annotation plug-in and the generation + // val dependencies = dependencyManager.calculateDependencies(project, context, Filters.EXCLUDE_OPTIONAL_FILTER, listOf(Scope.COMPILE), @@ -159,35 +206,30 @@ class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, va listOf("-language-version", "1.1", " -api-version", "1.1").forEach { flags.add(it) } - val sourceFiles = -// KFiles.findSourceFiles(project.directory, -// listOf("src/tmp/kotlin"), -// listOf("kt")) -// .toList() - KFiles.findSourceFiles(project.directory, project.sourceDirectories, listOf("kt")).toList() + - generatedSources -// + val sourceFiles = + KFiles.findSourceFiles(project.directory, project.sourceDirectories, listOf("kt")) + .toList() + generatedSources val buildDirectory = File(KFiles.joinDir(project.directory, generated)) val cai = CompilerActionInfo(project.directory, allDeps, sourceFiles, listOf(".kt"), buildDirectory, flags, emptyList(), forceRecompile = true) - println("FLAGS: " + flags.joinToString("\n")) - println(" " + kaptPluginFlags.joinToString("\n ")) + context.logger.log(project.name, 2, " " + kaptPluginFlags.joinToString("\n ")) val cr = compilerUtils.invokeCompiler(project, context, kotlinPlugin.compiler, cai) - println("") + success = cr.failedResult == null } - return TaskResult() + return TaskResult(success) } // ICompilerFlagContributor override fun compilerFlagsFor(project: Project, context: KobaltContext, currentFlags: List, suffixesBeingCompiled: List): List { - if (!suffixesBeingCompiled.contains("java")) return emptyList() - val result = arrayListOf() + // Only run for Java files + if (!suffixesBeingCompiled.contains("java")) return emptyList() + fun addFlags(outputDir: String) { aptDependencies[project.name]?.let { result.add("-s") @@ -199,10 +241,6 @@ class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, va addFlags(config.outputDir) } - kaptConfigs[project.name]?.let { config -> - addFlags(config.outputDir) - } - context.logger.log(project.name, 2, "New flags from apt: " + result.joinToString(" ")) return result } 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 5fa6af71..7d5892b0 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt @@ -44,14 +44,16 @@ class KotlinCompiler @Inject constructor( var filesToCompile = 0 if (! info.outputDir.path.endsWith("ript.jar")) { // Don't display the message if compiling Build.kt - filesToCompile = - info.sourceFiles.map(::File).map { - if (it.isDirectory) KFiles.findRecursively(it).size else 1 - }.reduce { a, b -> - a + b - } - kobaltLog.log(projectName ?: "", 1, - " Kotlin $version compiling " + Strings.pluralizeAll(filesToCompile, "file")) + if (info.sourceFiles.isNotEmpty()) { + filesToCompile = + info.sourceFiles.map(::File).map { + if (it.isDirectory) KFiles.findRecursively(it).size else 1 + }.reduce { a, b -> + a + b + } + kobaltLog.log(projectName ?: "", 1, + " Kotlin $version compiling " + Strings.pluralizeAll(filesToCompile, "file")) + } } val cp = compilerFirst(info.dependencies.map { it.jarFile.get() }) val infoDir = info.directory @@ -135,8 +137,10 @@ class KotlinCompiler @Inject constructor( val friends = info.friendPaths.toTypedArray() // Collect the compiler args from kotlinCompiler{} and from settings.xml and parse them - val args2 = (kotlinConfig(project)?.args ?: arrayListOf()) + - (settings.kobaltCompilerFlags?.split(" ") ?: listOf()) + val args2 = + info.compilerArgs + + (kotlinConfig(project)?.args ?: arrayListOf()) + + (settings.kobaltCompilerFlags?.split(" ") ?: listOf()) val args = K2JVMCompilerArguments() val compiler = K2JVMCompiler() compiler.parseArguments(args2.toTypedArray(), args) @@ -185,13 +189,27 @@ class KotlinCompiler @Inject constructor( fun logk(level: Int, message: CharSequence) = kobaltLog.log(projectName, level, message) - logk(2, " Invoking K2JVMCompiler with arguments:" + fun pluginClasspaths(args: K2JVMCompilerArguments) : String { + var result = "" + args.pluginClasspaths?.forEach { + result += " -Xplugin " + it + } + args.pluginOptions?.let { + result += " -P " + result += it.joinToString(",") + } + return result + } + + logk(2, " Invoking K2JVMCompiler with arguments: kotlinc " + if (args.skipMetadataVersionCheck) " -Xskip-metadata-version-check" else "" - + " -moduleName " + args.moduleName + " -d " + args.destination - + " -friendPaths " + args.friendPaths.joinToString(";") + " -classpath " + args.classpath + + pluginClasspaths(args) + " " + sourceFiles.joinToString(" ")) + logk(2, " Additional kotlinc arguments: " + + " -moduleName " + args.moduleName + + " -friendPaths " + args.friendPaths.joinToString(";")) val collector = object : MessageCollector { override fun clear() { throw UnsupportedOperationException("not implemented") @@ -214,7 +232,6 @@ class KotlinCompiler @Inject constructor( message: String, location: CompilerMessageLocation) { if (severity.isError) { "Couldn't compile file: ${dump(location, message)}".let { fullMessage -> - System.err.println(fullMessage) throw KobaltException(fullMessage) } } else if (severity == CompilerMessageSeverity.WARNING && KobaltLogger.LOG_LEVEL >= 2) { @@ -224,28 +241,28 @@ class KotlinCompiler @Inject constructor( } } } - - System.setProperty("kotlin.incremental.compilation", "true") - // TODO: experimental should be removed as soon as it becomes standard - System.setProperty("kotlin.incremental.compilation.experimental", "true") +// +// System.setProperty("kotlin.incremental.compilation", "true") +// // TODO: experimental should be removed as soon as it becomes standard +// System.setProperty("kotlin.incremental.compilation.experimental", "true") val result = - if (cliArgs.noIncrementalKotlin || Kobalt.context?.internalContext?.noIncrementalKotlin ?: false) { - log(2, " Kotlin incremental compilation is disabled") - val duration = benchmarkMillis { - compiler.exec(collector, Services.Builder().build(), args) + if (cliArgs.noIncrementalKotlin || Kobalt.context?.internalContext?.noIncrementalKotlin ?: false) { + log(2, " Kotlin incremental compilation is disabled") + val duration = benchmarkMillis { + compiler.exec(collector, Services.Builder().build(), args) + } + log(1, " Regular compilation time: ${duration.first} ms") + TaskResult(duration.second == ExitCode.OK) + } else { + log(1, " Kotlin incremental compilation is enabled") + val start = System.currentTimeMillis() + val duration = benchmarkMillis { + compileIncrementally(filesToCompile, sourceFiles, outputDir, info, args, collector) + } + log(1, " Incremental compilation time: ${duration.first} ms") + TaskResult() } - log(1, " Regular compilation time: ${duration.first} ms") - TaskResult(duration.second == ExitCode.OK) - } else { - log(1, " Kotlin incremental compilation is enabled") - val start = System.currentTimeMillis() - val duration = benchmarkMillis { - compileIncrementally(filesToCompile, sourceFiles, outputDir, info, args, collector) - } - log(1, " Incremental compilation time: ${duration.first} ms") - TaskResult() - } return result } From b331672c3de2747d1802f08dbd9f76df5363db6d Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Mon, 17 Apr 2017 16:30:25 -0700 Subject: [PATCH 17/33] Fix nowarn. --- kobalt/src/Build.kt | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/kobalt/src/Build.kt b/kobalt/src/Build.kt index 76c1a7af..99ee7f52 100644 --- a/kobalt/src/Build.kt +++ b/kobalt/src/Build.kt @@ -43,7 +43,6 @@ object Versions { val junitVintageVersion = "$junit.0-M4" } - fun mavenResolver(vararg m: String) = m.map { "org.apache.maven.resolver:maven-resolver-$it:${Versions.mavenResolver}" } .toTypedArray() @@ -140,12 +139,8 @@ val kobaltPluginApi = project { } } -// install { -// libDir = "lib-test" -// } - kotlinCompiler { - args("-nowarn") + args("nowarn") } bintray { @@ -233,7 +228,7 @@ val kobaltApp = project(kobaltPluginApi, wrapper) { } kotlinCompiler { - args("-nowarn") + args("nowarn") } bintray { From 007e616e7f0f417036881edb79151398b6f1edbf Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Mon, 17 Apr 2017 16:43:06 -0700 Subject: [PATCH 18/33] 1.0.68. --- 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 9061376b..2f7d9ede 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=1.0.67 \ No newline at end of file +kobalt.version=1.0.68 \ No newline at end of file diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index aa4491ae..2e0f309a 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=1.0.67 +kobalt.version=1.0.68 From da332b17166dda18c5d77de49c7292a5ad845488 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Mon, 17 Apr 2017 17:46:56 -0700 Subject: [PATCH 19/33] =?UTF-8?q?Don=E2=80=99t=20use=20variants=20for=20ap?= =?UTF-8?q?t.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/com/beust/kobalt/plugin/apt/AptPlugin.kt | 3 +-- 1 file changed, 1 insertion(+), 2 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 8c2873cf..cf50d616 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/apt/AptPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/apt/AptPlugin.kt @@ -92,8 +92,7 @@ class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, va } private fun generated(project: Project, context: KobaltContext, outputDir: String) = - KFiles.joinAndMakeDir(project.directory, project.buildDirectory, outputDir, - context.variant.toIntermediateDir()) + KFiles.joinAndMakeDir(project.directory, project.buildDirectory, outputDir) private fun generatedSources(project: Project, context: KobaltContext, outputDir: String) = KFiles.joinDir(generated(project, context, outputDir), "sources") From fd58ed58e4da3c6b255e28e3c87b406a824bd412 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Mon, 17 Apr 2017 17:47:24 -0700 Subject: [PATCH 20/33] 1.0.69. --- 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 2f7d9ede..5430a86f 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=1.0.68 \ No newline at end of file +kobalt.version=1.0.69 \ No newline at end of file diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index 2e0f309a..eab7d30e 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=1.0.68 +kobalt.version=1.0.69 From dc1ebfb15d114debf824a7677c9ed743ffc0cd4d Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Mon, 17 Apr 2017 18:54:37 -0700 Subject: [PATCH 21/33] =?UTF-8?q?Don=E2=80=99t=20display=20tasks=20if=20th?= =?UTF-8?q?e=20build=20file=20can=E2=80=99t=20be=20compiled.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/com/beust/kobalt/Options.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/com/beust/kobalt/Options.kt b/src/main/kotlin/com/beust/kobalt/Options.kt index 47ed91ac..615b4d64 100644 --- a/src/main/kotlin/com/beust/kobalt/Options.kt +++ b/src/main/kotlin/com/beust/kobalt/Options.kt @@ -108,7 +108,9 @@ class Options @Inject constructor( }), Option( { args.tasks }, { // --tasks - displayTasks() + runIfSuccessfulBuild(buildError) { + displayTasks() + } }), Option( { args.checkVersions }, { // --checkVersions From 37709b571ce90c49c154ca59ccb0ef784e636759 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 18 Apr 2017 08:16:13 -0700 Subject: [PATCH 22/33] Inject the Jvm object. --- .../kotlin/com/beust/kobalt/internal/GenericRunner.kt | 6 +++++- src/main/kotlin/com/beust/kobalt/app/MainModule.kt | 8 +++++--- .../beust/kobalt/plugin/application/ApplicationPlugin.kt | 9 ++++++--- .../kotlin/com/beust/kobalt/plugin/java/JavaCompiler.kt | 9 ++++----- .../com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt | 5 +++-- 5 files changed, 23 insertions(+), 14 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/GenericRunner.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/GenericRunner.kt index 01836be1..27419c02 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/GenericRunner.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/GenericRunner.kt @@ -4,6 +4,7 @@ import com.beust.kobalt.* import com.beust.kobalt.api.* import com.beust.kobalt.misc.KFiles import com.google.common.annotations.VisibleForTesting +import com.google.inject.Inject import java.io.File import java.util.* @@ -19,6 +20,9 @@ abstract class GenericTestRunner: ITestRunnerContributor { open var shortMessage: String? = null open var longMessage: String? = null + @Inject + private lateinit var jvm: Jvm + abstract fun args(project: Project, context: KobaltContext, classpath: List, testConfig: TestConfig) : List @@ -116,7 +120,7 @@ abstract class GenericTestRunner: ITestRunnerContributor { val args = args(project, context, classpath, testConfig) if (args.size > 0) { - val java = JavaInfo.create(File(SystemProperties.javaBase)).javaExecutable + val java = jvm.javaExecutable val jvmArgs = calculateAllJvmArgs(project, context, testConfig, classpath, Kobalt.INJECTOR.getInstance (PluginInfo::class.java)) val allArgs = arrayListOf().apply { diff --git a/src/main/kotlin/com/beust/kobalt/app/MainModule.kt b/src/main/kotlin/com/beust/kobalt/app/MainModule.kt index 8181a3b9..1f9e07b2 100644 --- a/src/main/kotlin/com/beust/kobalt/app/MainModule.kt +++ b/src/main/kotlin/com/beust/kobalt/app/MainModule.kt @@ -1,6 +1,8 @@ package com.beust.kobalt.app import com.beust.kobalt.Args +import com.beust.kobalt.JavaInfo +import com.beust.kobalt.Jvm import com.beust.kobalt.app.remote.KobaltServer import com.beust.kobalt.internal.IncrementalManager import com.beust.kobalt.internal.KobaltSettings @@ -17,6 +19,7 @@ import com.google.inject.Provider import com.google.inject.Singleton import com.google.inject.TypeLiteral import com.google.inject.assistedinject.FactoryModuleBuilder +import java.io.File import java.util.concurrent.ExecutorService open class MainModule(val args: Args, val settings: KobaltSettings) : AbstractModule() { @@ -49,15 +52,14 @@ open class MainModule(val args: Args, val settings: KobaltSettings) : AbstractMo bind(Args::class.java).toProvider(Provider { args }) - EventBus().let { eventBus -> - bind(EventBus::class.java).toInstance(eventBus) - } + bind(EventBus::class.java).toInstance(EventBus()) bind(PluginInfo::class.java).toProvider(Provider { PluginInfo.readKobaltPluginXml() }).`in`(Singleton::class.java) bind(KobaltSettings::class.java).toProvider(Provider { settings }).`in`(Singleton::class.java) + bind(Jvm::class.java).toInstance(JavaInfo.create(File(com.beust.kobalt.SystemProperties.javaBase))) // bindListener(Matchers.any(), object: TypeListener { // override fun hear(typeLiteral: TypeLiteral?, typeEncounter: TypeEncounter?) { 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 032c466d..9fc0b027 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/application/ApplicationPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/application/ApplicationPlugin.kt @@ -1,6 +1,9 @@ package com.beust.kobalt.plugin.application -import com.beust.kobalt.* +import com.beust.kobalt.Jvm +import com.beust.kobalt.KobaltException +import com.beust.kobalt.Plugins +import com.beust.kobalt.TaskResult import com.beust.kobalt.api.* import com.beust.kobalt.api.annotation.Directive import com.beust.kobalt.api.annotation.Task @@ -42,7 +45,7 @@ fun Project.application(init: ApplicationConfig.() -> Unit): ApplicationConfig { @Singleton class ApplicationPlugin @Inject constructor(val configActor: ConfigActor, val executors: KobaltExecutors, val nativeManager: NativeManager, - val dependencyManager: DependencyManager, val taskContributor : TaskContributor) + val dependencyManager: DependencyManager, val taskContributor : TaskContributor, val jvm: Jvm) : BasePlugin(), IRunnerContributor, ITaskContributor, IConfigActor by configActor { companion object { @@ -111,7 +114,7 @@ class ApplicationPlugin @Inject constructor(val configActor: ConfigActor val allDeps = arrayListOf(jarName) - val java = JavaInfo.create(File(SystemProperties.javaBase)).javaExecutable!! + val java = jvm.javaExecutable!! if (! isFatJar(packages, jarName)) { @Suppress("UNCHECKED_CAST") // If the jar file is not fat, we need to add the transitive closure of all dependencies diff --git a/src/main/kotlin/com/beust/kobalt/plugin/java/JavaCompiler.kt b/src/main/kotlin/com/beust/kobalt/plugin/java/JavaCompiler.kt index 97d7644b..1044adf5 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/java/JavaCompiler.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/java/JavaCompiler.kt @@ -1,7 +1,6 @@ package com.beust.kobalt.plugin.java -import com.beust.kobalt.JavaInfo -import com.beust.kobalt.SystemProperties +import com.beust.kobalt.Jvm import com.beust.kobalt.TaskResult import com.beust.kobalt.api.* import com.beust.kobalt.internal.CompilerUtils @@ -22,7 +21,7 @@ import javax.tools.ToolProvider @Singleton class JavaCompiler @Inject constructor(val jvmCompiler: JvmCompiler, val kobaltLog: ParallelLogger, - val compilerUtils: CompilerUtils) : ICompiler { + val compilerUtils: CompilerUtils, val jvm: Jvm) : ICompiler { fun compilerAction(executable: File) = object : ICompilerAction { override fun compile(project: Project?, info: CompilerActionInfo): TaskResult { val projectName = project?.name @@ -119,7 +118,7 @@ class JavaCompiler @Inject constructor(val jvmCompiler: JvmCompiler, val kobaltL -> it.compilerFlagsFor(project, context, currentFlags, suffixesBeingCompiled) } FlagContributor(it.flagPriority, closure) } - return run(project, context, info, JavaInfo.create(File(SystemProperties.javaBase)).javacExecutable!!, + return run(project, context, info, jvm.javacExecutable!!, compilerUtils.compilerFlags(project, context, info, adapters)) } @@ -130,7 +129,7 @@ class JavaCompiler @Inject constructor(val jvmCompiler: JvmCompiler, val kobaltL -> it.docFlagsFor(project, context, currentFlags, suffixesBeingCompiled) } FlagContributor(it.flagPriority, closure) } - return run(project, context, info, JavaInfo.create(File(SystemProperties.javaBase)).javadocExecutable!!, + return run(project, context, info, jvm.javadocExecutable!!, compilerUtils.compilerFlags(project, context, info, adapters)) } } 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 7d5892b0..33b26ec6 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt @@ -35,7 +35,8 @@ class KotlinCompiler @Inject constructor( val settings: KobaltSettings, val jvmCompiler: JvmCompiler, val compilerUtils: CompilerUtils, - val kobaltLog: ParallelLogger) { + val kobaltLog: ParallelLogger, + val jvm: Jvm) { val compilerAction = object: ICompilerAction { override fun compile(project: Project?, info: CompilerActionInfo): TaskResult { @@ -99,7 +100,7 @@ class KotlinCompiler @Inject constructor( private fun invokeCompilerInSeparateProcess(classpath: String, info: CompilerActionInfo, compilerVersion: String, project: Project?): TaskResult { - val java = JavaInfo.create(File(SystemProperties.javaBase)).javaExecutable + val java = jvm.javaExecutable val compilerClasspath = compilerDep(compilerVersion).jarFile.get().path + File.pathSeparator + compilerEmbeddableDependencies(null, compilerVersion).map { it.jarFile.get().path } From 104e71335e4f06e0d7e2ac51389db45506dbfb07 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 18 Apr 2017 08:36:17 -0700 Subject: [PATCH 23/33] Read the apt() dependency correctly. --- .../com/beust/kobalt/plugin/apt/AptPlugin.kt | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 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 cf50d616..1cb2003a 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/apt/AptPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/apt/AptPlugin.kt @@ -1,11 +1,11 @@ package com.beust.kobalt.plugin.apt import com.beust.kobalt.Constants +import com.beust.kobalt.Jvm import com.beust.kobalt.TaskResult import com.beust.kobalt.api.* import com.beust.kobalt.api.annotation.AnnotationDefault import com.beust.kobalt.api.annotation.Directive -import com.beust.kobalt.homeDir import com.beust.kobalt.internal.CompilerUtils import com.beust.kobalt.maven.DependencyManager import com.beust.kobalt.maven.aether.Filters @@ -30,7 +30,7 @@ import javax.inject.Singleton */ @Singleton class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, val kotlinPlugin: KotlinPlugin, - val compilerUtils: CompilerUtils) + val compilerUtils: CompilerUtils, val jvm: Jvm) : BasePlugin(), ICompilerFlagContributor, ISourceDirectoryContributor, IClasspathContributor, ITaskContributor { companion object { @@ -130,7 +130,7 @@ class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, va val buildDirectory = File(KFiles.joinDir(project.directory, generatedClasses(project, context, config.outputDir))) val flags = listOf() - val cai = CompilerActionInfo(project.directory, allDependencies(), sourceFiles, listOf(".kt"), + val cai = CompilerActionInfo(project.directory, allDependencies(project), sourceFiles, listOf(".kt"), buildDirectory, flags, emptyList(), forceRecompile = true) val cr = compilerUtils.invokeCompiler(project, context, kotlinPlugin.compiler, cai) @@ -145,14 +145,16 @@ class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, va fun annotationProcessorDependency() = dependencyManager.create(annotationDependencyId) - fun aptJarDependencies() : List { - val apDep = dependencyManager.create("net.thauvin.erik.:semver:0.9.6-beta") - val apDep2 = FileDependency(homeDir("t/semver-example-kotlin/lib/semver-0.9.7.jar")) - return listOf(apDep2) - } + fun aptJarDependencies(project: Project) = aptDependencies[project.name].map { dependencyManager.create(it) } - fun allDependencies(): List { - val allDeps = listOf(annotationProcessorDependency()) + aptJarDependencies() + fun allDependencies(project: Project): List { + val allDeps = arrayListOf() + allDeps.add(annotationProcessorDependency()) + allDeps.addAll(aptJarDependencies(project)) + +// jvm.toolsJar?.let { toolsJar -> +// allDeps.add(FileDependency(toolsJar.absolutePath)) +// } return allDeps } @@ -170,7 +172,7 @@ class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, va // // Tell the Kotlin compiler to use the annotation plug-in // - val allDeps = allDependencies() + val allDeps = allDependencies(project) flags.add("-Xplugin") flags.add(annotationProcessorDependency().jarFile.get().absolutePath) flags.add("-P") From 5d03544e31785001f7a53dba1117878a8f716de2 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 18 Apr 2017 20:01:43 -0700 Subject: [PATCH 24/33] =?UTF-8?q?GH-417:=20Don=E2=80=99t=20run=20abstract?= =?UTF-8?q?=20test=20classes=20with=20JUnit=204.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes https://github.com/cbeust/kobalt/issues/417 --- .../com/beust/kobalt/internal/GenericRunner.kt | 4 ++-- .../com/beust/kobalt/internal/JUnitRunner.kt | 14 ++++++++++++++ .../com/beust/kobalt/internal/KotlinTestRunner.kt | 6 +++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/GenericRunner.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/GenericRunner.kt index 27419c02..fb2b0927 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/GenericRunner.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/GenericRunner.kt @@ -30,7 +30,7 @@ abstract class GenericTestRunner: ITestRunnerContributor { open val extraClasspath: List = emptyList() - open fun filterTestClasses(classes: List) : List = classes + open fun filterTestClasses(project: Project, context: KobaltContext, classes: List) : List = classes override fun run(project: Project, context: KobaltContext, configName: String, classpath: List) : TaskResult { @@ -69,7 +69,7 @@ abstract class GenericTestRunner: ITestRunnerContributor { // } context.logger.log(project.name, 2, "Found ${result.size} test classes") - return filterTestClasses(result.map { it.second }) + return filterTestClasses(project, context, result.map { it.second }) } /** diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JUnitRunner.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JUnitRunner.kt index bfe6d800..c5b36997 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JUnitRunner.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JUnitRunner.kt @@ -4,6 +4,10 @@ import com.beust.kobalt.TestConfig import com.beust.kobalt.api.IClasspathDependency import com.beust.kobalt.api.KobaltContext import com.beust.kobalt.api.Project +import com.beust.kobalt.maven.DependencyManager +import com.google.inject.Inject +import java.lang.reflect.Modifier +import java.net.URLClassLoader open class JUnitRunner() : GenericTestRunner() { @@ -14,5 +18,15 @@ open class JUnitRunner() : GenericTestRunner() { override fun args(project: Project, context: KobaltContext, classpath: List, testConfig: TestConfig) = findTestClasses(project, context, testConfig) + + @Inject + lateinit var dependencyManager: DependencyManager + + override fun filterTestClasses(project: Project, context: KobaltContext, classes: List) : List { + val deps = dependencyManager.testDependencies(project, context) + val cl = URLClassLoader(deps.map { it.jarFile.get().toURI().toURL() }.toTypedArray()) + return classes.filter { !Modifier.isAbstract(cl.loadClass(it).modifiers) } + } + } diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/KotlinTestRunner.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/KotlinTestRunner.kt index b78da1db..24e643d5 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/KotlinTestRunner.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/KotlinTestRunner.kt @@ -1,5 +1,8 @@ package com.beust.kobalt.internal +import com.beust.kobalt.api.KobaltContext +import com.beust.kobalt.api.Project + /** * KotlinTestRunner triggers if it finds a dependency on io.kotlintest but other than that, it just * uses the regular JUnitRunner. @@ -12,6 +15,7 @@ class KotlinTestRunner : JUnitRunner() { * KotlinTestRunner runs tests in the init{} initializer, so ignore all the extra * classes generated by the Kotlin compiler. */ - override fun filterTestClasses(classes: List) = classes.filter { ! it.contains("$") } + override fun filterTestClasses(projet: Project, context: KobaltContext, classes: List) + = classes.filter { !it.contains("$") } } From 3686c4e110d25f079593f94ce9466c350f18e70a Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 18 Apr 2017 20:02:08 -0700 Subject: [PATCH 25/33] 1.0.70. --- 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 5430a86f..33b30c75 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=1.0.69 \ No newline at end of file +kobalt.version=1.0.70 \ No newline at end of file diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index eab7d30e..c6aad52c 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=1.0.69 +kobalt.version=1.0.70 From 1febd473686d8a8cc82f99f30bef0dba54fb1bf5 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Wed, 19 Apr 2017 08:19:46 -0700 Subject: [PATCH 26/33] Better JAVA_HOME detection. --- .../src/main/kotlin/com/beust/kobalt/SystemProperties.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/SystemProperties.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/SystemProperties.kt index b003aa9f..898f0594 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/SystemProperties.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/SystemProperties.kt @@ -2,8 +2,10 @@ package com.beust.kobalt class SystemProperties { companion object { - val javaBase = System.getProperty("java.home") ?: - (System.getenv("JAVA_HOME") ?: throw IllegalArgumentException("JAVA_HOME not defined")) + val javaBase = + System.getenv("JAVA_HOME") + ?: System.getProperty("java.home") + ?: throw IllegalArgumentException("JAVA_HOME not defined") val javaVersion = System.getProperty("java.version") val homeDir = System.getProperty("user.home") val tmpDir = System.getProperty("java.io.tmpdir") From 35fe4f6494ccae205c4c1167b3b66381e33cb323 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Wed, 19 Apr 2017 08:20:02 -0700 Subject: [PATCH 27/33] Add tools.jar on the annotation plug-in classpath. --- .../kotlin/com/beust/kobalt/plugin/apt/AptPlugin.kt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 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 1cb2003a..71d9e388 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/apt/AptPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/apt/AptPlugin.kt @@ -151,11 +151,6 @@ class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, va val allDeps = arrayListOf() allDeps.add(annotationProcessorDependency()) allDeps.addAll(aptJarDependencies(project)) - -// jvm.toolsJar?.let { toolsJar -> -// allDeps.add(FileDependency(toolsJar.absolutePath)) -// } - return allDeps } @@ -175,11 +170,17 @@ class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, va val allDeps = allDependencies(project) flags.add("-Xplugin") flags.add(annotationProcessorDependency().jarFile.get().absolutePath) - flags.add("-P") + + // Also need tools.jar on the plug-in classpath + jvm.toolsJar?.let { toolsJar -> + flags.add("-Xplugin") + flags.add(toolsJar.absolutePath) + } // // Pass options to the annotation plugin // + flags.add("-P") fun kaptPluginFlag(flagValue: String) = "plugin:org.jetbrains.kotlin.kapt3:$flagValue" val kaptPluginFlags = arrayListOf() val verbose = KobaltLogger.LOG_LEVEL >= 2 From abc90022921bd4593d282eda1fe9f1038db54f08 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Wed, 19 Apr 2017 08:29:01 -0700 Subject: [PATCH 28/33] 1.0.71. --- 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 33b30c75..9709019c 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=1.0.70 \ No newline at end of file +kobalt.version=1.0.71 \ No newline at end of file diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index c6aad52c..3bb86711 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=1.0.70 +kobalt.version=1.0.71 From 5bcb8185b8313a6bd3815f9fd0e4dc2455011802 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Wed, 19 Apr 2017 11:14:34 -0700 Subject: [PATCH 29/33] Refactor. --- .../src/main/kotlin/com/beust/kobalt/misc/NewRunCommand.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/NewRunCommand.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/NewRunCommand.kt index 67b666a6..243090ee 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/NewRunCommand.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/NewRunCommand.kt @@ -105,10 +105,10 @@ open class NewRunCommand(val info: RunCommandInfo) { open protected fun isSuccess(isSuccess: Boolean, input: List, error: List) : Boolean { var hasErrors = ! isSuccess if (info.useErrorStreamAsErrorIndicator && ! hasErrors) { - hasErrors = hasErrors || error.size > 0 + hasErrors = hasErrors || error.isNotEmpty() } if (info.useInputStreamAsErrorIndicator && ! hasErrors) { - hasErrors = hasErrors || input.size > 0 + hasErrors = hasErrors || input.isNotEmpty() } return ! hasErrors From 43844cbf80d0387e87e23cfb6d0d149306065b01 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Wed, 19 Apr 2017 11:16:05 -0700 Subject: [PATCH 30/33] Fix class path look up in kapt3. --- .../beust/kobalt/api/CompilerActionInfo.kt | 3 ++- .../com/beust/kobalt/misc/NewRunCommand.kt | 10 +++++---- .../com/beust/kobalt/plugin/apt/AptPlugin.kt | 14 ++++++++---- .../kobalt/plugin/kotlin/KotlinCompiler.kt | 22 +++++++++++++------ .../kobalt/plugin/kotlin/KotlinPlugin.kt | 1 + 5 files changed, 34 insertions(+), 16 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/CompilerActionInfo.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/CompilerActionInfo.kt index d2521255..e323e474 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/CompilerActionInfo.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/CompilerActionInfo.kt @@ -12,4 +12,5 @@ data class CompilerActionInfo(val directory: String?, val outputDir: File, val compilerArgs: List, val friendPaths: List, - val forceRecompile: Boolean) + val forceRecompile: Boolean, + val compilerSeparateProcess: Boolean = false) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/NewRunCommand.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/NewRunCommand.kt index 243090ee..7188cf10 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/NewRunCommand.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/NewRunCommand.kt @@ -79,10 +79,12 @@ open class NewRunCommand(val info: RunCommandInfo) { // Run the command and collect the return code and streams val returnCode = process.waitFor(30, TimeUnit.SECONDS) - val input = if (process.inputStream.available() > 0) fromStream(process.inputStream) - else listOf() - val error = if (process.errorStream.available() > 0) fromStream(process.errorStream) - else listOf() + val input = + if (process.inputStream.available() > 0) fromStream(process.inputStream) + else listOf() + val error = + if (process.errorStream.available() > 0) fromStream(process.errorStream) + else listOf() // Check to see if the command succeeded val isSuccess = 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 71d9e388..ed743b0f 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/apt/AptPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/apt/AptPlugin.kt @@ -131,7 +131,7 @@ class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, va generatedClasses(project, context, config.outputDir))) val flags = listOf() val cai = CompilerActionInfo(project.directory, allDependencies(project), sourceFiles, listOf(".kt"), - buildDirectory, flags, emptyList(), forceRecompile = true) + buildDirectory, flags, emptyList(), forceRecompile = true, compilerSeparateProcess = true) val cr = compilerUtils.invokeCompiler(project, context, kotlinPlugin.compiler, cai) success = cr.failedResult == null @@ -151,6 +151,7 @@ class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, va val allDeps = arrayListOf() allDeps.add(annotationProcessorDependency()) allDeps.addAll(aptJarDependencies(project)) + return allDeps } @@ -177,6 +178,11 @@ class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, va flags.add(toolsJar.absolutePath) } + aptJarDependencies(project).forEach { + flags.add("-Xplugin") + flags.add(it.jarFile.get().absolutePath) + } + // // Pass options to the annotation plugin // @@ -200,12 +206,12 @@ class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, va listOf(Scope.COMPILE), allDeps) dependencies.forEach { - val jarFile = it.jarFile.get() + val jarFile = it.jarFile.get().absolutePath kaptPluginFlags.add(kaptPluginFlag("apclasspath=$jarFile")) } flags.add(kaptPluginFlags.joinToString(",")) - listOf("-language-version", "1.1", " -api-version", "1.1").forEach { + listOf("-language-version", "1.1", "-api-version", "1.1").forEach { flags.add(it) } @@ -214,7 +220,7 @@ class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, va .toList() + generatedSources val buildDirectory = File(KFiles.joinDir(project.directory, generated)) val cai = CompilerActionInfo(project.directory, allDeps, sourceFiles, listOf(".kt"), - buildDirectory, flags, emptyList(), forceRecompile = true) + buildDirectory, flags, emptyList(), forceRecompile = true, compilerSeparateProcess = true) context.logger.log(project.name, 2, " " + kaptPluginFlags.joinToString("\n ")) val cr = compilerUtils.invokeCompiler(project, context, kotlinPlugin.compiler, cai) 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 33b26ec6..d8a1d153 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt @@ -89,7 +89,8 @@ class KotlinCompiler @Inject constructor( // the K2JVMCompiler class directly val actualVersion = kotlinVersion(project) - if (settings.kobaltCompilerSeparateProcess || actualVersion != Constants.KOTLIN_COMPILER_VERSION) { + if (settings.kobaltCompilerSeparateProcess || actualVersion != Constants.KOTLIN_COMPILER_VERSION + || info.compilerSeparateProcess) { return invokeCompilerInSeparateProcess(classpath, info, actualVersion, project) } else { @@ -114,20 +115,24 @@ class KotlinCompiler @Inject constructor( val newArgs = listOf( "-classpath", compilerClasspath, K2JVMCompiler::class.java.name, + *info.compilerArgs.toTypedArray(), "-classpath", classpath, "-d", info.outputDir.absolutePath, *xFlagsArray, *info.sourceFiles.toTypedArray()) .filter { ! it.isEmpty() } - log(2, " Invoking separate kotlinc:\n " + java!!.absolutePath + " " + newArgs.joinToString()) + log(2, " Invoking separate kotlinc:\n " + java!!.absolutePath + " " + newArgs.joinToString(" ")) val result = NewRunCommand(RunCommandInfo().apply { command = java.absolutePath args = newArgs directory = File(".") - // The Kotlin compiler issues warnings on stderr :-( - containsErrors = { errors: List -> errors.any { it.contains("rror")} } +// // The Kotlin compiler issues warnings on stderr :-( + useErrorStreamAsErrorIndicator = false +// containsErrors = { +// errors: List -> errors.any { it.contains("rror")} +// } }).invoke() return TaskResult(result == 0, errorMessage = "Error while compiling") } @@ -388,7 +393,8 @@ class KotlinCompiler @Inject constructor( * JvmCompilerPlugin#createCompilerActionInfo instead */ fun compile(project: Project?, context: KobaltContext?, compileDependencies: List, - otherClasspath: List, sourceFiles: List, outputDir: File, args: List) : TaskResult { + otherClasspath: List, sourceFiles: List, outputDir: File, args: List, + compilerSeparateProcess: Boolean) : TaskResult { val executor = executors.newExecutor("KotlinCompiler", 10) @@ -414,7 +420,7 @@ class KotlinCompiler @Inject constructor( emptyList() } val info = CompilerActionInfo(project?.directory, dependencies, sourceFiles, listOf("kt"), outputDir, args, - friendPaths, context?.internalContext?.forceRecompile ?: false) + friendPaths, context?.internalContext?.forceRecompile ?: false, compilerSeparateProcess) return jvmCompiler.doCompile(project, context, compilerAction, info, if (context != null) compilerUtils.sourceCompilerFlags(project, context, info) else emptyList()) @@ -428,6 +434,7 @@ class KConfiguration @Inject constructor(val compiler: KotlinCompiler){ var output: File by Delegates.notNull() val args = arrayListOf() var noIncrementalKotlin = false + var compilerSeparateProcess = false fun sourceFiles(s: String) = source.add(s) @@ -442,7 +449,8 @@ class KConfiguration @Inject constructor(val compiler: KotlinCompiler){ fun compile(project: Project? = null, context: KobaltContext? = null) : TaskResult { val saved = context?.internalContext?.noIncrementalKotlin ?: false if (context != null) context.internalContext.noIncrementalKotlin = noIncrementalKotlin - val result = compiler.compile(project, context, dependencies, classpath, source, output, args) + val result = compiler.compile(project, context, dependencies, classpath, source, output, args, + compilerSeparateProcess) if (context != null) context.internalContext.noIncrementalKotlin = saved return result } 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 220be8a7..3c437628 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinPlugin.kt @@ -83,6 +83,7 @@ class KotlinPlugin @Inject constructor(val executors: KobaltExecutors, val depen sourceFiles(info.sourceFiles) compilerArgs(info.compilerArgs) output = info.outputDir + compilerSeparateProcess = info.compilerSeparateProcess }.compile(project, context) } From 1d015a6f93e76d635fd43a7f394fd0a28f23e65f Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Wed, 19 Apr 2017 11:16:28 -0700 Subject: [PATCH 31/33] 1.0.72. --- 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 9709019c..842b3300 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=1.0.71 \ No newline at end of file +kobalt.version=1.0.72 \ No newline at end of file diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index 3bb86711..4436f17d 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=1.0.71 +kobalt.version=1.0.72 From e1c1da55c6fb9add9e130ee21ad7e43b869bb461 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 20 Apr 2017 11:17:23 -0700 Subject: [PATCH 32/33] Fix duplication of parameters. --- src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt | 1 - 1 file changed, 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 d8a1d153..b14244c3 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt @@ -145,7 +145,6 @@ class KotlinCompiler @Inject constructor( // Collect the compiler args from kotlinCompiler{} and from settings.xml and parse them val args2 = info.compilerArgs + - (kotlinConfig(project)?.args ?: arrayListOf()) + (settings.kobaltCompilerFlags?.split(" ") ?: listOf()) val args = K2JVMCompilerArguments() val compiler = K2JVMCompiler() From 1342428eb0b19d5ec52f3a977497a80b1c0751ca Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 20 Apr 2017 11:17:28 -0700 Subject: [PATCH 33/33] Reformat. --- .../kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 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 b14244c3..93ad5601 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt @@ -421,8 +421,10 @@ class KotlinCompiler @Inject constructor( val info = CompilerActionInfo(project?.directory, dependencies, sourceFiles, listOf("kt"), outputDir, args, friendPaths, context?.internalContext?.forceRecompile ?: false, compilerSeparateProcess) - return jvmCompiler.doCompile(project, context, compilerAction, info, - if (context != null) compilerUtils.sourceCompilerFlags(project, context, info) else emptyList()) + val compilerFlags = + if (context != null) compilerUtils.sourceCompilerFlags(project, context, info) + else emptyList() + return jvmCompiler.doCompile(project, context, compilerAction, info, compilerFlags) } }