Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
#504 reorder the plugin includes a little so we add the core/jmx stuf…
…f up front first to avoid ordering issues
  • Loading branch information
jstrachan committed Nov 15, 2013
1 parent b347e00 commit b0518e8
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions hawtio-web/src/test/java/io/hawt/web/tool/GenerateDevFiles.java
Expand Up @@ -20,14 +20,13 @@
import io.hawt.sample.Main;
import io.hawt.util.IOHelper;

import javax.annotation.Generated;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.Callable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
* Generate the developer HTML files using the individual JS files
Expand All @@ -38,6 +37,7 @@ public class GenerateDevFiles {
private final File outputDir;
private Set<String> jsFiles = new TreeSet<String>();
private String devIndexHtml = "index-dev.html";
private List<String> jsFileList;

public static void main(String[] args) {
String outputDir = Main.getWebAppOutputDir();
Expand Down Expand Up @@ -74,10 +74,30 @@ public void run() throws IOException {
}
}
}

reorderFiles();
generateDevIndexHtml();
}

protected void reorderFiles() {
jsFileList = new ArrayList<String>();

// lets add things in plugin order
String[] pluginOrder = {"core", "jmx", "log", "tree", "branding"};
for (String plugin : pluginOrder) {
String prefix = "app/" + plugin + "/";
Iterator<String> iterator = jsFiles.iterator();
while (iterator.hasNext()) {
String jsFile = iterator.next();
if (jsFile.startsWith(prefix)) {
jsFileList.add(jsFile);
iterator.remove();
}
}
}

jsFileList.addAll(jsFiles);
}

public static void assertDirectoryExists(File appSourceDir, String kind) {
if (!appSourceDir.exists()) {
throw new IllegalStateException("No " + kind + " at: " + appSourceDir.getAbsolutePath());
Expand All @@ -104,7 +124,6 @@ protected void generateDevIndexHtml() throws IOException {
throw new IllegalStateException("Could not find the script tag: " + scriptTag + " in " + indexHtml.getAbsolutePath());
}
StringBuilder buffer = new StringBuilder(html.substring(0, idx));

addScriptTags(buffer);
buffer.append(html.substring(idx + scriptTag.length()));
String newHtml = buffer.toString();
Expand All @@ -114,7 +133,7 @@ protected void generateDevIndexHtml() throws IOException {
}

protected void addScriptTags(StringBuilder buffer) {
for (String jsFile : jsFiles) {
for (String jsFile : jsFileList) {
buffer.append("<script type=\"text/javascript\" src=\"");
buffer.append(jsFile);
buffer.append("\"></script>");
Expand Down

0 comments on commit b0518e8

Please sign in to comment.