Skip to content

Commit f127118

Browse files
authored
Merge pull request #29 from Kotlin/windows_build_fixes
Fixed windows path separator issues
2 parents 41b907a + 2f3839b commit f127118

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ build/
66
**/.ipynb*
77
**/build/
88
*.DS_Store
9+
gradle.properties

build.gradle

+17-8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import java.nio.file.Paths
12

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

3839
version = '0.7.3'
3940

40-
ext.installPath = project.hasProperty('installPath') ? project.getProperty('installPath') : "${System.properties['user.home']}/.ipython/kernels/kotlin"
41+
ext.installPath = project.hasProperty('installPath') ?
42+
project.getProperty('installPath') :
43+
Paths.get(System.properties['user.home'].toString(), ".ipython", "kernels", "kotlin").toAbsolutePath().toString()
4144
ext.debugPort = 1044
4245
ext.configFile = "config.json"
4346
ext.debuggerConfig = "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=$debugPort"
@@ -102,24 +105,30 @@ void createTaskForSpecs(Boolean debug) {
102105
task(taskName) {
103106
dependsOn cleanInstallDir
104107
doLast {
105-
String spec = new File("kernelspec/kernel.json.template").getText('UTF-8')
108+
String sep = File.separator
109+
String spec = new File("kernelspec${sep}kernel.json.template").getText('UTF-8')
106110
File kernelFile = files { shadowJar }.singleFile
107-
spec = spec.replace("\${KERNEL_JAR_PATH}", "$installPath/${kernelFile.name}")
111+
spec = substitute(spec, "KERNEL_JAR_PATH", "$installPath${sep}${kernelFile.name}")
112+
108113
String libsCp = files { configurations.deploy }.files.collect {
109-
"$installPath/${it.name}"
114+
"$installPath${sep}${it.name}"
110115
} .join(File.pathSeparator)
111-
spec = spec.replace("\${RUNTIME_CLASSPATH}", libsCp)
112-
.replace("\${DEBUGGER_CONFIG}", debug ? "\"$debuggerConfig\"," : "")
113-
.replace("\${LIBRARIES_PATH}", "$installPath/$configFile")
116+
spec = substitute(spec, "RUNTIME_CLASSPATH", libsCp)
117+
spec = substitute(spec, "DEBUGGER_CONFIG", debug ? "\"$debuggerConfig\"," : "")
118+
spec = substitute(spec, "LIBRARIES_PATH", "$installPath$sep$configFile")
114119
File installDir = new File("$installPath")
115120
if (!installDir.exists()) {
116121
installDir.mkdirs();
117122
}
118-
new File("$installPath/kernel.json").write(spec, 'UTF-8')
123+
new File("$installPath${sep}kernel.json").write(spec, 'UTF-8')
119124
}
120125
}
121126
}
122127

128+
static String substitute(String spec, String template, String val) {
129+
return spec.replace("\${$template}", val.replace("\\", "\\\\"))
130+
}
131+
123132
task copyLibrariesConfig(type: Copy, dependsOn: cleanInstallDir) {
124133
from configFile
125134
into installPath

gradle.properties.template

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
installPath=<path-to-jupyter>/kernels/kotlin

0 commit comments

Comments
 (0)