Skip to content

Commit 4929215

Browse files
authored
Remove REWRITE_SOURCE_PATH env var support from C# RPC launcher (#7322)
The REWRITE_SOURCE_PATH fallback for launching the C# RPC server from source via dotnet run is no longer needed now that csharpServerEntry covers the dev/test use case. This simplifies the launch logic to only use the global tool exec path when no explicit entry point is set.
1 parent 5559bfc commit 4929215

1 file changed

Lines changed: 6 additions & 19 deletions

File tree

rewrite-csharp/src/main/java/org/openrewrite/csharp/rpc/CSharpRewriteRpc.java

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public static Builder builder() {
179179
public static class Builder implements Supplier<CSharpRewriteRpc> {
180180
private static final String TOOL_COMMAND = "rewrite-csharp";
181181
private static final String NUGET_PACKAGE_ID = "OpenRewrite.CSharp.Tool";
182-
private static final String REWRITE_SOURCE_PATH_ENV = "REWRITE_SOURCE_PATH";
182+
183183

184184
private RecipeMarketplace marketplace = new RecipeMarketplace();
185185
private List<RecipeBundleResolver> resolvers = new ArrayList<>();
@@ -222,7 +222,7 @@ public Builder dotnetPath(Path dotnetPath) {
222222
* Explicit entry point for the C# RPC server, primarily for tests.
223223
* When set, the server is launched via {@code dotnet run --project <path>}
224224
* (for {@code .csproj}) or {@code dotnet <path>} (for DLLs), bypassing
225-
* both {@code REWRITE_SOURCE_PATH} and global tool auto-install.
225+
* global tool auto-install.
226226
*/
227227
public Builder csharpServerEntry(Path csharpServerEntry) {
228228
this.csharpServerEntry = csharpServerEntry;
@@ -295,23 +295,10 @@ public CSharpRewriteRpc get() {
295295
);
296296
}
297297
} else {
298-
// If REWRITE_SOURCE_PATH is set, launch from source via dotnet run
299-
String rewriteSourcePath = System.getenv(REWRITE_SOURCE_PATH_ENV);
300-
if (rewriteSourcePath != null && !rewriteSourcePath.isEmpty()) {
301-
Path csproj = Paths.get(rewriteSourcePath)
302-
.resolve("rewrite-csharp/csharp/OpenRewrite.Tool/OpenRewrite.Tool.csproj");
303-
if (!Files.exists(csproj)) {
304-
throw new IllegalStateException(
305-
REWRITE_SOURCE_PATH_ENV + " is set to " + rewriteSourcePath +
306-
" but " + csproj + " does not exist");
307-
}
308-
cmd = buildCsprojCommand(csproj);
309-
} else {
310-
// Run via dotnet tool exec with the pinned version from the build
311-
String version = StringUtils.readFully(
312-
CSharpRewriteRpc.class.getResourceAsStream("/META-INF/rewrite-csharp-version.txt")).trim();
313-
cmd = buildToolExecCommand(version);
314-
}
298+
// Run via dotnet tool exec with the pinned version from the build
299+
String version = StringUtils.readFully(
300+
CSharpRewriteRpc.class.getResourceAsStream("/META-INF/rewrite-csharp-version.txt")).trim();
301+
cmd = buildToolExecCommand(version);
315302
}
316303

317304
return startProcess(cmd);

0 commit comments

Comments
 (0)