Skip to content

Commit

Permalink
Merge pull request #63 from Strumenta/windows-fixes
Browse files Browse the repository at this point in the history
Windows fixes
  • Loading branch information
martin-azpillaga authored Feb 22, 2024
2 parents 897f628 + f6bf622 commit 1182fe7
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ class LanguageServerPlugin : Plugin<Project?> {
}
}

fun isWindows(): Boolean {
return System.getProperty("os.name").toLowerCase().contains("win")
}
private fun createVscodeExtension(project: Project) {
val shadowJar = project.tasks.getByName("shadowJar") as ShadowJar
val entryPoint = shadowJar.manifest.attributes["Main-Class"] as String
Expand Down Expand Up @@ -199,7 +202,7 @@ class LanguageServerPlugin : Plugin<Project?> {
Files.writeString(
Paths.get(configuration.outputPath.toString(), "client.js"),
"""
let {LanguageClient} = require("../node_modules/vscode-languageclient/node");
let {LanguageClient} = require("./node_modules/vscode-languageclient/node");
async function activate (context)
{
Expand All @@ -218,8 +221,11 @@ class LanguageServerPlugin : Plugin<Project?> {

Files.copy(configuration.serverJarPath, Paths.get(configuration.outputPath.toString(), "server.jar"), StandardCopyOption.REPLACE_EXISTING)

ProcessBuilder("npm", "install", "--prefix", "build", "vscode-languageclient").directory(project.projectDir).start().waitFor()
ProcessBuilder("npx", "esbuild", "build/vscode/client.js", "--bundle", "--external:vscode", "--format=cjs", "--platform=node", "--outfile=build/vscode/client.js", "--allow-overwrite").directory(project.projectDir).start().waitFor()
val npm = if(isWindows()) "npm.cmd" else "npm"
val npx = if(isWindows()) "npx.cmd" else "npx"

ProcessBuilder(npm, "install", "--prefix", "build/vscode/", "vscode-languageclient").directory(project.projectDir).start().waitFor()
ProcessBuilder(npx, "esbuild", "build/vscode/client.js", "--bundle", "--external:vscode", "--format=cjs", "--platform=node", "--outfile=build/vscode/client.js", "--allow-overwrite").directory(project.projectDir).start().waitFor()

if (Files.exists(configuration.textmateGrammarPath)) {
Files.copy(configuration.textmateGrammarPath, Paths.get(configuration.outputPath.toString(), "grammar.tmLanguage"), StandardCopyOption.REPLACE_EXISTING)
Expand All @@ -241,6 +247,6 @@ class LanguageServerPlugin : Plugin<Project?> {
ProcessBuilder("curl", "https://repo1.maven.org/maven2/org/apache/lucene/lucene-core/9.8.0/lucene-core-9.8.0.jar", "-o", Paths.get(configuration.outputPath.toString(), "lucene-core-9.8.0.jar").toString()).start().waitFor()
ProcessBuilder("curl", "https://repo1.maven.org/maven2/org/apache/lucene/lucene-codecs/9.8.0/lucene-codecs-9.8.0.jar", "-o", Paths.get(configuration.outputPath.toString(), "lucene-codecs-9.8.0.jar").toString()).start().waitFor()

ProcessBuilder("npx", "[email protected]", "package").directory(configuration.outputPath.toFile()).start().waitFor()
ProcessBuilder(npx, "[email protected]", "package").directory(configuration.outputPath.toFile()).start().waitFor()
}
}

0 comments on commit 1182fe7

Please sign in to comment.