fix bug in getLastProject for non-site executions

This commit is contained in:
Jeremy Long
2016-03-06 17:28:40 -05:00
parent a19dd7687e
commit e51031c62a
3 changed files with 21 additions and 4 deletions

View File

@@ -128,7 +128,7 @@ public class AggregateMojo extends BaseDependencyCheckMojo {
/**
* Gets the last project in the reactor - taking into account skipped projects.
*
* @return the last projecct in the reactor
* @return the last project in the reactor
*/
private MavenProject getLastProject() {
for (int x = getReactorProjects().size() - 1; x >= 0; x--) {
@@ -149,7 +149,7 @@ public class AggregateMojo extends BaseDependencyCheckMojo {
*/
private boolean skipProject(MavenProject project) {
final String skip = (String) project.getProperties().get("maven.site.skip");
return "true".equalsIgnoreCase(skip);
return "true".equalsIgnoreCase(skip) && isGeneratingSite();
}
/**

View File

@@ -387,6 +387,7 @@ public abstract class BaseDependencyCheckMojo extends AbstractMojo implements Ma
*/
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
generatingSite = false;
if (skip) {
getLog().info("Skipping " + getName(Locale.US));
} else {
@@ -424,6 +425,20 @@ public abstract class BaseDependencyCheckMojo extends AbstractMojo implements Ma
generate((Sink) sink, locale);
}
/**
* A flag indicating whether or not the maven site is being generated.
*/
private boolean generatingSite = false;
/**
* Returns true if the Maven site is being generated.
*
* @return true if the Maven site is being generated
*/
protected boolean isGeneratingSite() {
return generatingSite;
}
/**
* Generates the Dependency-Check Site Report.
*
@@ -432,6 +447,7 @@ public abstract class BaseDependencyCheckMojo extends AbstractMojo implements Ma
* @throws MavenReportException if a maven report exception occurs
*/
public void generate(Sink sink, Locale locale) throws MavenReportException {
generatingSite = true;
try {
validateAggregate();
} catch (MojoExecutionException ex) {
@@ -1054,7 +1070,8 @@ public abstract class BaseDependencyCheckMojo extends AbstractMojo implements Ma
"org.owasp.dependencycheck.dependency.Reference",
"org.owasp.dependencycheck.dependency.Vulnerability",
"org.owasp.dependencycheck.dependency.VulnerabilityComparator",
"org.owasp.dependencycheck.dependency.VulnerableSoftware");
"org.owasp.dependencycheck.dependency.VulnerableSoftware",
"org.owasp.dependencycheck.data.cpe.IndexEntry");
ret = (List<Dependency>) ois.readObject();
} catch (FileNotFoundException ex) {
//TODO fix logging

View File

@@ -63,7 +63,7 @@ public class ExpectedOjectInputStream extends ObjectInputStream {
@Override
protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {
if (!this.expected.contains(desc.getName())) {
throw new InvalidClassException("Unexpected deserialization", desc.getName());
throw new InvalidClassException("Unexpected deserialization ", desc.getName());
}
return super.resolveClass(desc);
}