Skip to content

Commit f2fb4ef

Browse files
authored
Merge branch 'main' into snyk-upgrade-077a3e87df1150537a4c8d358405a7b0
2 parents 219d258 + 40ef2db commit f2fb4ef

4 files changed

Lines changed: 109 additions & 13045 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ repositories {
104104
<dependency>
105105
<groupId>com.redhat.exhort</groupId>
106106
<artifactId>exhort-java-api</artifactId>
107-
<version>0.0.8-SNAPSHOT</version>
107+
<version>0.0.9-SNAPSHOT</version>
108108
</dependency>
109109
```
110110
</li>
@@ -188,7 +188,7 @@ Excluding a package from any analysis can be achieved by marking the package for
188188
<dependency> <!--exhortignore-->
189189
<groupId>...</groupId>
190190
<artifactId>...</artifactId>
191-
<version>0.0.8-SNAPSHOT</version>
191+
<version>0.0.9-SNAPSHOT</version>
192192
</dependency>
193193
```
194194
</li>

pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.redhat.exhort</groupId>
77
<artifactId>exhort-java-api</artifactId>
8-
<version>0.0.8-SNAPSHOT</version>
8+
<version>0.0.9-SNAPSHOT</version>
99
<name>Exhort Java API</name>
1010
<description>Exhort Java API</description>
1111
<url>https://github.com/trustification/exhort-java-api#readme</url>
@@ -706,7 +706,7 @@ limitations under the License.]]>
706706
</transformer>
707707

708708
<!-- Service files transformer for Jackson and other services -->
709-
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
709+
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
710710

711711
<!-- Append NOTICE files -->
712712
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
@@ -745,8 +745,8 @@ limitations under the License.]]>
745745
<formats>
746746
<format>
747747
<includes><include>src/*</include></includes>
748-
<trimTrailingWhitespace/>
749-
<endWithNewline/>
748+
<trimTrailingWhitespace />
749+
<endWithNewline />
750750
<indent>
751751
<tabs>true</tabs>
752752
<spacesPerTab>4</spacesPerTab>

src/main/java/com/redhat/exhort/providers/JavaMavenProvider.java

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,41 @@ private List<DependencyAggregator> getDependencies(final Path manifestPath) thro
238238
// when a "dependency" tag starts, it will be initiated,
239239
// when a "dependency" tag ends, it will be parsed, act upon, and reset
240240
DependencyAggregator dependencyAggregator = null;
241+
boolean insideDependencyManagement = false;
242+
boolean insideExclusions = false;
243+
boolean insidePlugins = false;
241244
while (reader.hasNext()) {
242245
reader.next(); // get the next event
246+
if (reader.isStartElement() && "dependencyManagement".equals(reader.getLocalName())) {
247+
insideDependencyManagement = true;
248+
continue;
249+
}
250+
if (reader.isEndElement() && "dependencyManagement".equals(reader.getLocalName())) {
251+
insideDependencyManagement = false;
252+
continue;
253+
}
254+
if (reader.isStartElement() && "plugins".equals(reader.getLocalName())) {
255+
insidePlugins = true;
256+
continue;
257+
}
258+
if (reader.isEndElement() && "plugins".equals(reader.getLocalName())) {
259+
insidePlugins = false;
260+
continue;
261+
}
262+
if (reader.isStartElement() && "exclusions".equals(reader.getLocalName())) {
263+
insideExclusions = true;
264+
continue;
265+
}
266+
if (reader.isEndElement() && "exclusions".equals(reader.getLocalName())) {
267+
insideExclusions = false;
268+
continue;
269+
}
243270
if (reader.isStartElement() && "dependency".equals(reader.getLocalName())) {
244-
// starting "dependency" tag, initiate aggregator
245-
dependencyAggregator = new DependencyAggregator();
271+
// starting "dependency" tag, initiate aggregator only if not inside dependencyManagement
272+
// or plugins
273+
if (!insideDependencyManagement && !insidePlugins) {
274+
dependencyAggregator = new DependencyAggregator();
275+
}
246276
continue;
247277
}
248278

@@ -256,9 +286,10 @@ private List<DependencyAggregator> getDependencies(final Path manifestPath) thro
256286
continue;
257287
}
258288

259-
if (reader.isStartElement()) {
289+
if (reader.isStartElement() && !insideExclusions) {
260290
// NOTE if we want to include "scope" tags in ignore,
261291
// add a case here and a property in DependencyIgnore
292+
// Only process these elements if we're not inside exclusions
262293
switch (reader.getLocalName()) {
263294
case "groupId": // starting "groupId" tag, get next event and set to aggregator
264295
reader.next();
@@ -282,8 +313,11 @@ private List<DependencyAggregator> getDependencies(final Path manifestPath) thro
282313
}
283314

284315
if (reader.isEndElement() && "dependency".equals(reader.getLocalName())) {
285-
// add object to list and reset dependency aggregator
286-
deps.add(dependencyAggregator);
316+
// add object to list and reset dependency aggregator only if not inside
317+
// dependencyManagement or plugins
318+
if (!insideDependencyManagement && !insidePlugins && dependencyAggregator != null) {
319+
deps.add(dependencyAggregator);
320+
}
287321
dependencyAggregator = null;
288322
}
289323
}
@@ -383,7 +417,9 @@ private String selectMvnRuntime(final Path manifestPath) {
383417
try {
384418
// verify maven wrapper is accessible
385419
Operations.runProcess(manifest.getParent(), mvnw, ARG_VERSION);
386-
log.fine(String.format("using maven wrapper from : %s", mvnw));
420+
if (debugLoggingIsNeeded()) {
421+
log.info(String.format("using maven wrapper from : %s", mvnw));
422+
}
387423
return mvnw;
388424
} catch (Exception e) {
389425
log.warning(
@@ -393,7 +429,9 @@ private String selectMvnRuntime(final Path manifestPath) {
393429
}
394430
// If maven wrapper is not requested or not accessible, fall back to use mvn
395431
String mvn = Operations.getExecutable(MVN, ARG_VERSION);
396-
log.fine(String.format("using mvn executable from : %s", mvn));
432+
if (debugLoggingIsNeeded()) {
433+
log.info(String.format("using mvn executable from : %s", mvn));
434+
}
397435
return mvn;
398436
}
399437

0 commit comments

Comments
 (0)