fixed NPE
This commit is contained in:
@@ -60,14 +60,14 @@ public class AmpDependencyFilter implements DependencyFilter {
|
||||
if (this.log.isDebugEnabled())
|
||||
this.log.debug("Checking dependency: " + artifact.getArtifactId());
|
||||
|
||||
String moduleId = this.getModuleId(artifact);
|
||||
if (this.projectModuleId.equals(moduleId)) {
|
||||
String possibleModuleId = this.getModuleId(artifact);
|
||||
if (this.projectModuleId.equals(possibleModuleId)) {
|
||||
// always include project itself, even if it is a module
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
if (this.isOrIsInAlfrescoModule(moduleId, node, parents.iterator())) {
|
||||
if (this.isOrIsInAlfrescoModule(possibleModuleId, node, parents.iterator())) {
|
||||
if (this.log.isDebugEnabled())
|
||||
this.log.debug("Not packaging library; detected as Alfresco Module or as dependency to other Alfresco Module: " + artifact.getArtifactId());
|
||||
return false;
|
||||
@@ -81,22 +81,21 @@ public class AmpDependencyFilter implements DependencyFilter {
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean isOrIsInAlfrescoModule(String moduleId, DependencyNode moduleNode, Iterator<DependencyNode> parents) throws NotInScopeException {
|
||||
Artifact artifact = moduleNode.getArtifact();
|
||||
private boolean isOrIsInAlfrescoModule(String possibleModuleId, DependencyNode depNode, Iterator<DependencyNode> parents) throws NotInScopeException {
|
||||
Artifact artifact = depNode.getArtifact();
|
||||
|
||||
if (this.projectModuleId.equals(moduleId)) {
|
||||
if (this.projectModuleId.equals(possibleModuleId)) {
|
||||
return false;
|
||||
} else if (this.moduleIds.contains(moduleId)) {
|
||||
} else if (depNode.getDependency() != null && this.ignoreDependenciesOfParentScopes.contains(depNode.getDependency().getScope())) {
|
||||
throw new NotInScopeException(artifact);
|
||||
} else if (this.moduleIds.contains(possibleModuleId)) {
|
||||
if (this.log.isDebugEnabled())
|
||||
this.log.debug("Detected as Alfresco Module: " + artifact.getArtifactId());
|
||||
return true;
|
||||
} else if (this.notModuleIds.contains(moduleId)) {
|
||||
} else if (this.notModuleIds.contains(possibleModuleId)) {
|
||||
return false;
|
||||
} else if (parents != null && parents.hasNext()) {
|
||||
DependencyNode parentNode = parents.next();
|
||||
if (this.ignoreDependenciesOfParentScopes.contains(parentNode.getDependency().getScope()))
|
||||
throw new NotInScopeException(parentNode.getArtifact(), artifact);
|
||||
|
||||
String parentModuleId = this.getModuleId(parentNode.getArtifact());
|
||||
if (this.log.isDebugEnabled())
|
||||
this.log.debug("Checking parent dependency: " + artifact.getArtifactId());
|
||||
@@ -109,16 +108,16 @@ public class AmpDependencyFilter implements DependencyFilter {
|
||||
}
|
||||
|
||||
// never seen this artifact or its parents
|
||||
return this.isAlfrescoModule(moduleId, moduleNode);
|
||||
return this.isAlfrescoModule(possibleModuleId, depNode);
|
||||
}
|
||||
|
||||
private boolean isAlfrescoModule(String moduleId, DependencyNode moduleNode) {
|
||||
Artifact artifact = moduleNode.getArtifact();
|
||||
private boolean isAlfrescoModule(String possibleModuleId, DependencyNode depNode) {
|
||||
Artifact artifact = depNode.getArtifact();
|
||||
|
||||
if (this.moduleExtension.equalsIgnoreCase(artifact.getExtension())) {
|
||||
if (this.log.isDebugEnabled())
|
||||
this.log.debug("Detected as Alfresco Module: " + artifact.getArtifactId());
|
||||
this.moduleIds.add(moduleId);
|
||||
this.moduleIds.add(possibleModuleId);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -127,7 +126,7 @@ public class AmpDependencyFilter implements DependencyFilter {
|
||||
if (file == null) {
|
||||
if (this.log.isDebugEnabled())
|
||||
this.log.debug("Resolving dependency to get file: " + artifact.getArtifactId());
|
||||
ArtifactResult result = this.callback.resolveArtifact(new ArtifactRequest(moduleNode));
|
||||
ArtifactResult result = this.callback.resolveArtifact(new ArtifactRequest(depNode));
|
||||
if (result.isMissing() || !result.isResolved())
|
||||
throw new ArtifactResolutionException(Arrays.asList(result));
|
||||
artifact = result.getArtifact();
|
||||
@@ -137,13 +136,13 @@ public class AmpDependencyFilter implements DependencyFilter {
|
||||
this.log.debug("Checking dependency file: " + file);
|
||||
|
||||
if (this.isAlfrescoModuleJar(file)) {
|
||||
this.moduleIds.add(moduleId);
|
||||
this.moduleIds.add(possibleModuleId);
|
||||
if (this.log.isInfoEnabled())
|
||||
this.log.info("Detected as Alfresco Module: " + artifact.getArtifactId());
|
||||
return true;
|
||||
}
|
||||
|
||||
this.notModuleIds.add(moduleId);
|
||||
this.notModuleIds.add(possibleModuleId);
|
||||
return false;
|
||||
} catch (ArtifactResolutionException are) {
|
||||
this.log.warn("An artifact could not be resolved; assuming it is not an Alfresco module and continuing");
|
||||
|
||||
@@ -6,9 +6,14 @@ public class NotInScopeException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 8055701654626788700L;
|
||||
|
||||
private Artifact notInScopeParentArtifact;
|
||||
private final Artifact notInScopeParentArtifact;
|
||||
private Artifact impactedChildArtifact;
|
||||
|
||||
public NotInScopeException(Artifact notInScopeParentArtifact) {
|
||||
super("The '" + notInScopeParentArtifact.getArtifactId() + "' artifact is not scope");
|
||||
this.notInScopeParentArtifact = notInScopeParentArtifact;
|
||||
}
|
||||
|
||||
public NotInScopeException(Artifact notInScopeParentArtifact, Artifact impactedChildArtifact) {
|
||||
super("The '" + notInScopeParentArtifact.getArtifactId() + "' artifact is not scope, impacting the '" + impactedChildArtifact.getArtifactId() + "' artifact");
|
||||
this.notInScopeParentArtifact = notInScopeParentArtifact;
|
||||
|
||||
Reference in New Issue
Block a user