excluding deps that are children of provided deps
This commit is contained in:
@@ -27,6 +27,7 @@ public class AmpDependencyFilter implements DependencyFilter {
|
||||
|
||||
private final Pattern modulePropertiesPattern = Pattern.compile("^alfresco/module/[^/]+/module\\.properties$");
|
||||
private final String moduleExtension = "amp";
|
||||
private final Set<String> ignoreDependenciesOfParentScopes = new HashSet<>(Arrays.asList("provided", "system"));
|
||||
|
||||
private final int streamBufferSize = 16 * 1024;
|
||||
private final Log log;
|
||||
@@ -65,16 +66,22 @@ public class AmpDependencyFilter implements DependencyFilter {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.isOrIsInAlfrescoModule(moduleId, node, parents.iterator())) {
|
||||
try {
|
||||
if (this.isOrIsInAlfrescoModule(moduleId, 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;
|
||||
}
|
||||
} catch (NotInScopeException nise) {
|
||||
if (this.log.isDebugEnabled())
|
||||
this.log.debug("Not packaging library; detected as Alfresco Module or as dependency to other Alfresco Module: " + artifact.getArtifactId());
|
||||
this.log.debug("Not packaging library; detected as provided by another dependency [" + nise.getNotInScopeParentArtifact() + "]: " + artifact.getArtifactId());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean isOrIsInAlfrescoModule(String moduleId, DependencyNode moduleNode, Iterator<DependencyNode> parents) {
|
||||
private boolean isOrIsInAlfrescoModule(String moduleId, DependencyNode moduleNode, Iterator<DependencyNode> parents) throws NotInScopeException {
|
||||
Artifact artifact = moduleNode.getArtifact();
|
||||
|
||||
if (this.projectModuleId.equals(moduleId)) {
|
||||
@@ -87,7 +94,13 @@ public class AmpDependencyFilter implements DependencyFilter {
|
||||
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());
|
||||
|
||||
if (this.isOrIsInAlfrescoModule(parentModuleId, parentNode, parents)) {
|
||||
if (this.log.isDebugEnabled())
|
||||
this.log.debug("Detected as dependency to other Alfresco Module: " + artifact.getArtifactId());
|
||||
|
@@ -0,0 +1,26 @@
|
||||
package com.inteligr8.alfresco.amp;
|
||||
|
||||
import org.eclipse.aether.artifact.Artifact;
|
||||
|
||||
public class NotInScopeException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 8055701654626788700L;
|
||||
|
||||
private Artifact notInScopeParentArtifact;
|
||||
private Artifact impactedChildArtifact;
|
||||
|
||||
public NotInScopeException(Artifact notInScopeParentArtifact, Artifact impactedChildArtifact) {
|
||||
super("The '" + notInScopeParentArtifact.getArtifactId() + "' artifact is not scope, impacting the '" + impactedChildArtifact.getArtifactId() + "' artifact");
|
||||
this.notInScopeParentArtifact = notInScopeParentArtifact;
|
||||
this.impactedChildArtifact = impactedChildArtifact;
|
||||
}
|
||||
|
||||
public Artifact getNotInScopeParentArtifact() {
|
||||
return this.notInScopeParentArtifact;
|
||||
}
|
||||
|
||||
public Artifact getImpactedChildArtifact() {
|
||||
return this.impactedChildArtifact;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user