make smartJavaExec composable with NoDebugJavaExec

This commit is contained in:
Anton Bannykh
2019-03-28 19:23:12 +03:00
parent 8174d6c035
commit d04a0246db
2 changed files with 9 additions and 6 deletions
+6 -5
View File
@@ -8,9 +8,13 @@ import org.gradle.kotlin.dsl.task
* that can be found in the license/LICENSE.txt file.
*/
fun Project.smartJavaExec(configure: JavaExec.() -> Unit) = task<JavaExec> javaExec@{
fun Project.smartJavaExec(configure: JavaExec.() -> Unit) = task<JavaExec> {
configure()
passClasspathInJar()
}
// Moves the classpath into a jar metadata, to shorten the command line length and to avoid hitting the limit on Windows
fun JavaExec.passClasspathInJar() {
val jarTask = project.task("${name}WriteClassPath", Jar::class) {
val classpath = classpath
val main = main
@@ -28,12 +32,10 @@ fun Project.smartJavaExec(configure: JavaExec.() -> Unit) = task<JavaExec> javaE
)
}
}
archiveName = "$main.${this@javaExec.name}.classpath.container.$extension"
archiveName = "$main.${this@passClasspathInJar.name}.classpath.container.$extension"
destinationDir = temporaryDir
}
dependsOn(jarTask)
doFirst {
@@ -43,6 +45,5 @@ fun Project.smartJavaExec(configure: JavaExec.() -> Unit) = task<JavaExec> javaE
val copyArgs = args.orEmpty().toList()
args(jarTask.outputs.files.singleFile)
args(copyArgs)
}
}