Skip to content

Commit 2a1bf86

Browse files
committed
Update "find_jvm_packages" to include all resources
- Ensure extra_data is populated in "find_jvm_packages()" for all resources for mapping purposes - Adjust test logic to update extra_data after map_checksum, matching d2d pipeline sequence Signed-off-by: Chin Yeung Li <[email protected]>
1 parent eb8d4bb commit 2a1bf86

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

scanpipe/pipes/d2d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ def find_jvm_packages(project, jvm_lang: jvm.JvmLanguage, logger=None):
263263
Note: we use the same API as the ScanCode scans by design
264264
"""
265265
resources = (
266-
project.codebaseresources.files().no_status().from_codebase().has_no_relation()
266+
project.codebaseresources.files().no_status().from_codebase()
267267
)
268268

269269
from_jvm_resources = resources.filter(extension__in=jvm_lang.source_extensions)

scanpipe/tests/pipes/test_d2d.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,6 @@ def test_scanpipe_pipes_d2d_map_java_to_class_with_java_in_deploy(self):
399399
self.project1,
400400
path="from/flume-ng-node-1.9.0-sources.jar-extract/org/apache/flume/node/"
401401
"AbstractConfigurationProvider.java",
402-
extra_data={"java_package": "org.apache.flume.node"},
403402
sha1=sha1,
404403
)
405404
to1 = make_resource_file(
@@ -425,6 +424,14 @@ def test_scanpipe_pipes_d2d_map_java_to_class_with_java_in_deploy(self):
425424
self.assertEqual("sha1", relation1.map_type)
426425
self.assertEqual(from1, relation1.from_resource)
427426

427+
# The "java_package" field in extra_data is required for mapping
428+
# Java packages to classes.
429+
# Simulate the "find_jvm_packages" call by updating extra_data in
430+
# the from1 resource
431+
# Note that "find_java_packages" is called before
432+
# "map_java_to_class"
433+
from1.update_extra_data({"java_package": "org.apache.flume.node"})
434+
428435
# Now run map_java_to_class
429436
d2d.map_jvm_to_class(
430437
self.project1, logger=buffer.write, jvm_lang=jvm.JavaLanguage

0 commit comments

Comments
 (0)