@@ -200,20 +200,22 @@ def _collect_files(self):
200
200
201
201
# collect project files first, then extend with shaded (re)sources
202
202
super ()._collect_files ()
203
- javafiles = self ._javafiles
204
- non_javafiles = self ._non_javafiles
205
-
206
203
proj = self .subject
207
204
binDir = proj .output_dir ()
205
+ srcGenDir = proj .source_gen_dir ()
208
206
excludedPaths = proj .excluded_paths ()
209
207
includedPaths = proj .included_paths ()
210
208
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
+
211
213
for dep in proj .shaded_deps ():
212
214
srcFilePath = dep .get_source_path (False )
213
215
if srcFilePath is None :
214
216
continue
215
217
216
- for zipFilePath , outDir in [(srcFilePath , proj . source_gen_dir () )]:
218
+ for zipFilePath , outDir in [(srcFilePath , srcGenDir )]:
217
219
try :
218
220
with zipfile .ZipFile (zipFilePath , 'r' ) as zf :
219
221
for zi in zf .infolist ():
@@ -240,9 +242,9 @@ def _collect_files(self):
240
242
new_filename = proj .substitute_path (old_filename , mappings = path_mappings )
241
243
src_gen_path = os .path .join (outDir , new_filename )
242
244
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' )
244
246
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 )
246
248
except FileNotFoundError :
247
249
continue
248
250
return self
0 commit comments