Skip to content

Commit d68a862

Browse files
authored
Maintenance fixes to the POM file generation logic. (#413)
* Maintenance fixes to the POM file generation logic. * Refactored code for the generation of the JaCoCo plugin configuration. * Expunged instance referencing in the function to generate the JaCoCo plugin configuration.
1 parent edcda98 commit d68a862

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

python/rpdk/java/codegen.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,26 @@ def _writing_component(
165165
)
166166
project.safewrite(path, contents)
167167

168+
@staticmethod
169+
def _get_jacoco_maven_plugin_excluded_paths(
170+
project,
171+
):
172+
"""Return a list of excluded paths based on the extension type."""
173+
jacoco_excluded_paths = []
174+
175+
if project.artifact_type == ARTIFACT_TYPE_HOOK:
176+
jacoco_excluded_paths.append("**/hook/model/**")
177+
jacoco_excluded_paths.append("**/BaseHookConfiguration*")
178+
jacoco_excluded_paths.append("**/HookHandlerWrapper*")
179+
jacoco_excluded_paths.append("**/Configuration*")
180+
else:
181+
jacoco_excluded_paths.append("**/BaseConfiguration*")
182+
jacoco_excluded_paths.append("**/BaseHandler*")
183+
jacoco_excluded_paths.append("**/HandlerWrapper*")
184+
jacoco_excluded_paths.append("**/ResourceModel*")
185+
186+
return jacoco_excluded_paths
187+
168188
@logdebug
169189
def init(self, project):
170190
"""Init"""
@@ -206,12 +226,19 @@ def init_shared(self, project, src, tst, resources):
206226
LOG.debug("Writing Maven POM: %s", path)
207227
template = self.env.get_template("init/shared/pom.xml")
208228
artifact_id = "{}-handler".format(project.hypenated_name)
229+
jacoco_excluded_paths = self._get_jacoco_maven_plugin_excluded_paths(
230+
project=project,
231+
)
209232
contents = template.render(
210233
group_id=self.package_name,
211234
artifact_id=artifact_id,
212235
executable=EXECUTABLE,
213236
schema_file_name=project.schema_filename,
214237
package_name=self.package_name,
238+
jacoco_maven_plugin_exclude_path_1=jacoco_excluded_paths[0],
239+
jacoco_maven_plugin_exclude_path_2=jacoco_excluded_paths[1],
240+
jacoco_maven_plugin_exclude_path_3=jacoco_excluded_paths[2],
241+
jacoco_maven_plugin_exclude_path_4=jacoco_excluded_paths[3],
215242
)
216243
project.safewrite(path, contents)
217244

python/rpdk/java/templates/init/shared/pom.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
<dependency>
5050
<groupId>org.apache.logging.log4j</groupId>
5151
<artifactId>log4j-slf4j-impl</artifactId>
52-
<version>2.13.3</version>
52+
<version>2.17.1</version>
5353
</dependency>
5454

5555
<!-- https://mvnrepository.com/artifact/org.assertj/assertj-core -->
@@ -172,10 +172,10 @@
172172
<version>0.8.4</version>
173173
<configuration>
174174
<excludes>
175-
<exclude>**/BaseConfiguration*</exclude>
176-
<exclude>**/BaseHandler*</exclude>
177-
<exclude>**/HandlerWrapper*</exclude>
178-
<exclude>**/ResourceModel*</exclude>
175+
<exclude>{{ jacoco_maven_plugin_exclude_path_1 }}</exclude>
176+
<exclude>{{ jacoco_maven_plugin_exclude_path_2 }}</exclude>
177+
<exclude>{{ jacoco_maven_plugin_exclude_path_3 }}</exclude>
178+
<exclude>{{ jacoco_maven_plugin_exclude_path_4 }}</exclude>
179179
</excludes>
180180
</configuration>
181181
<executions>

0 commit comments

Comments
 (0)