Skip to content

Adding invertMarking flag to ModuleHasDependency for flipping what gets marked #146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 31, 2025
Merged
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 @@ -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,13 @@ 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);
}
if (!shouldInvert && acc.contains(jp)) {
return SearchResult.found(tree, "Module has dependency: " + dependencyGav);
}
return tree;
}
Expand Down
Loading