|
| 1 | +import java.nio.file.Paths |
1 | 2 |
|
2 | 3 | buildscript {
|
3 | 4 | ext.shadowJarVersion = "5.2.0"
|
@@ -37,7 +38,9 @@ allprojects {
|
37 | 38 |
|
38 | 39 | version = '0.7.3'
|
39 | 40 |
|
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() |
41 | 44 | ext.debugPort = 1044
|
42 | 45 | ext.configFile = "config.json"
|
43 | 46 | ext.debuggerConfig = "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=$debugPort"
|
@@ -102,24 +105,30 @@ void createTaskForSpecs(Boolean debug) {
|
102 | 105 | task(taskName) {
|
103 | 106 | dependsOn cleanInstallDir
|
104 | 107 | 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') |
106 | 110 | 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 | + |
108 | 113 | String libsCp = files { configurations.deploy }.files.collect {
|
109 |
| - "$installPath/${it.name}" |
| 114 | + "$installPath${sep}${it.name}" |
110 | 115 | } .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") |
114 | 119 | File installDir = new File("$installPath")
|
115 | 120 | if (!installDir.exists()) {
|
116 | 121 | installDir.mkdirs();
|
117 | 122 | }
|
118 |
| - new File("$installPath/kernel.json").write(spec, 'UTF-8') |
| 123 | + new File("$installPath${sep}kernel.json").write(spec, 'UTF-8') |
119 | 124 | }
|
120 | 125 | }
|
121 | 126 | }
|
122 | 127 |
|
| 128 | +static String substitute(String spec, String template, String val) { |
| 129 | + return spec.replace("\${$template}", val.replace("\\", "\\\\")) |
| 130 | +} |
| 131 | + |
123 | 132 | task copyLibrariesConfig(type: Copy, dependsOn: cleanInstallDir) {
|
124 | 133 | from configFile
|
125 | 134 | into installPath
|
|
0 commit comments