Skip to content

Commit

Permalink
Merge pull request #17 from atdixon/cp-includes-path-exceptions
Browse files Browse the repository at this point in the history
#18 Include path exceptions at end of cp
  • Loading branch information
José Pereda authored Jun 18, 2019
2 parents 0c4e010 + 6e610bd commit 25a0b89
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ Optionally, the configuration can be modified with:
- `outputFile` File to redirect the process output
- `options`: A list of VM options passed to the executable.
- `commandlineArgs`: Arguments separated by space for the executed program
- `includePathExceptionsInClasspath`: When resolving the module-path, setting this value to true will include the
dependencies that generate path exceptions in the classpath. By default the value is false, and these dependencies
won't be included.

For instance, the following configuration adds some VM options and a command line argument:

Expand Down
29 changes: 23 additions & 6 deletions src/main/java/org/openjfx/JavaFXBaseMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ abstract class JavaFXBaseMojo extends AbstractMojo {
@Parameter(property = "javafx.release", defaultValue = "11")
private String release;

@Parameter(property = "javafx.includePathExceptionsInClasspath", defaultValue = "false")
private boolean includePathExceptionsInClasspath;

List<String> classpathElements;
List<String> modulepathElements;
Map<String, JavaModuleDescriptor> pathElements;
Expand Down Expand Up @@ -195,13 +198,22 @@ void preparePaths() throws MojoExecutionException, MojoFailureException {
}
resolvePathsResult = locationManager.resolvePaths(fileResolvePathsRequest);

for (Map.Entry<File, Exception> pathException : resolvePathsResult.getPathExceptions().entrySet()) {
Throwable cause = pathException.getValue();
while (cause.getCause() != null) {
cause = cause.getCause();
if (!resolvePathsResult.getPathExceptions().isEmpty()) {
// for each path exception, show a warning to plugin user...
for (Map.Entry<File, Exception> pathException : resolvePathsResult.getPathExceptions().entrySet()) {
Throwable cause = pathException.getValue();
while (cause.getCause() != null) {
cause = cause.getCause();
}
String fileName = pathException.getKey().getName();
getLog().warn("Can't extract module name from " + fileName + ": " + cause.getMessage());
}
// ...if includePathExceptionsInClasspath is NOT enabled; provide configuration hint to plugin user
if (!includePathExceptionsInClasspath) {
getLog().warn("Some dependencies encountered issues while attempting to be resolved as modules" +
" and will not be included in the classpath; you can change this behavior via the " +
" 'includePathExceptionsInClasspath' configuration parameter.");
}
String fileName = pathException.getKey().getName();
getLog().warn("Can't extract module name from " + fileName + ": " + cause.getMessage());
}

if (moduleDescriptorPath != null) {
Expand Down Expand Up @@ -234,6 +246,11 @@ void preparePaths() throws MojoExecutionException, MojoFailureException {
resolvePathsResult.getModulepathElements().keySet()
.forEach(file -> modulepathElements.add(file.getPath()));

if (includePathExceptionsInClasspath) {
resolvePathsResult.getPathExceptions().keySet()
.forEach(file -> classpathElements.add(file.getPath()));
}

if (moduleDescriptorPath == null) {
pathElements.forEach((k, v) -> {
if (v != null && v.name() != null) {
Expand Down

0 comments on commit 25a0b89

Please sign in to comment.