Skip to content

Commit fb14bcf

Browse files
authored
chore: Support spotbugs running anywhere (#1537)
* Allow spotbugs & checkstyle to run from any subdirectory * Clean up spotbugs-exclude
1 parent 516db4e commit fb14bcf

File tree

7 files changed

+71
-137
lines changed

7 files changed

+71
-137
lines changed

.mvn/README

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
This is here purely so that we can get the root directory using maven.multiModuleProjectDirectory
2+

checkstyle.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
<module name="FileLength"/>
5252

5353
<module name="Header">
54-
<property name="headerFile" value="license-header"/>
54+
<property name="headerFile" value="${basedir}/license-header"/>
5555
<property name="severity" value="error"/>
5656
</module>
5757

examples/spotbugs-exclude.xml

-20
This file was deleted.

pom.xml

+6-1
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@
110110
<aws-embedded-metrics.version>1.0.6</aws-embedded-metrics.version>
111111
<jmespath.version>0.6.0</jmespath.version>
112112
<elastic.version>1.5.0</elastic.version>
113+
114+
<!-- As we have a .mvn directory at the root of the project, this will evaluate to the root directory
115+
regardless of where maven is run - sub-module, or root. -->
116+
<project.rootdir>${maven.multiModuleProjectDirectory}</project.rootdir>
113117
</properties>
114118

115119
<dependencyManagement>
@@ -544,7 +548,7 @@
544548
</executions>
545549
<configuration>
546550
<xmlOutput>true</xmlOutput>
547-
<excludeFilterFile>../spotbugs-exclude.xml</excludeFilterFile>
551+
<excludeFilterFile>${project.rootdir}/spotbugs-exclude.xml</excludeFilterFile>
548552
</configuration>
549553
</plugin>
550554
</plugins>
@@ -641,6 +645,7 @@
641645
<artifactId>maven-checkstyle-plugin</artifactId>
642646
<version>3.3.0</version>
643647
<configuration>
648+
<propertyExpansion>basedir=${project.rootdir}</propertyExpansion>
644649
<configLocation>checkstyle.xml</configLocation>
645650
<consoleOutput>true</consoleOutput>
646651
<failsOnError>true</failsOnError>

powertools-logging/spotbugs-exclude.xml

-30
This file was deleted.

powertools-parameters/spotbugs-exclude.xml

-82
This file was deleted.

spotbugs-exclude.xml

+62-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,34 @@
3939
<Class name="software.amazon.lambda.powertools.parameters.secrets.SecretsProviderBuilder"/>
4040
<Field name="client"/>
4141
</And>
42-
42+
<And>
43+
<Class name="software.amazon.lambda.powertools.parameters.ssm.SSMProviderBuilder"/>
44+
<Field name="client"/>
45+
</And>
46+
<And>
47+
<Class name="software.amazon.lambda.powertools.parameters.ssm.SSMProviderBuilder"/>
48+
<Field name="cacheManager"/>
49+
</And>
50+
<And>
51+
<Class name="software.amazon.lambda.powertools.parameters.dynamodb.DynamoDbProviderBuilder"/>
52+
<Field name="cacheManager"/>
53+
</And>
54+
<And>
55+
<Class name="software.amazon.lambda.powertools.parameters.dynamodb.DynamoDbProviderBuilder"/>
56+
<Field name="client"/>
57+
</And>
58+
<And>
59+
<Class name="software.amazon.lambda.powertools.parameters.dynamodb.DynamoDbProviderBuilder"/>
60+
<Field name="transformationManager"/>
61+
</And>
62+
<And>
63+
<Class name="software.amazon.lambda.powertools.parameters.appconfig.AppConfigProviderBuilder"/>
64+
<Field name="cacheManager"/>
65+
</And>
66+
<And>
67+
<Class name="software.amazon.lambda.powertools.parameters.appconfig.AppConfigProviderBuilder"/>
68+
<Field name="transformationManager"/>
69+
</And>
4370
</Or>
4471
</Match>
4572
<!-- Internals of Log event for apache log4j-->
@@ -58,6 +85,18 @@
5885
<Class name="software.amazon.lambda.powertools.largemessages.LargeMessageConfig"/>
5986
<Method name="getS3Client"/>
6087
</And>
88+
<And>
89+
<Class name="software.amazon.lambda.powertools.logging.internal.AbstractJacksonLayoutCopy$Builder" />
90+
<Method name="getAdditionalFields"/>
91+
</And>
92+
<And>
93+
<Class name="software.amazon.lambda.powertools.logging.internal.AbstractJacksonLayoutCopy$LogEventWithAdditionalFields" />
94+
<Method name="getAdditionalFields"/>
95+
</And>
96+
<And>
97+
<Class name="software.amazon.lambda.powertools.logging.internal.LambdaJsonLayout$LogEventWithAdditionalFields" />
98+
<Method name="getAdditionalFields"/>
99+
</And>
61100
</Or>
62101
</Match>
63102
<Match>
@@ -103,6 +142,26 @@
103142
<Class name="software.amazon.lambda.powertools.largemessages.LargeMessageConfig"/>
104143
<Field name="s3Client"/>
105144
</And>
145+
<And>
146+
<Class name="software.amazon.lambda.powertools.logging.internal.AbstractJacksonLayoutCopy" />
147+
<Method name="LogEventWithAdditionalFields"/>
148+
</And>
149+
<And>
150+
<Class name="software.amazon.lambda.powertools.logging.internal.AbstractJacksonLayoutCopy$Builder" />
151+
<Method name="setAdditionalFields"/>
152+
</And>
153+
<And>
154+
<Class name="software.amazon.lambda.powertools.logging.internal.LambdaJsonLayout" />
155+
<Method name="LogEventWithAdditionalFields"/>
156+
</And>
157+
<And>
158+
<Class name="software.amazon.lambda.powertools.logging.LambdaEcsEncoder" />
159+
<Method name="setThrowableConverter"/>
160+
</And>
161+
<And>
162+
<Class name="software.amazon.lambda.powertools.logging.LambdaJsonEncoder" />
163+
<Method name="setThrowableConverter"/>
164+
</And>
106165
</Or>
107166
</Match>
108167
<!--Functionally needed-->
@@ -171,5 +230,5 @@
171230
<Method name="threadOption1"/>
172231
</And>
173232
</Or>
174-
</Match>
175-
</FindBugsFilter>
233+
</Match>
234+
</FindBugsFilter>

0 commit comments

Comments
 (0)