diff --git a/pom.xml b/pom.xml index 7538310..54a6976 100644 --- a/pom.xml +++ b/pom.xml @@ -238,6 +238,7 @@ jar public + false diff --git a/src/main/java/com/inteligr8/wildfly/maven/IndexingDependencyGraphTransformer.java b/src/main/java/com/inteligr8/wildfly/maven/IndexingDependencyGraphTransformer.java index bdc82a8..e01b632 100644 --- a/src/main/java/com/inteligr8/wildfly/maven/IndexingDependencyGraphTransformer.java +++ b/src/main/java/com/inteligr8/wildfly/maven/IndexingDependencyGraphTransformer.java @@ -44,6 +44,12 @@ public class IndexingDependencyGraphTransformer implements DependencyGraphTransf this.dindex = dindex; } + /** + * This method is basically an intercepter for the default + * DependencyGraphTransformer. It will make the call to perform the + * default expected functions. But before that, it will crawl the + * dependencies to index them. + */ @Override public DependencyNode transformGraph(DependencyNode node, DependencyGraphTransformationContext context) throws RepositoryException { this.crawl(node, new Stack()); @@ -51,6 +57,12 @@ public class IndexingDependencyGraphTransformer implements DependencyGraphTransf return this.transfomer.transformGraph(node, context); } + /** + * This method crawls a dependency and its dependencies, recursively. + * + * @param node A dependency. + * @param ancestors A stack of ancestral artifacts; parent on top; root on bottom; empty if root. + */ private void crawl(DependencyNode node, Stack ancestors) { this.index(node, Collections.unmodifiableList(ancestors)); @@ -60,6 +72,15 @@ public class IndexingDependencyGraphTransformer implements DependencyGraphTransf ancestors.pop(); } + /** + * This method indexes a dependency. + * + * If a dependency encountered more than once, any occurrence inside a + * system module will take precedence; then a non-system module. + * + * @param node A dependency. + * @param parents A list of ancestral artifacts; parent is last; root is first; empty if root/self. + */ public void index(DependencyNode node, List parents) { String nodeId = this.dindex.toId(node); DependencyType type = this.dindex.getType(nodeId); @@ -71,6 +92,13 @@ public class IndexingDependencyGraphTransformer implements DependencyGraphTransf this.dindex.index(node); + if (parents == null || parents.isEmpty()) { + // root element; the project itself + // even if it is a module, we aren't going to consider it one in this context + this.dindex.indexType(nodeId, DependencyType.Self); + return; + } + for (DependencyNode ancestor : parents) { String ancestorId = this.dindex.toId(ancestor); type = this.dindex.getType(ancestorId); @@ -95,13 +123,6 @@ public class IndexingDependencyGraphTransformer implements DependencyGraphTransf } } - if (parents == null || parents.isEmpty()) { - // root element; the project itself - // even if it is a module, we aren't going to consider it one in this context - this.dindex.indexType(nodeId, DependencyType.Self); - return; - } - ModuleArtifactExtractor extractor = new ModuleArtifactExtractor(this.dac); try { Module module = extractor.extract(node.getArtifact()); diff --git a/src/main/java/com/inteligr8/wildfly/maven/goal/AbstractGoal.java b/src/main/java/com/inteligr8/wildfly/maven/goal/AbstractGoal.java index 067bd53..3decb26 100644 --- a/src/main/java/com/inteligr8/wildfly/maven/goal/AbstractGoal.java +++ b/src/main/java/com/inteligr8/wildfly/maven/goal/AbstractGoal.java @@ -109,6 +109,10 @@ public abstract class AbstractGoal extends DisablableGoal implements DependencyA this.executePost(); } + /** + * This method creates a Maven RepositorySystemSession that is able to load + * our DependencyIndex. + */ private RepositorySystemSession injectSession(DependencyIndex dindex) { DefaultRepositorySystemSession session = new DefaultRepositorySystemSession(this.session.getRepositorySession()); DependencyGraphTransformer transformer = session.getDependencyGraphTransformer();