Merge Gradle Server(aka. Task Server) and Build Server. Now they will start as two threads in one process. It works find for now. ✅
For the communication between Build Server and Build Client, I use Named pipe following this PR[https://github.com/eclipse-jdtls/eclipse.jdt.ls/pull/2922] in JDT.LS. Due to the different OS behavior between Windows and Unix, Windows use AsynchronousFileChannel while Unix use UnixSocket. The Unix part works fine✅ but the Windows part not work ❌.
In the Language Support For Java under Output, it will keep printing build/initialize message until out of memory. Error message like this:
In my code, I add build-server-for-gradle/.../ServerNamedPipeStream.java and vscode-gradle/.../ClientNamedPIpeStream.java In order to get InputStream and OutputStream for Launcher in both build-server-for-gradle/Launcher.java and vscode-gradle/importerPlugin.java.
In these two files, Only
private void initializeNamedPipe()
are different. Other functions are copied from previous PR implementation
Note: I hardcode for now and you can switch it to your own file path. In the end we hope to achieve this by calling VScode command.
In vscode-gradle/importerPlugin/../ClientNamedPipeStream.java:
private void initializeNamedPipe() {
File pipeFile = new File("/tmp/example.sock");
if (isWindows()) {
pipeFile = new File("/tmp/example");
AsynchronousFileChannel channel = null;
try {
channel = AsynchronousFileChannel.open(pipeFile.toPath(), StandardOpenOption.READ, StandardOpenOption.WRITE);
input = new NamedPipeInputStream(channel);
output = new NamedPipeOutputStream(channel);
} catch (IOException e) {
e.printStackTrace();
}
return;
}
boolean connected = false;
while (!connected) {
{
try {
UnixDomainSocketAddress socketAddress = UnixDomainSocketAddress.of(pipeFile.toPath());
SocketChannel channel = SocketChannel.open(StandardProtocolFamily.UNIX);
channel.connect(socketAddress);
input = new NamedPipeInputStream(channel);
output = new NamedPipeOutputStream(channel);
connected = true;
} catch (IOException e) {
try {
System.out.println("Failed to connect. Retrying in 1 second...");
Thread.sleep(1000);
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
throw new RuntimeException("Thread interrupted while trying to connect to named pipe", ie);
}
}
}
}
}
In build-Server-for-gradle/ServerNamePipeStream.java:
I believe their remain some misunderstand here because even if I switch these two initializeNamedPipe() function, they will act exactly the same(UnixSocket and build Server still works). Is this what we expect? There are many Client & Server in this whole architecture that made me quite confused.
I think it also related with lsp/Launcher since the only change I made is the Input&OutputStream parameters:
org.eclipse.lsp4j.jsonrpc.Launcher<BuildClient> launcher = new
org.eclipse.lsp4j.jsonrpc.Launcher.Builder<BuildClient>()
.setOutput(pipeStream.getOutputStream()) //here
.setInput(pipeStream.getInputStream()) //here
Hi @jdneo
New Architect:
cooperate with https://github.com/microsoft/build-server-for-gradle/pull/155
This Draft PR include following change:
Gradle Server(aka. Task Server)
andBuild Server
. Now they will start as two threads in one process. It works find for now. ✅Build Server
andBuild Client
, I use Named pipe following this PR[https://github.com/eclipse-jdtls/eclipse.jdt.ls/pull/2922] in JDT.LS. Due to the different OS behavior betweenWindows
andUnix
,Windows
useAsynchronousFileChannel
whileUnix
useUnixSocket
. The Unix part works fine✅ but theWindows
part not work ❌.If you run the code, it will stop at the
importToWorkSpace
stageIn the
Language Support For Java
under Output, it will keep printingbuild/initialize
message until out of memory. Error message like this:In my code, I add
build-server-for-gradle/.../ServerNamedPipeStream.java
andvscode-gradle/.../ClientNamedPIpeStream.java
In order to getInputStream
andOutputStream
forLauncher
in bothbuild-server-for-gradle/Launcher.java
andvscode-gradle/importerPlugin.java
.In these two files, Only
private void initializeNamedPipe()
are different. Other functions are copied from previous PR implementationNote: I hardcode for now and you can switch it to your own file path. In the end we hope to achieve this by calling VScode command.
In
vscode-gradle/importerPlugin/../ClientNamedPipeStream.java
:In
build-Server-for-gradle/ServerNamePipeStream.java
:My concerns:
initializeNamedPipe()
function, they will act exactly the same(UnixSocket and build Server still works). Is this what we expect? There are many Client & Server in this whole architecture that made me quite confused.lsp/Launcher
since the only change I made is theInput&OutputStream
parameters: