@@ -51,10 +51,17 @@ def find_repo(self, purl: PackageURL) -> tuple[str, RepoFinderInfo]:
5151 artifact = purl .name
5252 version = purl .version or ""
5353
54+ outcome = RepoFinderInfo .FOUND
5455 if not version :
55- logger .debug ("Version missing for maven artifact: %s:%s" , group , artifact )
56- # TODO add support for Java artifacts without a version
57- return "" , RepoFinderInfo .NO_VERSION_PROVIDED
56+ # TODO: consider using a Maven specific method for finding missing versions.
57+ logger .info ("Version missing for maven artifact: %s:%s" , group , artifact )
58+ latest_purl , outcome = DepsDevRepoFinder ().get_latest_version (purl )
59+ if not latest_purl or not latest_purl .version :
60+ logger .debug ("Could not find version for artifact: %s:%s" , purl .namespace , purl .name )
61+ return "" , RepoFinderInfo .NO_VERSION_PROVIDED
62+ group = latest_purl .namespace or ""
63+ artifact = latest_purl .name
64+ version = latest_purl .version
5865
5966 # Perform the following in a loop:
6067 # - Create URLs for the current artifact POM
@@ -64,19 +71,8 @@ def find_repo(self, purl: PackageURL) -> tuple[str, RepoFinderInfo]:
6471 # - Repeat
6572 limit = defaults .getint ("repofinder.java" , "parent_limit" , fallback = 10 )
6673 initial_limit = limit
67- last_outcome = RepoFinderInfo . FOUND
74+ last_outcome = outcome
6875 check_parents = defaults .getboolean ("repofinder.java" , "find_parents" )
69-
70- if not version :
71- logger .info ("Version missing for maven artifact: %s:%s" , group , artifact )
72- latest_purl , outcome = DepsDevRepoFinder ().get_latest_version (purl )
73- if not latest_purl or not latest_purl .version :
74- logger .debug ("Could not find version for artifact: %s:%s" , purl .namespace , purl .name )
75- return "" , outcome
76- group = latest_purl .namespace or ""
77- artifact = latest_purl .name
78- version = latest_purl .version
79-
8076 while group and artifact and version and limit > 0 :
8177 # Create the URLs for retrieving the artifact's POM.
8278 group = group .replace ("." , "/" )
0 commit comments