Skip to content

Commit

Permalink
Use a bundler; keep the JAR small.
Browse files Browse the repository at this point in the history
This commit was made after a conversation with Marten
in which I agreed to keep the dependencies out of the JAR.
It was too tempting to try this out instead.
  • Loading branch information
petervdonovan committed Aug 26, 2022
1 parent f304413 commit 1825bab
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 15 deletions.
7 changes: 6 additions & 1 deletion org.lflang.lfc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ task buildLfc(dependsOn: ['setupTypescriptRuntime']) {
apply plugin: 'application'
apply plugin: 'com.github.johnrengelman.shadow'
mainClassName = 'org.lflang.lfc.Main'
inputs.dir 'src'
inputs.dir '../org.lflang/src'
inputs.dir '../org.lflang/src-gen'
outputs.dir 'build'

shadowJar {
zip64 true
Expand All @@ -50,7 +54,8 @@ task buildLfc(dependsOn: ['setupTypescriptRuntime']) {
task setupTypescriptRuntime(type: Exec) {
workingDir '../org.lflang/src/lib/ts/reactor-ts'
commandLine 'npm', 'install'
outputs.file('../org.lflang/src/lib/ts/reactor-ts/*')
outputs.dir('../org.lflang/src/lib/ts/reactor-ts/lib')
inputs.dir('../org.lflang/src/lib/ts/reactor-ts')
}

buildLfc.finalizedBy shadowJar
Expand Down
1 change: 1 addition & 0 deletions org.lflang/src/lib/ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"@babel/preset-typescript": "^7.8.3",
"command-line-usage": "^6.1.0",
"command-line-args": "^5.1.1",
"microtime": "^3.1.1",
"rimraf": "^3.0.2"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion org.lflang/src/lib/ts/reactor-ts
Submodule reactor-ts updated 2 files
+573 −24 package-lock.json
+5 −4 package.json
27 changes: 14 additions & 13 deletions org.lflang/src/org/lflang/generator/ts/TSGenerator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class TSGenerator(
*/
val CONFIG_FILES = arrayOf("package.json", "tsconfig.json", "babel.config.js", ".eslintrc.json")

val RT_CONFIG_FILES = arrayOf("package.json", "package-lock.json", "tsconfig.json", ".babelrc")
val RT_CONFIG_FILES = arrayOf("package.json", "tsconfig.json")

private val VG =
ExpressionGenerator(::timeInTargetLanguage) { param -> "this.${param.name}.get()" }
Expand Down Expand Up @@ -148,7 +148,6 @@ class TSGenerator(

clean(context)
copyRuntime()
buildRuntime()
copyConfigFiles()

val codeMaps = HashMap<Path, CodeMap>()
Expand Down Expand Up @@ -208,19 +207,21 @@ class TSGenerator(
*/
private fun copyRuntime() {
FileUtil.copyDirectoryFromClassPath(
"$LIB_PATH/reactor-ts",
tsFileConfig.reactorTsPath(),
"$LIB_PATH/reactor-ts/lib",
tsFileConfig.reactorTsPath().resolve("lib"),
true
)
}

private fun buildRuntime() {
(commandFactory.createCommand(
"npm",
listOf("install"),
tsFileConfig.reactorTsPath(),
false // only produce a warning if command is not found
)).run()
FileUtil.copyDirectoryFromClassPath(
"$LIB_PATH/reactor-ts/src/core/@types",
tsFileConfig.reactorTsPath().resolve("src/core/@types"),
true
)
for (configFile in RT_CONFIG_FILES) {
FileUtil.copyFileFromClassPath(
"$LIB_PATH/reactor-ts/$configFile",
tsFileConfig.reactorTsPath().resolve(configFile)
)
}
}

/**
Expand Down

0 comments on commit 1825bab

Please sign in to comment.