]> source.dussan.org Git - vaadin-framework.git/commitdiff
Ensure addon css styles are before scss styles in addons.scss #11390
authorJohn Ahlroos <john@vaadin.com>
Thu, 18 Apr 2013 09:37:06 +0000 (12:37 +0300)
committerVaadin Code Review <review@vaadin.com>
Thu, 18 Apr 2013 12:51:39 +0000 (12:51 +0000)
Change-Id: I3737a94f076917cd896bd90e2936a5b752ccd801

client-compiler/src/com/vaadin/server/themeutils/SASSAddonImportFileCreator.java

index 98ce639d168fec7c8d3a18456c073d7e9c764dff..5cec9bd9d5bb58979003b334293af5b4984453b2 100644 (file)
@@ -21,6 +21,10 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.PrintStream;
 import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
 import java.util.Map;
 
 import com.vaadin.server.widgetsetutils.ClassPathExplorer;
@@ -89,8 +93,29 @@ public class SASSAddonImportFileCreator {
             printStream.println();
 
             Map<String, URL> addonThemes = info.getAddonStyles();
-            for (String path : addonThemes.keySet()) {
+
+            // Sort addon styles so that CSS imports are first and SCSS import
+            // last
+            List<String> paths = new ArrayList<String>(addonThemes.keySet());
+            Collections.sort(paths, new Comparator<String>() {
+
+                @Override
+                public int compare(String path1, String path2) {
+                    if (path1.toLowerCase().endsWith(".css")
+                            && path2.toLowerCase().endsWith(".scss")) {
+                        return -1;
+                    }
+                    if (path1.toLowerCase().endsWith(".scss")
+                            && path2.toLowerCase().endsWith(".css")) {
+                        return 1;
+                    }
+                    return 0;
+                }
+            });
+
+            for (String path : paths) {
                 addImport(printStream, path, addonThemes.get(path));
+                printStream.println();
             }
 
         } catch (FileNotFoundException e) {