Skip to content
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

Skip classifier when checking for internal dep #4117

Merged
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
19 changes: 11 additions & 8 deletions maven/lib/dependabot/maven/file_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ def dependency_from_dependency_node(pom, dependency_node)
return unless (name = dependency_name(dependency_node, pom))
return if internal_dependency_names.include?(name)

classifier = dependency_classifier(dependency_node, pom)
name = classifier ? "#{name}:#{classifier}" : name

build_dependency(pom, dependency_node, name)
end

Expand Down Expand Up @@ -125,7 +128,7 @@ def dependency_name(dependency_node, pom)
return unless dependency_node.at_xpath("./groupId")
return unless dependency_node.at_xpath("./artifactId")

name = [
[
evaluated_value(
dependency_node.at_xpath("./groupId").content.strip,
pom
Expand All @@ -135,15 +138,15 @@ def dependency_name(dependency_node, pom)
pom
)
].join(":")
end

if dependency_node.at_xpath("./classifier")
name += ":#{evaluated_value(
dependency_node.at_xpath('./classifier').content.strip,
pom
)}"
end
def dependency_classifier(dependency_node, pom)
return unless dependency_node.at_xpath("./classifier")

name
evaluated_value(
dependency_node.at_xpath("./classifier").content.strip,
pom
)
end

def plugin_name(dependency_node, pom)
Expand Down
6 changes: 6 additions & 0 deletions maven/spec/fixtures/poms/multimodule_pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@
<artifactId>util</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.evenh.multimodule</groupId>
<artifactId>util</artifactId>
<version>${project.version}</version>
<classifier>sources</classifier>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a test case in the filer_parser spec covering this case? Does this change mean we correctly detect internal dependencies?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is already a test case for this. Adding this classified dependency should cover the change. And yes, without the patch this added dependency will fail a test case where it asserts all dependencies to look for updates.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh gotcha! Thanks for linking 👍

</dependency>
</dependencies>
</dependencyManagement>

Expand Down