Skip to content

Commit

Permalink
Fix path encoding issue in window
Browse files Browse the repository at this point in the history
Change-Id: I063eb71165f0caf76364845623592e7b0979c270
  • Loading branch information
ngyukman committed Mar 1, 2023
1 parent 1cb7700 commit 974e476
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ subprojects {
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

group = "co.paralleluniverse"
version = "1.0.4-ullink3"
version = "1.0.4-ullink4"
status = "integration"
description = "Simple Java deployment"
ext.url = "https://github.com/puniverse/capsule"
Expand Down
22 changes: 6 additions & 16 deletions capsule/src/main/java/Capsule.java
Original file line number Diff line number Diff line change
Expand Up @@ -5429,10 +5429,8 @@ private List<Path> handleLongClasspath(List<Path> cp, int extra, List<?>... args
// visible for testing
static Path createPathingJar(Path dir, List<Path> cp) {
try {
dir = dir.toAbsolutePath();
final List<String> paths = createPathingClassPath(dir, cp);

final Path pathingJar = Files.createTempFile(dir, "capsule_pathing_jar", ".jar");
final List<String> paths = createPathingClassPath(cp);
final Path pathingJar = Files.createTempFile(dir.toAbsolutePath(), "capsule_pathing_jar", ".jar");
final Manifest man = new Manifest();
man.getMainAttributes().putValue(ATTR_MANIFEST_VERSION, "1.0");
man.getMainAttributes().putValue(ATTR_CLASS_PATH, join(paths, " "));
Expand All @@ -5444,19 +5442,11 @@ static Path createPathingJar(Path dir, List<Path> cp) {
}
}

private static List<String> createPathingClassPath(Path dir, List<Path> cp) {
boolean allPathsHaveSameRoot = true;
for (Path p : cp) {
if (!dir.getRoot().equals(p.getRoot()))
allPathsHaveSameRoot = false;
}

private static List<String> createPathingClassPath(List<Path> cp) {
final List<String> paths = new ArrayList<>(cp.size());
for (Path p : cp) { // In order to use the Class-Path attribute, we must either relativize the paths, or specifiy them as file URLs
if (allPathsHaveSameRoot)
paths.add(dir.relativize(p).toString());
else
paths.add(p.toUri().toString());
for (Path p : cp) { // In order to use the Class-Path attribute, we must either relativize the paths, or specify them as file URLs
// always use absolute path to avoid encoding issue
paths.add(p.toUri().toString());
}
return paths;
}
Expand Down

0 comments on commit 974e476

Please sign in to comment.