Skip to content

Commit

Permalink
Merge pull request quarkusio#5808 from jaikiran/devmode-jar-cp
Browse files Browse the repository at this point in the history
Use "file" scheme absolute URIs for "Class-Path" entries we create in our -dev.jar
  • Loading branch information
dmlloyd authored Dec 1, 2019
2 parents f0d665b + 0be50b2 commit 6873b49
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
17 changes: 12 additions & 5 deletions core/devmode/src/main/java/io/quarkus/dev/ClassLoaderCompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,19 @@ public ClassLoaderCompiler(ClassLoader classLoader,
}
Object classPath = mf.getMainAttributes().get(Attributes.Name.CLASS_PATH);
if (classPath != null) {
for (String i : WHITESPACE_PATTERN.split(classPath.toString())) {
for (String classPathEntry : WHITESPACE_PATTERN.split(classPath.toString())) {
final URI cpEntryURI = new URI(classPathEntry);
File f;
try {
f = Paths.get(new URI("file", null, "/", null).resolve(new URI(i))).toFile();
} catch (URISyntaxException e) {
f = new File(file.getParentFile(), i);
// if it's a "file" scheme URI, then use the path as a file system path
// without the need to resolve it
if (cpEntryURI.isAbsolute() && cpEntryURI.getScheme().equals("file")) {
f = new File(cpEntryURI.getPath());
} else {
try {
f = Paths.get(new URI("file", null, "/", null).resolve(cpEntryURI)).toFile();
} catch (URISyntaxException e) {
f = new File(file.getParentFile(), classPathEntry);
}
}
if (f.exists()) {
toParse.add(f.getAbsolutePath());
Expand Down
15 changes: 2 additions & 13 deletions devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
import io.quarkus.bootstrap.resolver.BootstrapAppModelResolver;
import io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver;
import io.quarkus.bootstrap.resolver.maven.workspace.LocalProject;
import io.quarkus.bootstrap.util.PropertyUtils;
import io.quarkus.dev.DevModeContext;
import io.quarkus.dev.DevModeMain;
import io.quarkus.maven.components.MavenVersionEnforcer;
Expand Down Expand Up @@ -383,23 +382,13 @@ private void addProject(DevModeContext devModeContext, LocalProject localProject
}

private void addToClassPaths(StringBuilder classPathManifest, DevModeContext classPath, File file) {
URI uri = file.toPath().toAbsolutePath().toUri();
final URI uri = file.toPath().toAbsolutePath().toUri();
try {
classPath.getClassPath().add(uri.toURL());
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
String path = uri.getRawPath();
if (PropertyUtils.isWindows()) {
if (path.length() > 2 && Character.isLetter(path.charAt(0)) && path.charAt(1) == ':') {
path = "/" + path;
}
}
classPathManifest.append(path);
if (file.isDirectory() && path.charAt(path.length() - 1) != '/') {
classPathManifest.append("/");
}
classPathManifest.append(" ");
classPathManifest.append(uri).append(" ");
}

class DevModeRunner {
Expand Down

0 comments on commit 6873b49

Please sign in to comment.