Return a list of Dependent package objects found in a MavenPom `pom` object.
(pom)
| 1037 | |
| 1038 | |
| 1039 | def get_dependencies(pom): |
| 1040 | """ |
| 1041 | Return a list of Dependent package objects found in a MavenPom `pom` object. |
| 1042 | """ |
| 1043 | dependencies = [] |
| 1044 | for scope, deps in pom.dependencies.items(): |
| 1045 | if TRACE: |
| 1046 | logger.debug('parse: dependencies.deps: {}'.format(deps)) |
| 1047 | if scope: |
| 1048 | scope = scope.strip().lower() |
| 1049 | if not scope: |
| 1050 | # maven default |
| 1051 | scope = 'compile' |
| 1052 | |
| 1053 | for (dgroup_id, dartifact_id, dversion), drequired in deps: |
| 1054 | if TRACE: |
| 1055 | logger.debug('parse: dependencies.deps: {}, {}, {}, {}'. |
| 1056 | format(dgroup_id, dartifact_id, dversion, drequired)) |
| 1057 | # pymaven whart |
| 1058 | if dversion == 'latest.release': |
| 1059 | dversion = None |
| 1060 | |
| 1061 | is_pinned = bool(dversion and not any(c in dversion for c in '$[,]')) |
| 1062 | |
| 1063 | dqualifiers = {} |
| 1064 | # FIXME: this is missing from the original Pom parser |
| 1065 | # classifier = dep.get('classifier') |
| 1066 | # if classifier: |
| 1067 | # qualifiers['classifier'] = classifier |
| 1068 | # |
| 1069 | # packaging = dep.get('type') |
| 1070 | # if packaging and packaging != 'jar': |
| 1071 | # qualifiers['packaging'] = packaging |
| 1072 | |
| 1073 | if is_pinned: |
| 1074 | dpurl = models.PackageURL( |
| 1075 | type='maven', |
| 1076 | namespace=dgroup_id, |
| 1077 | name=dartifact_id, |
| 1078 | version=dversion, |
| 1079 | qualifiers=dqualifiers or None, |
| 1080 | ) |
| 1081 | else: |
| 1082 | dpurl = models.PackageURL( |
| 1083 | type='maven', |
| 1084 | namespace=dgroup_id, |
| 1085 | name=dartifact_id, |
| 1086 | qualifiers=dqualifiers or None, |
| 1087 | ) |
| 1088 | |
| 1089 | # TODO: handle dependency management and pom type |
| 1090 | is_runtime = scope in ('runtime', 'system', 'provided') |
| 1091 | is_optional = bool(scope in ('test', 'compile',) or not drequired) |
| 1092 | |
| 1093 | dep_pack = models.DependentPackage( |
| 1094 | purl=str(dpurl), |
| 1095 | extracted_requirement=dversion, |
| 1096 | scope=scope, |