Skip to content

Commit 8e272a0

Browse files
author
Martin Vehovsky
committed
cygwin support improvements
- quote paths containing windows path separator '\' that was causing escaping characters in cygwin - use invariant separator '/' when generating gradle file for '--package'
1 parent 10a9cef commit 8e272a0

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/main/kotlin/kscript/app/AppHelpers.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ sourceSets.main.java.srcDirs 'src'
244244
// also symlink all includes
245245
includeURLs.distinctBy { it.fileName() }
246246
.forEach {
247-
247+
248248
val includeFile = when {
249249
it.protocol == "file" -> File(it.toURI())
250250
else -> fetchFromURL(it.toString())
@@ -254,7 +254,7 @@ sourceSets.main.java.srcDirs 'src'
254254
}
255255
}
256256

257-
return "idea ${tmpProjectDir.absolutePath}"
257+
return "idea \"${tmpProjectDir.absolutePath}\""
258258
}
259259

260260
private fun URL.fileName() = this.toURI().path.split("/").last()
@@ -313,7 +313,7 @@ $stringifiedDeps
313313
compile group: 'org.jetbrains.kotlin', name: 'kotlin-script-runtime', version: '${KotlinVersion.CURRENT}'
314314
315315
// https://stackoverflow.com/questions/20700053/how-to-add-local-jar-file-dependency-to-build-gradle-file
316-
compile files('${scriptJar}')
316+
compile files('${scriptJar.invariantSeparatorsPath}')
317317
}
318318
319319
// http://www.capsule.io/user-guide/#really-executable-capsules
@@ -360,11 +360,14 @@ exec java -jar ${'$'}0 "${'$'}@"
360360

361361
File(tmpProjectDir, "build.gradle").writeText(gradleScript)
362362

363-
val pckgResult = evalBash("cd ${tmpProjectDir} && gradle simpleCapsule && cp build/libs/${appName}*.jar ${pckgedJar} && chmod +x ${pckgedJar}")
363+
val pckgResult = evalBash("cd '${tmpProjectDir}' && gradle simpleCapsule")
364364

365365
with(pckgResult) {
366366
kscript.app.errorIf(exitCode != 0) { "packaging of '$appName' failed:\n$pckgResult" }
367367
}
368368

369+
pckgedJar.delete()
370+
File(tmpProjectDir, "build/libs/${appName}-capsule.jar").copyTo(pckgedJar, true)
371+
369372
infoMsg("Finished packaging into ${pckgedJar}")
370373
}

src/main/kotlin/kscript/app/Kscript.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ fun main(args: Array<String>) {
270270
if (classpath.isNotEmpty())
271271
extClassPath += kscript.app.CP_SEPARATOR_CHAR + classpath
272272

273-
println("kotlin ${kotlinOpts} -classpath ${extClassPath} ${execClassName} ${joinedUserArgs} ")
273+
println("kotlin ${kotlinOpts} -classpath \"${extClassPath}\" ${execClassName} ${joinedUserArgs} ")
274274
}
275275

276276

0 commit comments

Comments
 (0)