Skip to content

Commit

Permalink
Merge pull request #41997 from gabilang/fix-profiler-path-windows
Browse files Browse the repository at this point in the history
Fix path related issues in windows with 'Path.toUri()' method
  • Loading branch information
warunalakshitha authored Mar 13, 2024
2 parents b662ccd + 430a84c commit 24713af
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public class RunProfilerTask implements Task {
private final PrintStream err;
private static final String JAVA_OPTS = "JAVA_OPTS";
private static final String CURRENT_DIR_KEY = "current.dir";
private static final Path TARGET_OUTPUT_PATH = Paths.get(System.getProperty(USER_DIR));

public RunProfilerTask(PrintStream errStream) {
this.err = errStream;
Expand Down Expand Up @@ -110,8 +111,8 @@ public void execute(Project project) {
private String getAgentArgs() {
// add jacoco agent
String jacocoArgLine = "-javaagent:" + Paths.get(System.getProperty(BALLERINA_HOME), "bre", "lib",
"jacocoagent.jar") + "=destfile=" + Paths.get(System.getProperty(USER_DIR))
.resolve("build").resolve("jacoco").resolve("test.exec");
"jacocoagent.jar") + "=destfile=" + TARGET_OUTPUT_PATH.resolve("build").resolve("jacoco")
.resolve("test.exec");
return jacocoArgLine + " ";
}

Expand All @@ -130,17 +131,17 @@ private Path getProfilerPath(Project project) {

private Path getTargetPath(Project project) {
if (project.kind() == ProjectKind.SINGLE_FILE_PROJECT) {
return Paths.get(System.getProperty(USER_DIR));
return TARGET_OUTPUT_PATH;
}
return project.targetDir();
}

private String getTargetFilePath(Project project) {
if (project.kind() == ProjectKind.SINGLE_FILE_PROJECT) {
return Paths.get(System.getProperty(USER_DIR)).resolve(
getFileNameWithoutExtension(project.sourceRoot()) + BLANG_COMPILED_JAR_EXT).toUri().getPath();
return Path.of(TARGET_OUTPUT_PATH.resolve(getFileNameWithoutExtension(project.sourceRoot()) +
BLANG_COMPILED_JAR_EXT).toUri()).toString();
}
return project.targetDir().resolve("bin").resolve(project.currentPackage().packageName() +
BLANG_COMPILED_JAR_EXT).toUri().getPath();
return Path.of(project.targetDir().resolve("bin").resolve(project.currentPackage().packageName() +
BLANG_COMPILED_JAR_EXT).toUri()).toString();
}
}

0 comments on commit 24713af

Please sign in to comment.