Skip to content

Commit

Permalink
add build flag on production
Browse files Browse the repository at this point in the history
- a resource that when present, signals that we are in production. delete after build.
  • Loading branch information
YairLevi committed Jan 28, 2024
1 parent 56bdcc8 commit e1c4f73
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
15 changes: 15 additions & 0 deletions cli/coffee/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ func Build() {
return
}

log.Info("Preparing for bundle")
_, err = os.Create("src/main/resources/__jar__")
if err != nil {
log.Errorf("Unexpected error: production flag was not able to set. %v", err)
return
}

_, err = RunCommand(CmdProps{
Cmd: BundleApp,
LogBefore: "Bundling to JAR",
Expand All @@ -57,5 +64,13 @@ func Build() {
log.Errorf("Failed to build app into JAR. %v", err)
return
}

log.Info("Post bundle cleanup")
err = os.Remove("src/main/resources/__jar__")
if err != nil {
log.Errorf("Unexpected error: was not able to delete temporary production flag. %v", err)
return
}

log.Info("Done. your JAR is located at `./target")
}
3 changes: 2 additions & 1 deletion src/main/kotlin/org/levi/coffee/Window.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ import kotlin.system.exitProcess
class Window(val args: Array<String>) {
private val log: Logger = LoggerFactory.getLogger(this::class.java)
private val _beforeStartCallbacks: MutableList<Runnable> = ArrayList()
private val dev = Thread.currentThread().contextClassLoader.getResource("__jar__") == null
private val _onCloseCallbacks: MutableList<Runnable> = ArrayList()
private val _bindObjects = ArrayList<Any>()
private val _webviewInitFunctions: MutableList<(wv: Webview) -> Unit> = ArrayList()

private val dev = Thread.currentThread().contextClassLoader.getResource("__jar__") == null

fun setURL(url: String) {
_webviewInitFunctions.add { it.loadURL(url) }
}
Expand Down

0 comments on commit e1c4f73

Please sign in to comment.