Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed windows path separator issues #29

Merged
merged 1 commit into from
Dec 7, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -6,3 +6,4 @@ build/
**/.ipynb*
**/build/
*.DS_Store
gradle.properties
25 changes: 17 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import java.nio.file.Paths

buildscript {
ext.shadowJarVersion = "5.2.0"
@@ -37,7 +38,9 @@ allprojects {

version = '0.7.3'

ext.installPath = project.hasProperty('installPath') ? project.getProperty('installPath') : "${System.properties['user.home']}/.ipython/kernels/kotlin"
ext.installPath = project.hasProperty('installPath') ?
project.getProperty('installPath') :
Paths.get(System.properties['user.home'].toString(), ".ipython", "kernels", "kotlin").toAbsolutePath().toString()
ext.debugPort = 1044
ext.configFile = "config.json"
ext.debuggerConfig = "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=$debugPort"
@@ -102,24 +105,30 @@ void createTaskForSpecs(Boolean debug) {
task(taskName) {
dependsOn cleanInstallDir
doLast {
String spec = new File("kernelspec/kernel.json.template").getText('UTF-8')
String sep = File.separator
String spec = new File("kernelspec${sep}kernel.json.template").getText('UTF-8')
File kernelFile = files { shadowJar }.singleFile
spec = spec.replace("\${KERNEL_JAR_PATH}", "$installPath/${kernelFile.name}")
spec = substitute(spec, "KERNEL_JAR_PATH", "$installPath${sep}${kernelFile.name}")

String libsCp = files { configurations.deploy }.files.collect {
"$installPath/${it.name}"
"$installPath${sep}${it.name}"
} .join(File.pathSeparator)
spec = spec.replace("\${RUNTIME_CLASSPATH}", libsCp)
.replace("\${DEBUGGER_CONFIG}", debug ? "\"$debuggerConfig\"," : "")
.replace("\${LIBRARIES_PATH}", "$installPath/$configFile")
spec = substitute(spec, "RUNTIME_CLASSPATH", libsCp)
spec = substitute(spec, "DEBUGGER_CONFIG", debug ? "\"$debuggerConfig\"," : "")
spec = substitute(spec, "LIBRARIES_PATH", "$installPath$sep$configFile")
File installDir = new File("$installPath")
if (!installDir.exists()) {
installDir.mkdirs();
}
new File("$installPath/kernel.json").write(spec, 'UTF-8')
new File("$installPath${sep}kernel.json").write(spec, 'UTF-8')
}
}
}

static String substitute(String spec, String template, String val) {
return spec.replace("\${$template}", val.replace("\\", "\\\\"))
}

task copyLibrariesConfig(type: Copy, dependsOn: cleanInstallDir) {
from configFile
into installPath
1 change: 1 addition & 0 deletions gradle.properties.template
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
installPath=<path-to-jupyter>/kernels/kotlin