mirror of
https://github.com/google/gn-language-server.git
synced 2025-12-23 12:26:43 +00:00
Bundle gn-language-server binary in IntelliJ plugin
This change updates the build process and runtime logic of the IntelliJ plugin to bundle and use a prebuilt gn-language-server binary. - Modified `intellij-gn/build.gradle.kts` to accept a `gnBinaryPath` property and copy the specified binary into the plugin's `bin` directory during the `prepareSandbox` task. - Updated `GnLspServerFactory.kt` to look for the `gn-language-server` executable within the plugin's installation directory. If found, it is used; otherwise, the plugin falls back to using the executable from the system PATH. - Updated `.github/workflows/ci.yml` to build the IntelliJ plugin as part of the CI pipeline, passing the platform-specific rust binary path to the Gradle build, and uploading the resulting plugin artifacts.
This commit is contained in:
parent
b3eba58e2c
commit
396ccd18ae
3 changed files with 45 additions and 1 deletions
22
.github/workflows/ci.yml
vendored
22
.github/workflows/ci.yml
vendored
|
|
@ -96,6 +96,23 @@ jobs:
|
|||
with:
|
||||
name: vscode-gn-vsix-${{ matrix.vscode_target }}
|
||||
path: vscode-gn/*.vsix
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'zulu'
|
||||
java-version: '21'
|
||||
- uses: gradle/actions/setup-gradle@v4
|
||||
with:
|
||||
gradle-version: 8.14.3
|
||||
- name: Build IntelliJ Plugin
|
||||
working-directory: intellij-gn
|
||||
shell: bash
|
||||
run: |
|
||||
gradle buildPlugin -PgnBinaryPath="../target/${{ matrix.rust_target }}/release/gn-language-server$(if [ "${{ matrix.os }}" = "windows-latest" ]; then echo ".exe"; fi)"
|
||||
mv build/distributions/intellij-gn-*.zip build/distributions/intellij-gn-${{ matrix.vscode_target }}.zip
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: intellij-gn-${{ matrix.vscode_target }}
|
||||
path: intellij-gn/build/distributions/*.zip
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: gn-language-server-${{ matrix.rust_target }}
|
||||
|
|
@ -130,6 +147,11 @@ jobs:
|
|||
pattern: vscode-gn-vsix-*
|
||||
path: ${{ github.workspace }}/artifacts
|
||||
merge-multiple: true
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
pattern: intellij-gn-*
|
||||
path: ${{ github.workspace }}/artifacts
|
||||
merge-multiple: true
|
||||
- run: ls -l .
|
||||
working-directory: artifacts
|
||||
- run: gh release upload "${{ github.ref_name }}" artifacts/*
|
||||
|
|
|
|||
|
|
@ -60,6 +60,15 @@ tasks {
|
|||
wrapper {
|
||||
gradleVersion = "8.14.3"
|
||||
}
|
||||
|
||||
prepareSandbox {
|
||||
val gnBinaryPath = project.findProperty("gnBinaryPath") as? String
|
||||
if (gnBinaryPath != null) {
|
||||
from(gnBinaryPath) {
|
||||
into("${intellijPlatform.pluginConfiguration.name.get()}/bin")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
kotlin {
|
||||
|
|
|
|||
|
|
@ -14,15 +14,28 @@
|
|||
|
||||
package com.google.gn
|
||||
|
||||
import com.intellij.ide.plugins.PluginManagerCore
|
||||
import com.intellij.openapi.extensions.PluginId
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.SystemInfo
|
||||
import com.redhat.devtools.lsp4ij.LanguageServerFactory
|
||||
import com.redhat.devtools.lsp4ij.server.ProcessStreamConnectionProvider
|
||||
import com.redhat.devtools.lsp4ij.server.StreamConnectionProvider
|
||||
import java.nio.file.Files
|
||||
|
||||
class GnLspServerFactory : LanguageServerFactory {
|
||||
override fun createConnectionProvider(project: Project): StreamConnectionProvider {
|
||||
val plugin = PluginManagerCore.getPlugin(PluginId.getId("com.google.gn"))
|
||||
val binaryName = if (SystemInfo.isWindows) "gn-language-server.exe" else "gn-language-server"
|
||||
val bundledBinary = plugin?.pluginPath?.resolve("bin")?.resolve(binaryName)
|
||||
val command = if (bundledBinary != null && Files.exists(bundledBinary)) {
|
||||
listOf(bundledBinary.toAbsolutePath().toString())
|
||||
} else {
|
||||
listOf("gn-language-server")
|
||||
}
|
||||
|
||||
return object : ProcessStreamConnectionProvider(
|
||||
listOf("gn-language-server"),
|
||||
command,
|
||||
project.basePath
|
||||
) {}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue