Skip to content

Commit

Permalink
fix(java): don't ignore runtime scope for pom.xml files (#6223)
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriyLewen committed Mar 4, 2024
1 parent 355c1b5 commit c4b5ab7
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/dependency/parser/java/pom/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ func (p *parser) parseDependencies(deps []pomDependency, props map[string]string
// Resolve dependencies
d = d.Resolve(props, depManagement, rootDepManagement)

if (d.Scope != "" && d.Scope != "compile") || d.Optional {
if (d.Scope != "" && d.Scope != "compile" && d.Scope != "runtime") || d.Optional {
continue
}

Expand Down
24 changes: 24 additions & 0 deletions pkg/dependency/parser/java/pom/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,24 @@ func TestPom_Parse(t *testing.T) {
},
},
},
{
ID: "org.example:example-runtime:1.0.0",
Name: "org.example:example-runtime",
Version: "1.0.0",
Locations: types.Locations{
{
StartLine: 37,
EndLine: 42,
},
},
},
},
wantDeps: []types.Dependency{
{
ID: "com.example:happy:1.0.0",
DependsOn: []string{
"org.example:example-api:1.7.30",
"org.example:example-runtime:1.0.0",
},
},
},
Expand Down Expand Up @@ -80,12 +92,24 @@ func TestPom_Parse(t *testing.T) {
},
},
},
{
ID: "org.example:example-runtime:1.0.0",
Name: "org.example:example-runtime",
Version: "1.0.0",
Locations: types.Locations{
{
StartLine: 37,
EndLine: 42,
},
},
},
},
wantDeps: []types.Dependency{
{
ID: "com.example:happy:1.0.0",
DependsOn: []string{
"org.example:example-api:1.7.30",
"org.example:example-runtime:1.0.0",
},
},
},
Expand Down
6 changes: 6 additions & 0 deletions pkg/dependency/parser/java/pom/testdata/happy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@
<artifactId>example-api</artifactId>
<version>${api.version}</version>
</dependency>
<dependency>
<groupId>org.example</groupId>
<artifactId>example-runtime</artifactId>
<version>1.0.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.example</groupId>
<artifactId>example-provided</artifactId>
Expand Down

0 comments on commit c4b5ab7

Please sign in to comment.