Skip to content

Commit

Permalink
Do not assign resources in uberjars
Browse files Browse the repository at this point in the history
This introduces a fix where we don't assign resources to packages when we
find multiple pom.xmls in a META-INF directory for a jar.

Signed-off-by: Ayan Sinha Mahapatra <[email protected]>
  • Loading branch information
AyanSinhaMahapatra committed Jun 12, 2023
1 parent bb91b89 commit 5b0e46c
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 242 deletions.
13 changes: 12 additions & 1 deletion src/packagedcode/maven.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,21 @@ def assign_package_to_resources(cls, package, resource, codebase, package_adder)
if resource.path.endswith(f'META-INF/maven/{package.namespace}/{package.name}/pom.xml'):
# First case: a pom.xml inside a META-INF directory such as in
# /META-INF/maven/log4j/log4j/pom.xml: This requires going up 5 times
upward_segments = 5
upward_segments = 4
root = resource
for _ in range(upward_segments):
root = root.parent(codebase)

number_poms = 0
for child in root.walk(codebase):
if 'pom.xml' in child.path:
number_poms += 1

if number_poms > 1:
root = resource
else:
root = root.parent(codebase)

else:
# Second case: a pom.xml at the root of codebase tree
# FIXME: handle the cases opf parent POMs and nested POMs
Expand Down
Loading

0 comments on commit 5b0e46c

Please sign in to comment.