@@ -270,19 +270,17 @@ private static boolean themeConfigurationChanged(Options options,
270270 throws IOException {
271271 Map <String , JsonObject > themeJsonContents = new HashMap <>();
272272
273- if (options .getJarFiles () == null ) {
274- return false ;
273+ if (options .getJarFiles () != null ) {
274+ options .getJarFiles ().stream ().filter (File ::exists )
275+ .filter (file -> !file .isDirectory ())
276+ .forEach (jarFile -> getPackagedThemeJsonContents (jarFile ,
277+ themeJsonContents ));
275278 }
276279
277- options .getJarFiles ().stream ().filter (File ::exists )
278- .filter (file -> !file .isDirectory ())
279- .forEach (jarFile -> getPackagedThemeJsonContents (jarFile ,
280- themeJsonContents ));
281-
282280 ThemeDefinition themeDefinition = frontendDependencies
283281 .getThemeDefinition ();
284- Optional <JsonObject > projectThemeJson = getContentForProjectThemeJson (
285- options , themeDefinition );
282+ Optional <JsonObject > projectThemeJson = FrontendUtils
283+ . getThemeJsonInFrontend ( options , themeDefinition );
286284
287285 JsonObject contentsInStats = statsJson .getObject ("themeJsonContents" );
288286 if (contentsInStats == null && (!themeJsonContents .isEmpty ()
@@ -307,16 +305,29 @@ private static boolean themeConfigurationChanged(Options options,
307305 }
308306
309307 List <String > missedKeys = new ArrayList <>();
310- JsonObject content = Json .parse (contentsInStats .getString (key ));
311- if (!objectIncludesEntry (content , projectThemeJson .get (),
308+ JsonObject themeJsonContent = Json
309+ .parse (contentsInStats .getString (key ));
310+ if (!objectIncludesEntry (themeJsonContent , projectThemeJson .get (),
312311 missedKeys )) {
313312 getLogger ().info (
314313 "Project custom theme '{}' has imports/assets in 'theme.json' not present in the bundle" ,
315314 projectThemeName );
316- Collections .reverse (missedKeys );
317- logChangedFiles (missedKeys , "Detected missed entries:" );
315+ logMissedEntries (missedKeys );
318316 return true ;
319317 }
318+
319+ Optional <String > parentThemeInFrontend = FrontendUtils
320+ .getParentThemeNameInFrontend (
321+ options .getFrontendDirectory (),
322+ projectThemeJson .get ());
323+ if (parentThemeInFrontend .isPresent ()) {
324+ String parentThemeName = parentThemeInFrontend .get ();
325+ Optional <JsonObject > themeJson = FrontendUtils
326+ .getThemeJsonInFrontend (options .getFrontendDirectory (),
327+ parentThemeName );
328+ themeJson .ifPresent (jsonObject -> themeJsonContents
329+ .put (parentThemeName , jsonObject ));
330+ }
320331 }
321332
322333 for (Map .Entry <String , JsonObject > themeContent : themeJsonContents
@@ -333,8 +344,9 @@ private static boolean themeConfigurationChanged(Options options,
333344 if (!objectIncludesEntry (content , themeContent .getValue (),
334345 missedKeys )) {
335346 getLogger ().info (
336- "Packaged custom theme '{}' has imports/assets in 'theme.json' not present in the bundle" ,
347+ "Parent theme '{}' has imports/assets in 'theme.json' not present in the bundle" ,
337348 themeContent .getKey ());
349+ logMissedEntries (missedKeys );
338350 return true ;
339351 }
340352 }
@@ -564,6 +576,11 @@ private static void logChangedFiles(List<String> frontendFiles,
564576 getLogger ().info (message , handledFiles );
565577 }
566578
579+ private static void logMissedEntries (List <String > missedKeys ) {
580+ Collections .reverse (missedKeys );
581+ logChangedFiles (missedKeys , "Detected missed entries:" );
582+ }
583+
567584 private static void compareFrontendHashes (JsonObject frontendHashes ,
568585 List <String > faultyContent , String frontendFilePath ,
569586 String frontendFileContent ) {
@@ -856,24 +873,6 @@ private static void getPackagedThemeJsonContents(File jarFileToLookup,
856873 }
857874 }
858875
859- private static Optional <JsonObject > getContentForProjectThemeJson (
860- Options options , ThemeDefinition themeDefinition )
861- throws IOException {
862- if (themeDefinition != null ) {
863- String themeName = themeDefinition .getName ();
864- File projectThemeJson = new File (options .getFrontendDirectory (),
865- Constants .APPLICATION_THEME_ROOT + "/" + themeName + "/"
866- + "theme.json" );
867- if (projectThemeJson .exists ()) {
868- String content = FileUtils .readFileToString (projectThemeJson ,
869- StandardCharsets .UTF_8 );
870- content = content .replaceAll ("\\ r\\ n" , "\n " );
871- return Optional .of (Json .parse (content ));
872- }
873- }
874- return Optional .empty ();
875- }
876-
877876 private static Logger getLogger () {
878877 return LoggerFactory .getLogger (TaskRunDevBundleBuild .class );
879878 }
0 commit comments