Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -73,6 +73,12 @@ public String getDescription() {
@Nullable
String version;

@Option(displayName = "Invert marking",
description = "If `true`, will invert the check for whether to mark a file. Defaults to `false`.",
required = false)
@Nullable
Boolean invertMarking;

@Override
public Set<JavaProject> getInitialValue(ExecutionContext ctx) {
return new HashSet<>();
Expand Down Expand Up @@ -110,8 +116,12 @@ public Tree visit(@Nullable Tree tree, ExecutionContext ctx) {
return tree;
}
JavaProject jp = maybeJp.get();
if (acc.contains(jp)) {
return SearchResult.found(tree, "Module has dependency: " + groupIdPattern + ":" + artifactIdPattern + (version == null ? "" : ":" + version));
boolean shouldInvert = invertMarking != null && invertMarking;
String dependencyGav = groupIdPattern + ":" + artifactIdPattern + (version == null ? "" : ":" + version);
if (shouldInvert && !acc.contains(jp)) {
return SearchResult.found(tree, "Module does not have dependency: " + dependencyGav);
} else if (!shouldInvert && acc.contains(jp)) {
return SearchResult.found(tree, "Module has dependency: " + dependencyGav);
}
return tree;
}
Expand Down
Loading