Skip to content
Jesse Eichar edited this page Jan 13, 2014 · 4 revisions
Date 2014-01-06 Contacts Jesse Eichar
Status Motion Passed - Done Release 2.12
Resources Jesse Eichar Ticket # https://github.com/geonetwork/core-geonetwork/issues/337
Source code https://github.com/geonetwork/core-geonetwork/tree/javascript_build
Funding N/A

Overview

Use Wro4j,protractor and jasmine (Web Resource Optimization for Java) for Javascript develop/test/minification/build in Geonetwork.

WRO4J (Web Resources Optimizer for Java)

At the moment YUI-compressor is used in web-client and web modules. Closure compiler, less and python are used in web-ui.

This makes the build process difficult and introducing new developer to the system can be confusing because they won't know what technology to use or how to debug.

We propose using Wro4J as the unified solution. Wro4J will be integrated into the build as a Servlet Filter bound to the /static/* path.

The main pertinent features of Wro4J are as follows:

  • Javascript and Css groups are defined and a single URL is used for both minified files and for non-minified files.
  • To obtain the non-minified Javascript or CSS a minimized=false parameter is added to the url. This simplifies the html file since only a single javascript or css link tag is needed for debug or production mode.
  • Minification is done as needed at run time. This allows one to make changes to the files and immediately test the minified javascript/css without rebuilding a module. This can also be done in production if desired. (Although by default the wro.properties file for production will not rebuild minified files unless the configuration is changed).
  • Automatically compile less files
  • Automatically process @import directives in CSS and LESS files
  • Create a Dependency graph by parsing goog.provide and good.require statements in the javascript.
  • This means the dependency management can be defined in the javascript files only. There is no need to manage the dependencies in the wro4j configuration files.
  • Wro4J is extremely configurable and extensible, which means it will be able to adapt to future requirements
  • There are many javascript and CSS minification technologies available to Wro4J including YUI and closure. (We use using Closure in Simple mode for Javascript minification, and Jawr's CSS minification library for CSS minification)

The benefits of Wro4J over the current technologies are as follows:

  • YUI

    • YUI configuration is hardcoded in pom.xml
    • Wro4j has the configuration in external file
    • This means that Configuration overrides can be used in the future to modify the javascript minification build
    • It also simplifies the pom files and makes the build simpler to understand
    • Rebuilding the module is required for new minified files
    • Wro4j minifies when a file is changed (in development mode)
    • YUI requires that all non-minified files are added to html page for debug mode
    • Wro4j requires only a parameter to be added for non-minfied (debug) mode
  • Closure/python build

    • Makes build more complex since python and closure must be installed and environment and Java system variables must be correctly set for the build to work
    • Wro4J is a Java only solution and adds no extra requirements when setting up a new develop or CI environment
    • Need to rebuild module to get new minified files
    • Wro4J will rebuild minified files when file changes allowing quick switching from debug mode (non minified files) to testing minified files.

Protractor for E2E testing

At the moment there is no automated UI testing. This proposal also includes using Protractor to run End to End tests (E2E). Protractor is based on selenium and Jasmine with extensions specific for testing AngularJS applications. The tests will be in the e2e-tests module and can be enabled or disable by enabling the e2e-tests profile.

Jasmine for Javascript unit tests

We can use the com.github.searls.jasmine-maven-plugin for running jasmine unit tests for our javascript logic.

Proposal Type

  • Type: Javascript build
  • Module: web, web-ui, web-client, wro4j, e2e-tests

Voting History

  • Vote Proposed: TBA

Participants

  • All
Clone this wiki locally