fix possible NPE
This commit is contained in:
+30
-24
@@ -45,36 +45,42 @@ public class JSSourceJarMojo extends AbstractMojo {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() throws MojoExecutionException, MojoFailureException {
|
public void execute() throws MojoExecutionException, MojoFailureException {
|
||||||
if (!librarySourceDir.exists()) {
|
if (librarySourceDir != null) {
|
||||||
getLog().warn("Source directory does not exist: " + librarySourceDir);
|
if (!librarySourceDir.exists()) {
|
||||||
} else {
|
getLog().warn("Source directory does not exist: " + librarySourceDir);
|
||||||
try {
|
} else {
|
||||||
File metaInfFile = new File(outputDir, ClassPathLibrarySourcesLoader.META_INF_SERVICES_FILE);
|
try {
|
||||||
metaInfFile.getParentFile().mkdirs();
|
File metaInfFile = new File(outputDir, ClassPathLibrarySourcesLoader.META_INF_SERVICES_FILE);
|
||||||
|
metaInfFile.getParentFile().mkdirs();
|
||||||
|
|
||||||
FileUtils.copyDirectoryStructure(librarySourceDir, outputDir);
|
FileUtils.copyDirectoryStructure(librarySourceDir, outputDir);
|
||||||
|
|
||||||
// now lets generate the META-INF/services/org.jetbrains.kotlin.js.librarySource file
|
// now lets generate the META-INF/services/org.jetbrains.kotlin.js.librarySource file
|
||||||
PrintWriter writer = new PrintWriter(new FileWriter(metaInfFile));
|
PrintWriter writer = new PrintWriter(new FileWriter(metaInfFile));
|
||||||
appendSourceFiles(writer, outputDir.getCanonicalPath(), outputDir);
|
appendSourceFiles(writer, outputDir.getCanonicalPath(), outputDir);
|
||||||
writer.close();
|
writer.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new MojoFailureException(e.getMessage(), e);
|
throw new MojoFailureException(e.getMessage(), e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (definitionSourceDir.exists()) {
|
if (definitionSourceDir != null) {
|
||||||
try {
|
if (!librarySourceDir.exists()) {
|
||||||
File metaInfFile = new File(outputDir, ClassPathLibraryDefintionsConfig.META_INF_SERVICES_FILE);
|
getLog().warn("Definition directory does not exist: " + definitionSourceDir);
|
||||||
metaInfFile.getParentFile().mkdirs();
|
} else {
|
||||||
|
try {
|
||||||
|
File metaInfFile = new File(outputDir, ClassPathLibraryDefintionsConfig.META_INF_SERVICES_FILE);
|
||||||
|
metaInfFile.getParentFile().mkdirs();
|
||||||
|
|
||||||
FileUtils.copyDirectoryStructure(definitionSourceDir, outputDir);
|
FileUtils.copyDirectoryStructure(definitionSourceDir, outputDir);
|
||||||
|
|
||||||
// now lets generate the META-INF/services/org.jetbrains.kotlin.js.libraryDefinitions file
|
// now lets generate the META-INF/services/org.jetbrains.kotlin.js.libraryDefinitions file
|
||||||
PrintWriter writer = new PrintWriter(new FileWriter(metaInfFile));
|
PrintWriter writer = new PrintWriter(new FileWriter(metaInfFile));
|
||||||
appendSourceFiles(writer, definitionSourceDir.getCanonicalPath(), definitionSourceDir);
|
appendSourceFiles(writer, definitionSourceDir.getCanonicalPath(), definitionSourceDir);
|
||||||
writer.close();
|
writer.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new MojoFailureException(e.getMessage(), e);
|
throw new MojoFailureException(e.getMessage(), e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user