fix possible NPE

This commit is contained in:
James Strachan
2012-05-31 09:38:26 +01:00
parent f7b9dab9f7
commit 57ffb91514
@@ -45,6 +45,7 @@ public class JSSourceJarMojo extends AbstractMojo {
@Override @Override
public void execute() throws MojoExecutionException, MojoFailureException { public void execute() throws MojoExecutionException, MojoFailureException {
if (librarySourceDir != null) {
if (!librarySourceDir.exists()) { if (!librarySourceDir.exists()) {
getLog().warn("Source directory does not exist: " + librarySourceDir); getLog().warn("Source directory does not exist: " + librarySourceDir);
} else { } else {
@@ -62,7 +63,11 @@ public class JSSourceJarMojo extends AbstractMojo {
throw new MojoFailureException(e.getMessage(), e); throw new MojoFailureException(e.getMessage(), e);
} }
} }
if (definitionSourceDir.exists()) { }
if (definitionSourceDir != null) {
if (!librarySourceDir.exists()) {
getLog().warn("Definition directory does not exist: " + definitionSourceDir);
} else {
try { try {
File metaInfFile = new File(outputDir, ClassPathLibraryDefintionsConfig.META_INF_SERVICES_FILE); File metaInfFile = new File(outputDir, ClassPathLibraryDefintionsConfig.META_INF_SERVICES_FILE);
metaInfFile.getParentFile().mkdirs(); metaInfFile.getParentFile().mkdirs();
@@ -78,6 +83,7 @@ public class JSSourceJarMojo extends AbstractMojo {
} }
} }
} }
}
private void appendSourceFiles(PrintWriter writer, String rootPath, File currentDir) throws IOException { private void appendSourceFiles(PrintWriter writer, String rootPath, File currentDir) throws IOException {
File[] files = currentDir.listFiles(); File[] files = currentDir.listFiles();