diff --git a/maven/lib/dependabot/maven/file_parser.rb b/maven/lib/dependabot/maven/file_parser.rb index 0759e41e134..c6df42a319b 100644 --- a/maven/lib/dependabot/maven/file_parser.rb +++ b/maven/lib/dependabot/maven/file_parser.rb @@ -40,6 +40,9 @@ class FileParser < Dependabot::FileParsers::Base PLUGIN_ARTIFACT_ITEMS_SELECTOR = "plugins > plugin > executions > execution > " \ "configuration > artifactItems > artifactItem" + # Packages that are virtual/IDE-only and do not exist in any Maven repository. + VIRTUAL_PACKAGES = T.let(["org.eclipse.m2e:lifecycle-mapping"].freeze, T::Array[String]) + # Regex to get the property name from a declaration that uses a property PROPERTY_REGEX = /\$\{(?.*?)\}/ @@ -223,6 +226,7 @@ def dependency_from_dependency_node(pom, dependency_node, plugin_names) def dependency_from_plugin_node(pom, dependency_node) return unless (name = plugin_name(dependency_node, pom)) return if internal_dependency_names.include?(name) + return if VIRTUAL_PACKAGES.include?(name) build_dependency(pom, dependency_node, name, is_plugin: true) end diff --git a/maven/spec/dependabot/maven/file_parser_spec.rb b/maven/spec/dependabot/maven/file_parser_spec.rb index 3f6c6df1f2d..ba877444630 100644 --- a/maven/spec/dependabot/maven/file_parser_spec.rb +++ b/maven/spec/dependabot/maven/file_parser_spec.rb @@ -393,6 +393,21 @@ end end + context "when the pom includes org.eclipse.m2e:lifecycle-mapping" do + let(:pom_body) { fixture("poms", "lifecycle_mapping_pom.xml") } + + it "skips org.eclipse.m2e:lifecycle-mapping" do + expect(dependencies.map(&:name)).not_to include("org.eclipse.m2e:lifecycle-mapping") + end + + it "still includes other plugins" do + expect(dependencies.map(&:name)) + .to include("org.apache.maven.plugins:maven-compiler-plugin") + end + + its(:length) { is_expected.to eq(1) } + end + context "when dealing with versions defined by a property" do let(:pom_body) { fixture("poms", "property_pom.xml") } diff --git a/maven/spec/fixtures/poms/lifecycle_mapping_pom.xml b/maven/spec/fixtures/poms/lifecycle_mapping_pom.xml new file mode 100644 index 00000000000..536c3f32b90 --- /dev/null +++ b/maven/spec/fixtures/poms/lifecycle_mapping_pom.xml @@ -0,0 +1,29 @@ + + 4.0.0 + + com.dependabot + lifecycle-mapping-test + 0.0.1 + + pom + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.11.0 + + + + +