Skip to content

Commit 60c6777

Browse files
committed
Fix handing of outdated src_gen files in ShadedLibraryBuildTask.
1 parent d4cc6aa commit 60c6777

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

sdk/mx.sdk/mx_sdk_shaded.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,20 +200,22 @@ def _collect_files(self):
200200

201201
# collect project files first, then extend with shaded (re)sources
202202
super()._collect_files()
203-
javafiles = self._javafiles
204-
non_javafiles = self._non_javafiles
205-
206203
proj = self.subject
207204
binDir = proj.output_dir()
205+
srcGenDir = proj.source_gen_dir()
208206
excludedPaths = proj.excluded_paths()
209207
includedPaths = proj.included_paths()
210208

209+
# remove possibly outdated src_gen files; they will be added below
210+
javafiles = self._javafiles = {src: out for src, out in self._javafiles.items() if not src.startswith(srcGenDir)}
211+
non_javafiles = self._non_javafiles = {src: out for src, out in self._non_javafiles.items() if not src.startswith(srcGenDir)}
212+
211213
for dep in proj.shaded_deps():
212214
srcFilePath = dep.get_source_path(False)
213215
if srcFilePath is None:
214216
continue
215217

216-
for zipFilePath, outDir in [(srcFilePath, proj.source_gen_dir())]:
218+
for zipFilePath, outDir in [(srcFilePath, srcGenDir)]:
217219
try:
218220
with zipfile.ZipFile(zipFilePath, 'r') as zf:
219221
for zi in zf.infolist():
@@ -240,9 +242,9 @@ def _collect_files(self):
240242
new_filename = proj.substitute_path(old_filename, mappings=path_mappings)
241243
src_gen_path = os.path.join(outDir, new_filename)
242244
if filepath.suffix == '.java':
243-
javafiles.setdefault(src_gen_path, os.path.join(binDir, new_filename[:-len('.java')] + '.class'))
245+
javafiles[src_gen_path] = os.path.join(binDir, new_filename[:-len('.java')] + '.class')
244246
else:
245-
non_javafiles.setdefault(src_gen_path, os.path.join(binDir, new_filename))
247+
non_javafiles[src_gen_path] = os.path.join(binDir, new_filename)
246248
except FileNotFoundError:
247249
continue
248250
return self

0 commit comments

Comments
 (0)