Skip to content

Commit

Permalink
fix: gui set to built-in
Browse files Browse the repository at this point in the history
  • Loading branch information
cjlee38 committed Sep 22, 2024
1 parent d6109a5 commit c1ccb07
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:

- name: Build JAR
working-directory: ./gitnote-jetbrains
run: ./gradlew buildPlugin -Dgitnote.phase=2
run: ./gradlew buildPlugin -Dgitnote.useLocalGui=false -Dgitnote.buildCore=false

- name: Get Project Version
id: get_version
Expand Down
42 changes: 26 additions & 16 deletions gitnote-jetbrains/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
}

group = "io.cjlee"
version = "0.2.6"
version = "0.2.7"

repositories {
mavenCentral()
Expand All @@ -29,11 +29,18 @@ intellij {
plugins.set(listOf(/* Plugin Dependencies */))
}

// phase
val PHASE_DEVELOP = 0
val PHASE_ALPHA = 1
val PHASE_RELEASE = 2
val phase = (System.getProperty("gitnote.phase") ?: "0").toInt()

/**
* Determine whether to use `localhost:3000` GUI for development. false by default means using the built-in GUI
*/
val useLocalGui = System.getProperty("gitnote.useLocalGui")?.toBoolean() ?: false

/**
* Determine whether to build the core module locally.
*
* Usually set to false when you release the plugin using github-actions.
*/
val buildCore = System.getProperty("gitnote.buildCore")?.toBoolean() ?: true

tasks {
// Set the JVM compatibility versions
Expand All @@ -52,14 +59,24 @@ tasks {

runIde {
autoReloadPlugins = true
systemProperty("gitnote.phase", phase)
}

buildPlugin {
if (phase == PHASE_ALPHA) {
dependsOn("buildCore")
if (!useLocalGui) {
dependsOn("buildGui")
}
if (buildCore) {
dependsOn("buildCore")
}
}

processResources {
if (!useLocalGui) {
dependsOn(named("copyGui"))
}
if (buildCore) {
dependsOn(named("copyCore"))
}
}

signPlugin {
Expand Down Expand Up @@ -96,11 +113,4 @@ tasks {
from("../gitnote-gui/build")
into("src/main/resources/webview/.")
}

processResources {
if (phase == PHASE_ALPHA) {
dependsOn(named("copyCore"))
dependsOn(named("copyGui"))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class ProcessCoreConnector(
}

companion object {
private val phase = System.getProperty("gitnote.phase", "1").toInt()
private val systemCommand = arrayOf("git", "note")
val COMMAND: Array<String>

Expand All @@ -53,10 +52,7 @@ class ProcessCoreConnector(
}

private fun determineCommand(): Array<String> {
val platform = ConnectorLoader.platform
if (phase == 0 || platform == null) {
return systemCommand
}
val platform = ConnectorLoader.platform ?: return systemCommand
val filename = when (platform) {
Platform.WINDOWS -> "git-note.exe"
else -> "git-note"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ class GitNoteViewerWindow(
private val project: Project,
private val protocolHandlers: Map<String, ProtocolHandler>
) {
private val phase = System.getProperty("gitnote.phase", "1").toInt()
private val useLocalGui = System.getProperty("gitnote.useLocalGui", "false").toBoolean()

val webView: JBCefBrowser = JBCefBrowser.createBuilder()
.setOffScreenRendering(false)
.build()
.apply {
if (phase == 0) this.loadURL("http://localhost:3000/index.html")
if (useLocalGui) this.loadURL("http://localhost:3000/index.html")
else this.loadURL("http://gitnote/index.html")

registerAppSchemeHandler()
Expand All @@ -49,7 +49,7 @@ class GitNoteViewerWindow(
frontHandler.addHandler("theme", ThemeProtocolHandler())
jsQuery.addHandler(frontHandler)

if (phase == 0) {
if (useLocalGui) {
browser.jbCefClient.addDisplayHandler(JCefDebugDisplayHandler(), browser.cefBrowser) // for debugging
}
}
Expand Down

0 comments on commit c1ccb07

Please sign in to comment.