Skip to content

Commit c1ccb07

Browse files
committed
fix: gui set to built-in
1 parent d6109a5 commit c1ccb07

File tree

4 files changed

+31
-25
lines changed

4 files changed

+31
-25
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272

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

7777
- name: Get Project Version
7878
id: get_version

gitnote-jetbrains/build.gradle.kts

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ plugins {
88
}
99

1010
group = "io.cjlee"
11-
version = "0.2.6"
11+
version = "0.2.7"
1212

1313
repositories {
1414
mavenCentral()
@@ -29,11 +29,18 @@ intellij {
2929
plugins.set(listOf(/* Plugin Dependencies */))
3030
}
3131

32-
// phase
33-
val PHASE_DEVELOP = 0
34-
val PHASE_ALPHA = 1
35-
val PHASE_RELEASE = 2
36-
val phase = (System.getProperty("gitnote.phase") ?: "0").toInt()
32+
33+
/**
34+
* Determine whether to use `localhost:3000` GUI for development. false by default means using the built-in GUI
35+
*/
36+
val useLocalGui = System.getProperty("gitnote.useLocalGui")?.toBoolean() ?: false
37+
38+
/**
39+
* Determine whether to build the core module locally.
40+
*
41+
* Usually set to false when you release the plugin using github-actions.
42+
*/
43+
val buildCore = System.getProperty("gitnote.buildCore")?.toBoolean() ?: true
3744

3845
tasks {
3946
// Set the JVM compatibility versions
@@ -52,14 +59,24 @@ tasks {
5259

5360
runIde {
5461
autoReloadPlugins = true
55-
systemProperty("gitnote.phase", phase)
5662
}
5763

5864
buildPlugin {
59-
if (phase == PHASE_ALPHA) {
60-
dependsOn("buildCore")
65+
if (!useLocalGui) {
6166
dependsOn("buildGui")
6267
}
68+
if (buildCore) {
69+
dependsOn("buildCore")
70+
}
71+
}
72+
73+
processResources {
74+
if (!useLocalGui) {
75+
dependsOn(named("copyGui"))
76+
}
77+
if (buildCore) {
78+
dependsOn(named("copyCore"))
79+
}
6380
}
6481

6582
signPlugin {
@@ -96,11 +113,4 @@ tasks {
96113
from("../gitnote-gui/build")
97114
into("src/main/resources/webview/.")
98115
}
99-
100-
processResources {
101-
if (phase == PHASE_ALPHA) {
102-
dependsOn(named("copyCore"))
103-
dependsOn(named("copyGui"))
104-
}
105-
}
106116
}

gitnote-jetbrains/src/main/kotlin/io/cjlee/gitnote/core/ProcessCoreConnector.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ class ProcessCoreConnector(
4444
}
4545

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

@@ -53,10 +52,7 @@ class ProcessCoreConnector(
5352
}
5453

5554
private fun determineCommand(): Array<String> {
56-
val platform = ConnectorLoader.platform
57-
if (phase == 0 || platform == null) {
58-
return systemCommand
59-
}
55+
val platform = ConnectorLoader.platform ?: return systemCommand
6056
val filename = when (platform) {
6157
Platform.WINDOWS -> "git-note.exe"
6258
else -> "git-note"

gitnote-jetbrains/src/main/kotlin/io/cjlee/gitnote/jcef/GitNoteViewerWindow.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ class GitNoteViewerWindow(
2222
private val project: Project,
2323
private val protocolHandlers: Map<String, ProtocolHandler>
2424
) {
25-
private val phase = System.getProperty("gitnote.phase", "1").toInt()
25+
private val useLocalGui = System.getProperty("gitnote.useLocalGui", "false").toBoolean()
2626

2727
val webView: JBCefBrowser = JBCefBrowser.createBuilder()
2828
.setOffScreenRendering(false)
2929
.build()
3030
.apply {
31-
if (phase == 0) this.loadURL("http://localhost:3000/index.html")
31+
if (useLocalGui) this.loadURL("http://localhost:3000/index.html")
3232
else this.loadURL("http://gitnote/index.html")
3333

3434
registerAppSchemeHandler()
@@ -49,7 +49,7 @@ class GitNoteViewerWindow(
4949
frontHandler.addHandler("theme", ThemeProtocolHandler())
5050
jsQuery.addHandler(frontHandler)
5151

52-
if (phase == 0) {
52+
if (useLocalGui) {
5353
browser.jbCefClient.addDisplayHandler(JCefDebugDisplayHandler(), browser.cefBrowser) // for debugging
5454
}
5555
}

0 commit comments

Comments
 (0)