Web Resources Optimizer for Java (WRO4J) is used by Geonetwork for Javascript and CSS minification. This module has some customization to the out-of-the-box implementation. A few customizations are:
- Custom Wro Model Factory
- The factory uses a custom XML model file called
wro-sources.xml
which is based on thewro-sources.xsd
schema. The documentation for writing the XML file is in the XSD file. - This custom factory allows the Javascript files and dependencies to be declared in the file using
goog.provide
andgoog.require
declarations (see https://developers.google.com/closure/library/docs/introduction). In WRO4J lingo, allrequireJsSources
Javascript files found (seerequireJsSourceType
inwro-sources.xsd
) are parsed forgoog.provide
andgoog.require
files. The dependencies of each Javascript file will be included in the WRO4J group. All dependencies and the Javascript file will be minified together as one group and the dependency order will be maintained. - The factory will create a
closure_deps.js
file which is needed by closurebase.js
for determining which javascript files to load. This is used when in debug mode. - The model factory also allows an explicit ordering of Javascript files when that is required.
- Finally, the model factory allows
wro-sources.xml
files to be included in a rootwro-sources.xml
file. This allows thewro-sources.xml
to be kept in the module it applies to and just be included from theweb-app
module.
- The factory uses a custom XML model file called
- A Less Compiler that can handle both css and
less
files. - A Processor that removes
goog.provide
andgoog.require
(because they are not needed in the minified javascript because all dependencies are included) - Other support classes for Wro Model Factory are included in this module (like
ClosureDependencyUriLocator
)
wro-sources.xml
- Declares the javascript and css groups. Thewro-sources.xsd
contains information on how to write such a file. At the time of this writing there is a rootwro-sources.xml
file inweb/src/main/webResources/WEB-INF/wro-sources.xml
which includes:web-ui/src/main/resources/web-ui-wro-sources.xml
wro.properties
- The wro configuration. See https://code.google.com/p/wro4j/wiki/ConfigurationOptions for the list and description of properties in the file.web/pom.xml
- This file containsbuild/plugins/plugin
plugin forwro4j
which runs the minification and some minor checks on thewro4j
configuration during a build. The intention is to catch any major configuration errors at build time.