From 2d3740849374a18c63059b3e0f7b2b088cb57d29 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 20 Oct 2015 00:49:26 -0700 Subject: [PATCH 1/7] Clean up. --- src/main/kotlin/com/beust/kobalt/Main.kt | 46 ++++++++++++------------ 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/src/main/kotlin/com/beust/kobalt/Main.kt b/src/main/kotlin/com/beust/kobalt/Main.kt index cfe9ac4b..93dae213 100644 --- a/src/main/kotlin/com/beust/kobalt/Main.kt +++ b/src/main/kotlin/com/beust/kobalt/Main.kt @@ -77,30 +77,28 @@ private class Main @Inject constructor( return result } - public class Worker(val runNodes: ArrayList, val n: T) : IWorker { - override val priority = 0 - - override fun call() : TaskResult2 { - log(2, "Running node ${n}") - runNodes.add(n) - return TaskResult2(n != 3, n) - } - } - - private fun runTest() { - with(Topological()) { - addEdge("b1", "a1") - addEdge("b1", "a2") - addEdge("b2", "a1") - addEdge("b2", "a2") - addEdge("c1", "b1") - addEdge("c1", "b2") - val sorted = sort(arrayListOf("a1", "a2", "b1", "b2", "c1", "x", "y")) - println("Sorted: ${sorted}") - } - } - - private val SCRIPT_JAR = "buildScript.jar" +// public class Worker(val runNodes: ArrayList, val n: T) : IWorker { +// override val priority = 0 +// +// override fun call() : TaskResult2 { +// log(2, "Running node $n") +// runNodes.add(n) +// return TaskResult2(n != 3, n) +// } +// } +// +// private fun runTest() { +// with(Topological()) { +// addEdge("b1", "a1") +// addEdge("b1", "a2") +// addEdge("b2", "a1") +// addEdge("b2", "a2") +// addEdge("c1", "b1") +// addEdge("c1", "b2") +// val sorted = sort(arrayListOf("a1", "a2", "b1", "b2", "c1", "x", "y")) +// println("Sorted: $sorted") +// } +// } private fun runWithArgs(jc: JCommander, args: Args) : Int { var result = 0 From 04762f153d3a03b9f8228e0336d9955756734e59 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 20 Oct 2015 00:52:51 -0700 Subject: [PATCH 2/7] File adjustment. --- .../kotlin/com/beust/kobalt/misc/KFiles.kt | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/com/beust/kobalt/misc/KFiles.kt b/src/main/kotlin/com/beust/kobalt/misc/KFiles.kt index c6531d86..49d4d077 100644 --- a/src/main/kotlin/com/beust/kobalt/misc/KFiles.kt +++ b/src/main/kotlin/com/beust/kobalt/misc/KFiles.kt @@ -13,19 +13,21 @@ import java.nio.file.StandardCopyOption public class KFiles { val kobaltJar : String get() { - val jar = joinDir(distributionsDir, Kobalt.version, "kobalt/wrapper/kobalt-" + Kobalt.version + ".jar") - val jarFile = File(jar) val envJar = System.getenv("KOBALT_JAR") - if (! jarFile.exists() && envJar != null) { + if (envJar != null) { debug("Using kobalt jar $envJar") return File(envJar).absolutePath - } - if (! jarFile.exists()) { - // Will only happen when building kobalt itself: the jar file might not be in the dist/ directory - // yet since we're currently building it. Instead, use the classes directly - return File(joinDir("build", "classes", "main")).absolutePath } else { - return jar + val jar = joinDir(distributionsDir, Kobalt.version, "kobalt/wrapper/kobalt-" + Kobalt.version + ".jar") + val jarFile = File(jar) + if (! jarFile.exists()) { + return jarFile.absolutePath + } else { + // Will only happen when building kobalt itself: the jar file might not be in the dist/ directory + // yet since we're currently building it. Instead, use the classes directly + debug("Couldn't find a kobalt.jar file, using build/classes/main") + return java.io.File(joinDir("build", "classes", "main")).absolutePath + } } } From 5b83dc4b889a460309ccfde455bec5dd37fc2c15 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 20 Oct 2015 01:55:28 -0700 Subject: [PATCH 3/7] Client/server work. --- build.gradle | 3 +- kobalt.iml | 1 + kobalt/src/Build.kt | 3 +- src/main/kotlin/com/beust/kobalt/Args.kt | 13 +++++ src/main/kotlin/com/beust/kobalt/Main.kt | 20 ++++++- .../com/beust/kobalt/internal/KobaltClient.kt | 52 +++++++++++++++++++ .../com/beust/kobalt/internal/KobaltServer.kt | 50 ++++++++++++++++++ .../beust/kobalt/kotlin/ScriptCompiler2.kt | 15 ++++-- 8 files changed, 148 insertions(+), 9 deletions(-) create mode 100644 src/main/kotlin/com/beust/kobalt/internal/KobaltClient.kt create mode 100644 src/main/kotlin/com/beust/kobalt/internal/KobaltServer.kt diff --git a/build.gradle b/build.gradle index d2a5a212..928554da 100644 --- a/build.gradle +++ b/build.gradle @@ -48,7 +48,8 @@ dependencies { 'com.google.inject.extensions:guice-assistedinject:4.0', 'com.google.guava:guava:18.0', 'org.apache.maven:maven-model:3.3.3', - 'com.github.spullara.mustache.java:compiler:0.8.18' + 'com.github.spullara.mustache.java:compiler:0.8.18', + "io.reactivex:rxjava:1.0.14" // compile files("/Users/beust/.kobalt/repository/com/beust/kobalt-example-plugin/build/libs/kobalt-example-plugin.jar") testCompile 'org.testng:testng:6.9.6' diff --git a/kobalt.iml b/kobalt.iml index 99f9efd0..bf0ac307 100644 --- a/kobalt.iml +++ b/kobalt.iml @@ -40,5 +40,6 @@ + \ No newline at end of file diff --git a/kobalt/src/Build.kt b/kobalt/src/Build.kt index 84bfe947..71dd7370 100644 --- a/kobalt/src/Build.kt +++ b/kobalt/src/Build.kt @@ -66,7 +66,8 @@ val kobalt = kotlinProject(wrapper) { "com.google.inject.extensions:guice-assistedinject:4.0", "com.google.guava:guava:19.0-rc2", "org.apache.maven:maven-model:3.3.3", - "com.github.spullara.mustache.java:compiler:0.9.1" + "com.github.spullara.mustache.java:compiler:0.9.1", + "io.reactivex:rxjava:1.0.14" ) } } diff --git a/src/main/kotlin/com/beust/kobalt/Args.kt b/src/main/kotlin/com/beust/kobalt/Args.kt index 697aa83a..7bb16a29 100644 --- a/src/main/kotlin/com/beust/kobalt/Args.kt +++ b/src/main/kotlin/com/beust/kobalt/Args.kt @@ -13,6 +13,9 @@ class Args { "dependencies") var checkVersions = false + @Parameter(names = arrayOf("--client")) + var client: Boolean = false + @Parameter(names = arrayOf("--dev"), description = "Turn of dev mode, resulting in a more verbose log output") var dev: Boolean = false @@ -29,6 +32,16 @@ class Args { @Parameter(names = arrayOf("--log"), description = "Define the log level (1-3)") var log: Int = 1 + companion object { + const val DEFAULT_SERVER_PORT = 3867 + } + + @Parameter(names = arrayOf("--port"), description = "Port, if --server was specified") + var port: Int = DEFAULT_SERVER_PORT + + @Parameter(names = arrayOf("--server"), description = "Run in server mode") + var serverMode: Boolean = false + @Parameter(names = arrayOf("--tasks"), description = "Display the tasks available for this build") var tasks: Boolean = false diff --git a/src/main/kotlin/com/beust/kobalt/Main.kt b/src/main/kotlin/com/beust/kobalt/Main.kt index 93dae213..8117e284 100644 --- a/src/main/kotlin/com/beust/kobalt/Main.kt +++ b/src/main/kotlin/com/beust/kobalt/Main.kt @@ -47,11 +47,19 @@ private class Main @Inject constructor( val depFactory: DepFactory, val checkVersions: CheckVersions, val github: GithubApi, - val updateKobalt: UpdateKobalt) { + val updateKobalt: UpdateKobalt, + val client: KobaltClient, + val server: KobaltServer) { data class RunInfo(val jc: JCommander, val args: Args) public fun run(jc: JCommander, args: Args) : Int { + + if (args.client) { + client.run() + return 0 + } + var result = 0 val latestVersionFuture = github.latestKobaltVersion benchmark("Build", { @@ -120,7 +128,15 @@ private class Main @Inject constructor( } else { val context = KobaltContext(args) Kobalt.context = context - val allProjects = script2.create(arrayListOf(buildFile)).findProjects() + val scriptCompiler = script2.create(arrayListOf(buildFile)) + + if (args.serverMode) { + scriptCompiler.observable.subscribe { + info -> server.sendInfo(info) + } + executors.miscExecutor.submit(server) + } + val allProjects = scriptCompiler.findProjects() // // Force each project.directory to be an absolute path, if it's not already diff --git a/src/main/kotlin/com/beust/kobalt/internal/KobaltClient.kt b/src/main/kotlin/com/beust/kobalt/internal/KobaltClient.kt new file mode 100644 index 00000000..58d9286e --- /dev/null +++ b/src/main/kotlin/com/beust/kobalt/internal/KobaltClient.kt @@ -0,0 +1,52 @@ +package com.beust.kobalt.internal + +import com.beust.kobalt.Args +import com.beust.kobalt.kotlin.ScriptCompiler2 +import com.beust.kobalt.mainNoExit +import com.beust.kobalt.misc.log +import com.google.inject.Inject +import java.io.BufferedReader +import java.io.InputStreamReader +import java.io.PrintWriter +import java.net.ConnectException +import java.net.Socket +import java.util.concurrent.Executors + +public class KobaltClient @Inject constructor() : Runnable { + var outgoing: PrintWriter? = null + + override fun run() { + val portNumber = Args.DEFAULT_SERVER_PORT + + Executors.newFixedThreadPool(1).submit { + log(1, "Lauching Kobalt main") + mainNoExit(arrayOf("--dev", "--server", "assemble")) + } + + var done = false + var attempts = 1 + while (attempts < 3 && ! done) { + try { + val socket = Socket("localhost", portNumber) + val ins = BufferedReader(InputStreamReader(socket.inputStream)) + done = true + log(1, "Launching listening server") + var fromServer = ins.readLine() + while (fromServer != null) { + log(1, "From server: " + fromServer); + if (fromServer.equals("Bye.")) + break; + fromServer = ins.readLine() + } + } catch(ex: ConnectException) { + log(1, "Server not up, sleeping a bit") + Thread.sleep(2000) + attempts++ + } + } + } + + fun sendInfo(info: ScriptCompiler2.BuildScriptInfo) { + outgoing!!.println("Sending info with project count: " + info.projects.size()) + } +} diff --git a/src/main/kotlin/com/beust/kobalt/internal/KobaltServer.kt b/src/main/kotlin/com/beust/kobalt/internal/KobaltServer.kt new file mode 100644 index 00000000..2305e7ff --- /dev/null +++ b/src/main/kotlin/com/beust/kobalt/internal/KobaltServer.kt @@ -0,0 +1,50 @@ +package com.beust.kobalt.internal + +import com.beust.kobalt.Args +import com.beust.kobalt.kotlin.ScriptCompiler2 +import com.beust.kobalt.misc.log +import com.google.inject.Inject +import java.io.BufferedReader +import java.io.InputStreamReader +import java.io.PrintWriter +import java.net.ServerSocket + +public class KobaltServer @Inject constructor() : Runnable { + var outgoing: PrintWriter? = null + val pending = arrayListOf() + + override fun run() { + val portNumber = Args.DEFAULT_SERVER_PORT + + log(1, "Starting on port $portNumber") + val serverSocket = ServerSocket(portNumber) + val clientSocket = serverSocket.accept() + outgoing = PrintWriter(clientSocket.outputStream, true) + if (pending.size() > 0) { + log(1, "Emptying the queue, size $pending.size()") + synchronized(pending) { + pending.forEach { sendInfo(it) } + pending.clear() + } + } + val ins = BufferedReader(InputStreamReader(clientSocket.inputStream)) + var inputLine = ins.readLine() + while (inputLine != null) { + log(1, "Received $inputLine") + if (inputLine.equals("Bye.")) + break; + inputLine = ins.readLine() + } + } + + fun sendInfo(info: ScriptCompiler2.BuildScriptInfo) { + if (outgoing != null) { + outgoing!!.println("Sending info with project count: " + info.projects.size()) + } else { + log(1, "Queuing $info") + synchronized(pending) { + pending.add(info) + } + } + } +} diff --git a/src/main/kotlin/com/beust/kobalt/kotlin/ScriptCompiler2.kt b/src/main/kotlin/com/beust/kobalt/kotlin/ScriptCompiler2.kt index c8cec56c..52308195 100644 --- a/src/main/kotlin/com/beust/kobalt/kotlin/ScriptCompiler2.kt +++ b/src/main/kotlin/com/beust/kobalt/kotlin/ScriptCompiler2.kt @@ -11,6 +11,7 @@ import com.beust.kobalt.misc.countChar import com.beust.kobalt.misc.log import com.beust.kobalt.plugin.kotlin.kotlinCompilePrivate import com.google.inject.assistedinject.Assisted +import rx.subjects.PublishSubject import java.io.File import java.io.FileInputStream import java.io.InputStream @@ -29,6 +30,8 @@ public class ScriptCompiler2 @Inject constructor(@Assisted("buildFiles") val bui fun create(@Assisted("buildFiles") buildFiles: List) : ScriptCompiler2 } + val observable = PublishSubject.create() + private val SCRIPT_JAR = "buildScript.jar" fun findProjects(): List { @@ -38,8 +41,8 @@ public class ScriptCompiler2 @Inject constructor(@Assisted("buildFiles") val bui val buildScriptJarFile = File(KFiles.findBuildScriptLocation(buildFile, SCRIPT_JAR)) maybeCompileBuildFile(buildFile, buildScriptJarFile, pluginUrls) - val output = parseBuildScriptJarFile(buildScriptJarFile, pluginUrls) - result.addAll(output.projects) + val buildScriptInfo = parseBuildScriptJarFile(buildScriptJarFile, pluginUrls) + result.addAll(buildScriptInfo.projects) } return result } @@ -130,7 +133,7 @@ public class ScriptCompiler2 @Inject constructor(@Assisted("buildFiles") val bui class BuildScriptInfo(val projects: List, val classLoader: ClassLoader) private fun parseBuildScriptJarFile(buildScriptJarFile: File, urls: List) : BuildScriptInfo { - val result = arrayListOf() + val projects = arrayListOf() var stream : InputStream? = null val allUrls = arrayListOf().plus(urls).plus(arrayOf( buildScriptJarFile.toURI().toURL(), @@ -172,7 +175,7 @@ public class ScriptCompiler2 @Inject constructor(@Assisted("buildFiles") val bui val r = method.invoke(null) if (r is Project) { log(2, "Found project ${r} in class ${cls}") - result.add(r) + projects.add(r) } } else { val taskAnnotation = method.getAnnotation(Task::class.java) @@ -188,6 +191,8 @@ public class ScriptCompiler2 @Inject constructor(@Assisted("buildFiles") val bui } // Now that we all the projects, sort them topologically - return BuildScriptInfo(Kobalt.sortProjects(result), classLoader) + val result = BuildScriptInfo(Kobalt.sortProjects(projects), classLoader) + observable.onNext(result) + return result } } From e792680dd5b2032f8db1204910ce37303a134d5f Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 20 Oct 2015 03:56:20 -0700 Subject: [PATCH 4/7] Formatting. --- src/main/kotlin/com/beust/kobalt/api/Kobalt.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/kotlin/com/beust/kobalt/api/Kobalt.kt b/src/main/kotlin/com/beust/kobalt/api/Kobalt.kt index 9b138b2e..799bfa1e 100644 --- a/src/main/kotlin/com/beust/kobalt/api/Kobalt.kt +++ b/src/main/kotlin/com/beust/kobalt/api/Kobalt.kt @@ -94,8 +94,7 @@ public class Kobalt { /** * @return the projects sorted topologically. */ - fun sortProjects(allProjects: ArrayList) : List - = topological.sort(allProjects) + fun sortProjects(allProjects: ArrayList) = topological.sort(allProjects) fun findPlugin(name: String) = Plugins.findPlugin(name) } From 05c6da10f97cd65792a43f06145acc08f210e5fa Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 20 Oct 2015 03:57:00 -0700 Subject: [PATCH 5/7] JSON server. --- .../com/beust/kobalt/internal/KobaltServer.kt | 48 ++++++++++++++++++- .../com/beust/kobalt/maven/SimpleDep.kt | 2 +- 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/beust/kobalt/internal/KobaltServer.kt b/src/main/kotlin/com/beust/kobalt/internal/KobaltServer.kt index 2305e7ff..cac31442 100644 --- a/src/main/kotlin/com/beust/kobalt/internal/KobaltServer.kt +++ b/src/main/kotlin/com/beust/kobalt/internal/KobaltServer.kt @@ -1,15 +1,22 @@ package com.beust.kobalt.internal import com.beust.kobalt.Args +import com.beust.kobalt.api.Project import com.beust.kobalt.kotlin.ScriptCompiler2 +import com.beust.kobalt.maven.IClasspathDependency +import com.beust.kobalt.maven.MavenDependency +import com.beust.kobalt.maven.SimpleDep +import com.beust.kobalt.misc.KobaltExecutors import com.beust.kobalt.misc.log import com.google.inject.Inject import java.io.BufferedReader import java.io.InputStreamReader import java.io.PrintWriter import java.net.ServerSocket +import java.util.concurrent.Executor +import java.util.concurrent.ExecutorService -public class KobaltServer @Inject constructor() : Runnable { +public class KobaltServer @Inject constructor(val executors: KobaltExecutors) : Runnable { var outgoing: PrintWriter? = null val pending = arrayListOf() @@ -39,7 +46,8 @@ public class KobaltServer @Inject constructor() : Runnable { fun sendInfo(info: ScriptCompiler2.BuildScriptInfo) { if (outgoing != null) { - outgoing!!.println("Sending info with project count: " + info.projects.size()) + val json = toJson(info, executors.miscExecutor) + outgoing!!.println(json) } else { log(1, "Queuing $info") synchronized(pending) { @@ -47,4 +55,40 @@ public class KobaltServer @Inject constructor() : Runnable { } } } + + companion object { + internal fun toJson(info: ScriptCompiler2.BuildScriptInfo, executor: ExecutorService): String { + val result = "{ projects: [" + + info.projects.map { toJson(it, executor) }.join(",\n") + + "]\n}\n" + return result + } + + private fun toJson(project: Project, executor: ExecutorService): String { + var result = "{\n" + + arrayListOf( + "\"name\" : \"${project.name}\"", + toJson("dependencies", project.compileDependencies, executor), + toJson("providedDependencies", project.compileProvidedDependencies, executor), + toJson("runtimeDependencies", project.compileRuntimeDependencies, executor), + toJson("testDependencies", project.testDependencies, executor), + toJson("testProvidedDependencies", project.testProvidedDependencies, executor) + ).join(",\n") + + "}\n" + return result + } + + private fun toJson(name: String, dependencies: List, executor: ExecutorService) : String { + return "\"$name\" : [" + + dependencies.map { + val dep = MavenDependency.create(it.id, executor) + val path = dep.jarFile.get() + "{\n" + + "\"id\" : \"${it.id}\",\n" + + "\"path\" : \"$path\"" + + "}\n" + }.join(",") + + "]" + } + } } diff --git a/src/main/kotlin/com/beust/kobalt/maven/SimpleDep.kt b/src/main/kotlin/com/beust/kobalt/maven/SimpleDep.kt index d39795dd..a4084e18 100644 --- a/src/main/kotlin/com/beust/kobalt/maven/SimpleDep.kt +++ b/src/main/kotlin/com/beust/kobalt/maven/SimpleDep.kt @@ -25,7 +25,7 @@ open public class SimpleDep(override val groupId: String, override val artifactI fun toPomFile(r: RepoFinder.RepoResult) = toFile(r.version, r.snapshotVersion, ".pom") - fun toJarFile(v: String) = toFile(v, "", ".jar") + fun toJarFile(v: String = version) = toFile(v, "", ".jar") fun toJarFile(r: RepoFinder.RepoResult) = toFile(r.version, r.snapshotVersion, ".jar") From 3af480fd8c83695f80a34db12bee646c61dbb2e3 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 20 Oct 2015 03:57:36 -0700 Subject: [PATCH 6/7] Warnings. --- .../com/beust/kobalt/kotlin/ScriptCompiler2.kt | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/com/beust/kobalt/kotlin/ScriptCompiler2.kt b/src/main/kotlin/com/beust/kobalt/kotlin/ScriptCompiler2.kt index 52308195..4479c2a5 100644 --- a/src/main/kotlin/com/beust/kobalt/kotlin/ScriptCompiler2.kt +++ b/src/main/kotlin/com/beust/kobalt/kotlin/ScriptCompiler2.kt @@ -5,10 +5,9 @@ import com.beust.kobalt.api.Kobalt import com.beust.kobalt.api.Plugin import com.beust.kobalt.api.Project import com.beust.kobalt.api.annotation.Task +import com.beust.kobalt.internal.KobaltServer import com.beust.kobalt.maven.KobaltException -import com.beust.kobalt.misc.KFiles -import com.beust.kobalt.misc.countChar -import com.beust.kobalt.misc.log +import com.beust.kobalt.misc.* import com.beust.kobalt.plugin.kotlin.kotlinCompilePrivate import com.google.inject.assistedinject.Assisted import rx.subjects.PublishSubject @@ -110,7 +109,7 @@ public class ScriptCompiler2 @Inject constructor(@Assisted("buildFiles") val bui // // Run preBuildScript.jar to initialize plugins and repos // - val projectInfo = parseBuildScriptJarFile(buildScriptJarFile, arrayListOf()) + parseBuildScriptJarFile(buildScriptJarFile, arrayListOf()) // // All the plug-ins are now in Plugins.dynamicPlugins, download them if they're not already @@ -159,7 +158,7 @@ public class ScriptCompiler2 @Inject constructor(@Assisted("buildFiles") val bui if (cl != null) { classes.add(cl) } else { - throw KobaltException("Couldn't instantiate ${className}") + throw KobaltException("Couldn't instantiate $className") } } entry = stream.nextJarEntry; @@ -174,13 +173,12 @@ public class ScriptCompiler2 @Inject constructor(@Assisted("buildFiles") val bui if (method.name.startsWith("get") && Modifier.isStatic(method.modifiers)) { val r = method.invoke(null) if (r is Project) { - log(2, "Found project ${r} in class ${cls}") + log(2, "Found project $r in class $cls") projects.add(r) } } else { val taskAnnotation = method.getAnnotation(Task::class.java) if (taskAnnotation != null) { - // Plugins.defaultPlugin.addTask(taskAnnotation, ) Plugins.defaultPlugin.methodTasks.add(Plugin.MethodTask(method, taskAnnotation)) } From 1a362091b06eb3dba43ae5d572a52bef63947d9e Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 20 Oct 2015 04:06:27 -0700 Subject: [PATCH 7/7] Path problem. --- src/main/kotlin/com/beust/kobalt/maven/Gpg.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/com/beust/kobalt/maven/Gpg.kt b/src/main/kotlin/com/beust/kobalt/maven/Gpg.kt index cac3b10a..df740334 100644 --- a/src/main/kotlin/com/beust/kobalt/maven/Gpg.kt +++ b/src/main/kotlin/com/beust/kobalt/maven/Gpg.kt @@ -38,7 +38,7 @@ public class Gpg { if (gpg != null) { val directory = files.get(0).parentFile.absoluteFile files.forEach { file -> - val ascFile = File(directory, file.absolutePath + ".asc") + val ascFile = File(file.absolutePath + ".asc") ascFile.delete() val allArgs = arrayListOf() allArgs.add(gpg)