Skip to content

Maven build

Sven Loesekann edited this page Apr 21, 2017 · 11 revisions

Build an optimized ear

The maven build is done according to the archetype of JBoss for ear packages.

Ear project

In the ear project the war and ejb dependencies bundled by the maven ear plugin into an ear package for deployment.

Ejb project

In the ejb project the sources and resources are build and bundled in a ejb jar.

War project

In the war project are several steps performed.

  1. The directories dist/ and node_modules are cleaned

  2. The directory src/main/angular2 is copied to target (without dependencies only a few kb)

  3. In target/angular2/carrental/ npm install is called to resolve the dependencies

  4. In target/angular2/carrental/ ng build --prod --base-href "/carrental-web/" is called to build an optimized bundle. (--base-href is needed to set baseref)

  5. In target/angular2/carrental/ ng test --browser PhantomJS --reporters junit --single-run is called to run the jasmine tests for the carrental application. If a test fails the junit reporter breaks the build.

  6. The war plugin includes the directories for the Angular Cli bundle and the translations and builds the war.

The command ng build --prod --base-ref "carrental-web" builds a tree shaken/uglified bundle with the right bref for routing to work. Angular Cli will offer the --aot option for further optimization and splitting of the bundle according to routes. That will get the initial load even further down.

The command ng test --browser PhantomJS --reporters junit --single-run runs the Jasmine tests of the Angular 2 Application once on the PhantomJS browser. The PhantomJS browser is headless and can be used as npm dependency to run the tests on. The junit reporter of Karma returns a Junit Xml file to Maven that breaks the build if one of the tests fails. The Parameter --single-run tells Karma to run the tests once and then exit so that a build server has not stale processes in the background.

To build the application execute 'mvn clean install'.

Clone this wiki locally