|
27 | 27 | _license_scanner_macos = os.path.join('third_party', 'askalono', 'askalono_macos')
|
28 | 28 | _license_scanner_windows = os.path.join('third_party', 'askalono', 'askalono.exe')
|
29 | 29 |
|
| 30 | +gradle_config = ['runtimeClasspath', 'runtime'] |
| 31 | +android_config = ['releaseRuntimeClasspath'] |
| 32 | + |
30 | 33 |
|
31 | 34 | class PackageManager:
|
32 | 35 | input_package_list_file = []
|
@@ -104,9 +107,8 @@ def run_gradle_task(self):
|
104 | 107 |
|
105 | 108 | def add_allDeps_in_gradle(self):
|
106 | 109 | ret = False
|
107 |
| - configuration = 'project.configurations.runtimeClasspath, project.configurations.runtime' |
108 |
| - if self.package_manager_name == 'android': |
109 |
| - configuration = 'project.configurations.releaseRuntimeClasspath' |
| 110 | + config = android_config if self.package_manager_name == 'android' else gradle_config |
| 111 | + configuration = ','.join([f'project.configurations.{c}' for c in config]) |
110 | 112 |
|
111 | 113 | allDeps = f'''allprojects {{
|
112 | 114 | task allDeps(type: DependencyReportTask) {{
|
@@ -140,15 +142,24 @@ def exeucte_gradle_task(self, dependency_tree_fname):
|
140 | 142 | return ret
|
141 | 143 |
|
142 | 144 | def parse_dependency_tree(self, f_name):
|
| 145 | + config = android_config if self.package_manager_name == 'android' else gradle_config |
143 | 146 | with open(f_name, 'r', encoding='utf8') as input_fp:
|
| 147 | + packages_in_config = False |
144 | 148 | for i, line in enumerate(input_fp.readlines()):
|
145 | 149 | try:
|
146 | 150 | line_bk = copy.deepcopy(line)
|
147 |
| - re_result = re.findall(r'\-\-\-\s([^\:\s]+\:[^\:\s]+)\:([^\:\s]+)', line) |
148 |
| - if re_result: |
149 |
| - self.total_dep_list.append(re_result[0][0]) |
150 |
| - if re.match(r'^[\+|\\]\-\-\-\s([^\:\s]+\:[^\:\s]+)\:([^\:\s]+)', line_bk): |
151 |
| - self.direct_dep_list.append(re_result[0][0]) |
| 151 | + if not packages_in_config: |
| 152 | + filtered = next(filter(lambda c: re.findall(rf'^{c}\s\-', line), config), None) |
| 153 | + if filtered: |
| 154 | + packages_in_config = True |
| 155 | + else: |
| 156 | + if line == '': |
| 157 | + packages_in_config = False |
| 158 | + re_result = re.findall(r'\-\-\-\s([^\:\s]+\:[^\:\s]+)\:([^\:\s]+)', line) |
| 159 | + if re_result: |
| 160 | + self.total_dep_list.append(re_result[0][0]) |
| 161 | + if re.match(r'^[\+|\\]\-\-\-\s([^\:\s]+\:[^\:\s]+)\:([^\:\s]+)', line_bk): |
| 162 | + self.direct_dep_list.append(re_result[0][0]) |
152 | 163 | except Exception as e:
|
153 | 164 | logger.error(f"Failed to parse dependency tree: {e}")
|
154 | 165 |
|
|
0 commit comments