CSS Compiler
CSS files are stored in a directory structure that mirrors the JavaScript class packages:
+- src/
+- main/
+- css/
+- com/
+- myapp/
+- MyClass/
|
+- MyClass.css
+- icon.png
+- arrow.png
Pass the CSS compiler a JavaScript file to compile and instead of writing out the contents of the various included JavaScript files, it looks on the filesystem and classpath for CSS files instead.
// If you have a theme, tell the compiler
String theme = null;
// The input file is the page file.
URL inputFile = new URL("file:///path/to/file.js");
// This is the package that holds the page files for my application
String pagePackage = "myapp.page";
// This is where the compiled JavaScript will get written to
OutputStream outputStream = new FileOutputStream(File.createTempFile("foo", "css"));
// These are any base styles that my application needs
String[] includes = new String[] {
"src/main/webapp/css/reset.css",
"src/main/webapp/css/common.css"
};
// This is where the compiler should search for source files in addition to the classpath
String[] sourceRoots = new String[] {
"src/main/javascript"
};
Compiler compiler = new CSSCompiler(theme, includes);
compiler.compile(url, pagePackage, outputStream, sourceRoots);