-
Notifications
You must be signed in to change notification settings - Fork 106
/
Copy pathbuild.gradle
149 lines (125 loc) · 4.9 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import java.nio.file.Paths
buildscript {
ext.shadowJarVersion = "5.2.0"
ext.kotlinVersion = '1.3.70-dev-2104'
repositories {
jcenter()
mavenLocal()
mavenCentral()
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
maven { url 'https://dl.bintray.com/kotlin/kotlin-dev' }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath "com.github.jengelman.gradle.plugins:shadow:$shadowJarVersion"
}
}
allprojects {
apply plugin: 'kotlin'
repositories {
jcenter()
mavenLocal()
mavenCentral()
// only when using Kotlin EAP releases ...
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
maven { url 'https://dl.bintray.com/kotlin/kotlin-dev' }
maven { url 'https://kotlin.bintray.com/kotlin-dependencies' }
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
testCompile 'junit:junit:4.12'
testCompile "org.jetbrains.kotlin:kotlin-test:$kotlinVersion"
}
version = '0.7.3'
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"
}
apply plugin: 'com.github.johnrengelman.shadow'
configurations {
deploy
}
dependencies {
compile project(":jupyter-lib")
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion"
compile "org.jetbrains.kotlin:kotlin-scripting-jvm-host-embeddable:$kotlinVersion"
compile "org.jetbrains.kotlin:kotlin-scripting-common:$kotlinVersion"
compile "org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:$kotlinVersion"
compile "org.jetbrains.kotlin:kotlin-compiler-embeddable:$kotlinVersion"
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"
compile "org.jetbrains.kotlin:kotlin-script-util:$kotlinVersion"
compile "org.jetbrains.kotlin:kotlin-main-kts:$kotlinVersion"
compile "org.jetbrains.kotlin:kotlin-scripting-dependencies:$kotlinVersion"
compile "org.jetbrains.kotlin:kotlin-scripting-dependencies-maven:$kotlinVersion"
compile "org.apache.maven:maven-core:3.0.3"
compile 'org.slf4j:slf4j-api:1.7.25'
compile 'org.zeromq:jeromq:0.3.5'
compile 'com.beust:klaxon:5.2'
runtime 'org.slf4j:slf4j-simple:1.7.25'
runtime "org.jetbrains.kotlin:jcabi-aether:1.0-dev-3"
runtime "org.sonatype.aether:aether-api:1.13.1"
runtime "net.java.dev.jna:jna:5.4.0"
deploy project(":jupyter-lib")
}
jar.manifest.attributes(
'Main-class': 'org.jetbrains.kotlin.jupyter.IkotlinKt',
'Implementation-Version': version
)
shadowJar {
baseName = 'kotlin-jupyter-kernel'
classifier = ''
mergeServiceFiles()
}
task cleanInstallDir(){
doLast {
File installDir = new File("$installPath")
installDir.deleteDir()
}
}
task installKernel(type: Copy, dependsOn: [cleanInstallDir, shadowJar]) {
from shadowJar.outputs
into installPath
}
void createTaskForSpecs(Boolean debug) {
String taskName = debug ? "createDebugSpecs" : "createSpecs"
task(taskName) {
dependsOn cleanInstallDir
doLast {
String sep = File.separator
String spec = new File("kernelspec${sep}kernel.json.template").getText('UTF-8')
File kernelFile = files { shadowJar }.singleFile
spec = substitute(spec, "KERNEL_JAR_PATH", "$installPath${sep}${kernelFile.name}")
String libsCp = files { configurations.deploy }.files.collect {
"$installPath${sep}${it.name}"
} .join(File.pathSeparator)
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${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
}
createTaskForSpecs(true)
createTaskForSpecs(false)
task installLibs(type: Copy, dependsOn: cleanInstallDir) {
into "$installPath"
from configurations.deploy
}
task install(dependsOn: [installKernel, installLibs, createSpecs, copyLibrariesConfig]) {
}
task installDebug(dependsOn: [installKernel, installLibs, createDebugSpecs, copyLibrariesConfig]) {
}