-
Notifications
You must be signed in to change notification settings - Fork 18
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
Fix inclusion/exclusion inconsistency #342
base: main
Are you sure you want to change the base?
Conversation
This makes it consistent, if we decide a root artefact is allowed by the include/exclude list we use the same logic to decide if we should process it as a node. Note this changes the behaviour, an inclusion rule will beat an exclusion rule. Signed-off-by: Robert Young <robeyoun@redhat.com>
} else { | ||
collect = !isExcluded(d) && isIncluded(d); | ||
collect = !isExplicitlyExcluded(d) && isExplicitlyIncluded(d); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we check if the projectBomConstraint is explicitly included in this case? When discovering top level artefacts we check if they are included or not excluded.
@@ -752,7 +763,7 @@ private void processRootArtifact(ArtifactCoords rootArtifact) { | |||
} | |||
for (DependencyNode d : root.getChildren()) { | |||
if (d.getDependency().isOptional() | |||
&& !(config.isIncludeOptionalDeps() || isIncluded(toCoords(d.getArtifact())))) { | |||
&& !(config.isIncludeOptionalDeps() || isExplicitlyIncluded(toCoords(d.getArtifact())))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we only consult the include list when deciding if we should recurse into optional deps?
@@ -1247,7 +1258,7 @@ private void processNodes(DependencyNode node, int level, boolean remaining) { | |||
} | |||
|
|||
final ArtifactCoords coords = toCoords(node.getArtifact()); | |||
if (isExcluded(coords)) { | |||
if (!isIncluded(coords)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the actual logic change, checking if the coords are in the inclusion list or not in the exclusion list.
Alternatively if exclusion should beat inclusion (hard to make everyone happy 😁), we should add that to the javadoc and put tests on it. |
@@ -1238,7 +1249,7 @@ private void processNodes(DependencyNode node, int level, boolean remaining) { | |||
if (winner != null) { | |||
final ArtifactCoords coords = toCoords(winner.getArtifact()); | |||
// linked dependencies should also be checked for exclusions | |||
if (!isExcluded(coords)) { | |||
if (!isExplicitlyExcluded(coords)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should the inclusion list be considered here too?
Closes #320
If we decide a root artefact is allowed by the include/exclude list we use the same logic to decide if we should process it as a node.
Note this changes the behaviour, an inclusion rule will beat an exclusion rule.
Context
We are using ProjectDependencyResolver to discover project dependencies and want to be able to configure it like:
However in this configuration
org.group:specific:*
is not resolved as the exclusion takes precedence. Then looking into the code we see some usages where inclusion beats exclusion and wonder what the intent of the inclusion/exclusion lists are.This is more the start of a conversation as there are numerous places where the include/exclude list are consulted. For example when collecting projectBomConstraints it has different logic again:
where it applies this groupId restriction if there are no explicit inclusions else it requires it to be explicitly included.
There are other places in the resolver where we only check the exclusion list or inclusion list.
The javadoc on ProjectDependencyConfig is ambiguous around how
getIncludePatterns
andgetExcludePatterns
interact and how they relate togetIncludeArtifacts
.It feels like there should be some consistent way that the inclusion/exclusion rules are applied to dependencies.