Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ protected boolean validate(
rootFailed = !validate(artifact);
}
StringBuilder childMessageBuilder = new StringBuilder();
if (rootFailed
|| !node.getChildren().stream()
if (!node.getChildren().stream()
.map(childNode -> validate(childNode, level + 1, childMessageBuilder, visitedArtifacts))
.reduce(true, Boolean::logicalAnd)) {
.reduce(true, Boolean::logicalAnd)
|| rootFailed) {
messageBuilder
.append(StringUtils.repeat(" ", level))
.append(ArtifactUtils.toArtifact(node).getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,39 @@ void excludesAndIncludesUseTransitiveDependencies() throws Exception {
.hasMessageNotContaining("childAB");
}

@Test
void excludesReportsRootAndTransitiveDependencies() throws Exception {

when(resolverUtil.resolveTransitiveDependenciesVerbose(anyList()))
.thenReturn(new DependencyNodeBuilder()
.withType(DependencyNodeBuilder.Type.POM)
.withChildNode(new DependencyNodeBuilder()
.withArtifactId("childA")
.withVersion("1.0.0")
.withChildNode(new DependencyNodeBuilder()
.withType(DependencyNodeBuilder.Type.WAR)
.withArtifactId("childAA")
.withVersion("1.0.0-SNAPSHOT")
.withChildNode(new DependencyNodeBuilder()
.withType(DependencyNodeBuilder.Type.WAR)
.withArtifactId("childAAA")
.withVersion("1.0.0-SNAPSHOT")
.build())
.build())
.build())
.build());

rule.setSearchTransitive(true);
rule.setExcludes(Collections.singletonList("*:*:*:war"));

assertThatCode(rule::execute)
.isInstanceOf(EnforcerRuleException.class)
.hasMessageContaining(
"default-group:childAA:war:classifier:1.0.0-SNAPSHOT <--- banned via the exclude/include list")
.hasMessageContaining(
"default-group:childAAA:war:classifier:1.0.0-SNAPSHOT <--- banned via the exclude/include list");
}

@Test
void invalidExcludeFormat() throws Exception {
rule.setSearchTransitive(false);
Expand Down