additional checks added as part of issue #257

Former-commit-id: 9a9154adcc42688f600a9a6cce49a919fd08f482
This commit is contained in:
Jeremy Long
2015-06-19 05:34:52 -04:00
parent f4ce087649
commit 63d92c62a5

View File

@@ -477,7 +477,7 @@ public abstract class BaseDependencyCheckMojo extends AbstractMojo implements Ma
d.addProjectReference(project.getName()); d.addProjectReference(project.getName());
if (getLog().isDebugEnabled()) { if (getLog().isDebugEnabled()) {
getLog().debug(String.format("Adding project reference %s on dependency %s", project.getName(), getLog().debug(String.format("Adding project reference %s on dependency %s", project.getName(),
d.getDisplayFileName())); d.getDisplayFileName()));
} }
if (metadataSource != null) { if (metadataSource != null) {
try { try {
@@ -508,7 +508,7 @@ public abstract class BaseDependencyCheckMojo extends AbstractMojo implements Ma
} else { } else {
if (getLog().isDebugEnabled()) { if (getLog().isDebugEnabled()) {
final String msg = String.format("More then 1 dependency was identified in first pass scan of '%s:%s:%s'", final String msg = String.format("More then 1 dependency was identified in first pass scan of '%s:%s:%s'",
a.getGroupId(), a.getArtifactId(), a.getVersion()); a.getGroupId(), a.getArtifactId(), a.getVersion());
getLog().debug(msg); getLog().debug(msg);
} }
} }
@@ -638,7 +638,7 @@ public abstract class BaseDependencyCheckMojo extends AbstractMojo implements Ma
Settings.setBoolean(Settings.KEYS.AUTO_UPDATE, autoUpdate); Settings.setBoolean(Settings.KEYS.AUTO_UPDATE, autoUpdate);
if (externalReport != null) { if (externalReport != null) {
getLog().warn("The 'externalReport' option was set; this configuration option has been removed. " getLog().warn("The 'externalReport' option was set; this configuration option has been removed. "
+ "Please update the dependency-check-maven plugin's configuration"); + "Please update the dependency-check-maven plugin's configuration");
} }
if (proxyUrl != null && !proxyUrl.isEmpty()) { if (proxyUrl != null && !proxyUrl.isEmpty()) {
@@ -750,7 +750,7 @@ public abstract class BaseDependencyCheckMojo extends AbstractMojo implements Ma
return proxies.get(0); return proxies.get(0);
} else { } else {
getLog().warn("Multiple proxy definitions exist in the Maven settings. In the dependency-check " getLog().warn("Multiple proxy definitions exist in the Maven settings. In the dependency-check "
+ "configuration set the mavenSettingsProxyId so that the correct proxy will be used."); + "configuration set the mavenSettingsProxyId so that the correct proxy will be used.");
throw new IllegalStateException("Ambiguous proxy definition"); throw new IllegalStateException("Ambiguous proxy definition");
} }
} }
@@ -841,7 +841,7 @@ public abstract class BaseDependencyCheckMojo extends AbstractMojo implements Ma
} }
} catch (Throwable ex) { } catch (Throwable ex) {
getLog().error( getLog().error(
"Unexpected exception occurred during analysis; please see the verbose error log for more details."); "Unexpected exception occurred during analysis; please see the verbose error log for more details.");
if (getLog().isDebugEnabled()) { if (getLog().isDebugEnabled()) {
getLog().debug("", ex); getLog().debug("", ex);
} }
@@ -963,6 +963,13 @@ public abstract class BaseDependencyCheckMojo extends AbstractMojo implements Ma
} else { } else {
file = new File(writeTo, dataFileName); file = new File(writeTo, dataFileName);
} }
File parent = file.getParentFile();
if (!parent.isDirectory()) {
if (parent.mkdirs()) {
getLog().error(String.format("Directory '%s' does not exist and cannot be created; unable to write data file.", parent.getAbsolutePath()));
}
}
OutputStream os = null; OutputStream os = null;
OutputStream bos = null; OutputStream bos = null;
ObjectOutputStream out = null; ObjectOutputStream out = null;
@@ -980,7 +987,7 @@ public abstract class BaseDependencyCheckMojo extends AbstractMojo implements Ma
} }
if (getLog().isDebugEnabled()) { if (getLog().isDebugEnabled()) {
getLog().debug(String.format("Serialized data file written to '%s' for %s, referenced by key %s", getLog().debug(String.format("Serialized data file written to '%s' for %s, referenced by key %s",
file.getAbsolutePath(), mp.getName(), this.getDataFileContextKey())); file.getAbsolutePath(), mp.getName(), this.getDataFileContextKey()));
} }
mp.setContextValue(this.getDataFileContextKey(), file.getAbsolutePath()); mp.setContextValue(this.getDataFileContextKey(), file.getAbsolutePath());
} catch (IOException ex) { } catch (IOException ex) {