Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 57dfc26

Browse filesBrowse files
committed
Path.relativize() may throw exception if source and build directories are on different Windows drives
Closes #364
1 parent 2248255 commit 57dfc26
Copy full SHA for 57dfc26

File tree

Expand file treeCollapse file tree

1 file changed

+19
-7
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+19
-7
lines changed

‎plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/AbstractCompiler.java

Copy file name to clipboardExpand all lines: plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/AbstractCompiler.java
+19-7Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -268,19 +268,31 @@ private static String getCanonicalPath(File origFile) throws CompilerException {
268268

269269
protected void logCompiling(String[] sourceFiles, CompilerConfiguration config) {
270270
if (log.isInfoEnabled()) {
271-
String to = (config.getWorkingDirectory() == null)
272-
? config.getOutputLocation()
273-
: config.getWorkingDirectory()
274-
.toPath()
275-
.relativize(new File(config.getOutputLocation()).toPath())
276-
.toString();
277271
log.info("Compiling "
278272
+ (sourceFiles == null
279273
? ""
280274
: (sourceFiles.length + " source file" + (sourceFiles.length == 1 ? " " : "s ")))
281275
+ "with "
282276
+ getCompilerId() + " [" + config.describe() + "]" + " to "
283-
+ to);
277+
+ getRelativeWorkingDirectory(config));
284278
}
285279
}
280+
281+
private static String getRelativeWorkingDirectory(CompilerConfiguration config) {
282+
String to;
283+
if (config.getWorkingDirectory() == null) {
284+
to = config.getOutputLocation();
285+
} else {
286+
try {
287+
to = config.getWorkingDirectory()
288+
.toPath()
289+
.relativize(new File(config.getOutputLocation()).toPath())
290+
.toString();
291+
} catch (IllegalArgumentException e) {
292+
// may happen on Windows if the working directory is on a different drive
293+
to = config.getOutputLocation();
294+
}
295+
}
296+
return to;
297+
}
286298
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.