in src/main/java/org/apache/maven/plugins/jdeps/AbstractJDepsMojo.java [197:246]
public void execute() throws MojoExecutionException, MojoFailureException {
if (!new File(getClassesDirectory()).exists()) {
getLog().debug("No classes to analyze");
return;
}
String jExecutable;
try {
jExecutable = getJDepsExecutable();
} catch (IOException e) {
throw new MojoFailureException("Unable to find jdeps command: " + e.getMessage(), e);
}
// Synopsis
// jdeps [options] classes ...
Commandline cmd = new Commandline();
cmd.setExecutable(jExecutable);
Set<Path> dependenciesToAnalyze = null;
try {
dependenciesToAnalyze = getDependenciesToAnalyze(includeClasspath);
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
addJDepsOptions(cmd, dependenciesToAnalyze);
addJDepsClasses(cmd, dependenciesToAnalyze);
JDepsConsumer consumer = new JDepsConsumer();
executeJDepsCommandLine(cmd, outputDirectory, consumer);
// @ TODO if there will be more goals, this should be pushed down to AbstractJDKInternals
if (!consumer.getOffendingPackages().isEmpty()) {
final String ls = System.lineSeparator();
StringBuilder msg = new StringBuilder();
msg.append("Found offending packages:").append(ls);
for (Map.Entry<String, String> offendingPackage :
consumer.getOffendingPackages().entrySet()) {
msg.append(' ')
.append(offendingPackage.getKey())
.append(" -> ")
.append(offendingPackage.getValue())
.append(ls);
}
if (isFailOnWarning()) {
throw new MojoExecutionException(msg.toString());
}
}
}