From b2767a257a0d553d80852ef328df443b73a2923a Mon Sep 17 00:00:00 2001 From: Jiaaming <2455951489@qq.com> Date: Tue, 6 Aug 2024 16:18:22 +0800 Subject: [PATCH] refine doc and remove redundant file --- CONTRIBUTING.md | 6 +- .../exceptions/GradleExecutionException.java | 16 ---- .../gradle/exceptions/ProcessException.java | 13 ---- .../badsyntax/gradle/process/Process.java | 74 ------------------- .../gradle/process/ProcessOutput.java | 28 ------- proto/gradle.proto | 40 ---------- 6 files changed, 1 insertion(+), 176 deletions(-) delete mode 100644 gradle-server/src/main/java/com/github/badsyntax/gradle/exceptions/GradleExecutionException.java delete mode 100644 gradle-server/src/main/java/com/github/badsyntax/gradle/exceptions/ProcessException.java delete mode 100644 gradle-server/src/main/java/com/github/badsyntax/gradle/process/Process.java delete mode 100644 gradle-server/src/main/java/com/github/badsyntax/gradle/process/ProcessOutput.java diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 508a6d084..318272fc6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -51,11 +51,7 @@ The extension uses a Gradle plugin (`com.microsoft.gradle.GradlePlugin`) to get 1. Run vscode launch configuration `Debug Gradle Server & Extension`. 2. Run vscode launch configuration `Attach to Gradle Server` when you notice the `Gradle: Connecting...` message in the bottom status bar. -> **Note:** If the "Java: Error" message appears in the bottom status bar and the following error is logged in the `.log` file: -> ```java -> java.lang.NullPointerException: Cannot invoke "ch.epfl.scala.bsp4j.WorkspaceBuildTargetsResult.getTargets()" -> ``` -> it indicates that the connection attempt to the Gradle Server was too slow. The [GradleBuildClient](/extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/gradle/bs/importer/ImporterPlugin.java#L107) requires an active Gradle Server to successfully establish a connection. If you encounter this issue, please retry the connection promptly to avoid this error. +> **Note:** If `[error] Error connecting to gradle server: Failed to connect before the deadline` appears in the `Gradle for Java` output channel, it indicates that the connection attempt to the Gradle Server was too slow. The [GradleBuildClient](/extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/gradle/bs/importer/ImporterPlugin.java#L107) requires an active Gradle Server to successfully establish a connection. If you encounter this issue, please retry the connection promptly to avoid this error. ## Development Workflow diff --git a/gradle-server/src/main/java/com/github/badsyntax/gradle/exceptions/GradleExecutionException.java b/gradle-server/src/main/java/com/github/badsyntax/gradle/exceptions/GradleExecutionException.java deleted file mode 100644 index 8ad2cbf78..000000000 --- a/gradle-server/src/main/java/com/github/badsyntax/gradle/exceptions/GradleExecutionException.java +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. - -package com.github.badsyntax.gradle.exceptions; - -public class GradleExecutionException extends Exception { - private static final long serialVersionUID = 1L; - - public GradleExecutionException(String message) { - super(message); - } - - public GradleExecutionException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/gradle-server/src/main/java/com/github/badsyntax/gradle/exceptions/ProcessException.java b/gradle-server/src/main/java/com/github/badsyntax/gradle/exceptions/ProcessException.java deleted file mode 100644 index 3e2f16a3a..000000000 --- a/gradle-server/src/main/java/com/github/badsyntax/gradle/exceptions/ProcessException.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.github.badsyntax.gradle.exceptions; - -public class ProcessException extends Exception { - private static final long serialVersionUID = 1L; - - public ProcessException(String message) { - super(message); - } - - public ProcessException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/gradle-server/src/main/java/com/github/badsyntax/gradle/process/Process.java b/gradle-server/src/main/java/com/github/badsyntax/gradle/process/Process.java deleted file mode 100644 index cf1210bca..000000000 --- a/gradle-server/src/main/java/com/github/badsyntax/gradle/process/Process.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.github.badsyntax.gradle.process; - -import com.github.badsyntax.gradle.exceptions.ProcessException; -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.io.InputStreamReader; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -public class Process implements AutoCloseable { - public static final Boolean IS_WINDOWS = System.getProperty("os.name").toLowerCase().contains("windows"); - private static Runtime runtime = Runtime.getRuntime(); - private File workingDir; - private String windowsCommand; - private String unixCommand; - private ProcessOutput processOutput; - - public Process(File workingDir) { - this.workingDir = workingDir; - } - - public synchronized void setWindowsCommand(String command) { - this.windowsCommand = command; - } - - public synchronized void setUnixCommand(String command) { - this.unixCommand = command; - } - - public static synchronized void kill(String pid) throws IOException { - if (Boolean.TRUE.equals(IS_WINDOWS)) { - runtime.exec(String.format("taskkill /f /pid %s", pid)); - } else { - runtime.exec(String.format("kill -9 %s", pid)); - } - } - - public synchronized void exec(String... args) throws IOException, ProcessException { - ProcessBuilder processBuilder = new ProcessBuilder(buildCommand(args)); - processBuilder.directory(workingDir); - Map env = processBuilder.environment(); - // use the same java runtime to execute wrapper - env.put("JAVA_HOME", System.getProperty("java.home")); - java.lang.Process process = processBuilder.start(); - this.processOutput = new ProcessOutput(new BufferedReader(new InputStreamReader(process.getInputStream())), - new BufferedReader(new InputStreamReader(process.getErrorStream()))); - } - - private synchronized List buildCommand(String[] args) throws ProcessException { - String command = Boolean.TRUE.equals(IS_WINDOWS) ? windowsCommand : unixCommand; - if (command == null) { - throw new ProcessException("No command is set"); - } - Path commandPath = Paths.get(workingDir.getAbsolutePath(), command); - ArrayList commandList = new ArrayList<>(); - commandList.add(commandPath.toAbsolutePath().toString()); - commandList.addAll(Arrays.asList(args)); - return commandList; - } - - public synchronized ProcessOutput getProcessOutput() { - return processOutput; - } - - @Override - public synchronized void close() throws IOException { - this.processOutput.close(); - } -} diff --git a/gradle-server/src/main/java/com/github/badsyntax/gradle/process/ProcessOutput.java b/gradle-server/src/main/java/com/github/badsyntax/gradle/process/ProcessOutput.java deleted file mode 100644 index c4bbb18ef..000000000 --- a/gradle-server/src/main/java/com/github/badsyntax/gradle/process/ProcessOutput.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.github.badsyntax.gradle.process; - -import java.io.BufferedReader; -import java.io.IOException; - -public class ProcessOutput implements AutoCloseable { - private BufferedReader stdOut; - private BufferedReader stdErr; - - public ProcessOutput(BufferedReader stdOut, BufferedReader stdErr) { - this.stdOut = stdOut; - this.stdErr = stdErr; - } - - public synchronized BufferedReader getStdOut() { - return this.stdOut; - } - - public synchronized BufferedReader getStdErr() { - return this.stdErr; - } - - @Override - public synchronized void close() throws IOException { - this.stdOut.close(); - this.stdErr.close(); - } -} diff --git a/proto/gradle.proto b/proto/gradle.proto index f8b314836..f5d4d5852 100644 --- a/proto/gradle.proto +++ b/proto/gradle.proto @@ -11,9 +11,6 @@ service Gradle { rpc RunBuild(RunBuildRequest) returns (stream RunBuildReply) {} rpc CancelBuild(CancelBuildRequest) returns (CancelBuildReply) {} rpc CancelBuilds(CancelBuildsRequest) returns (CancelBuildsReply) {} - rpc GetDaemonsStatus(GetDaemonsStatusRequest) returns (GetDaemonsStatusReply) {} - rpc StopDaemons(StopDaemonsRequest) returns (StopDaemonsReply) {} - rpc StopDaemon(StopDaemonRequest) returns (StopDaemonReply) {} rpc executeCommand(ExecuteCommandRequest) returns (ExecuteCommandReply) {} } @@ -109,43 +106,6 @@ message CancelBuildsReply { string message = 1; } -message GetDaemonsStatusRequest { - string project_dir = 1; -} - -message GetDaemonsStatusReply { - repeated DaemonInfo daemon_info = 1; -} - -message StopDaemonsRequest { - string project_dir = 1; -} - -message StopDaemonsReply { - string message = 1; -} - -message StopDaemonRequest { - string pid = 1; -} - -message StopDaemonReply { - string message = 1; -} - -message DaemonInfo { - enum DaemonStatus { - IDLE = 0; - BUSY = 1; - STOPPED = 2; - STOPPING = 3; - CANCELED = 4; - } - string pid = 1; - DaemonStatus status = 2; - string info = 3; -} - message GradleConfig { string gradle_home = 1; string user_home = 2;