7.5 Adding the dependency plugin

Maven now successfully builds the PAR for your application, however the dependencies of the PAR are not apparent. In this step the Maven dependency plugin is added to collect the transitive dependency graph for the PAR.

In the <build><plugins>…</plugins></build> section (after the par plugin declaration), add a plugin declaration for the dependency plugin:


A dependency on Freemarker needs to be added to the other dependancies. This is required to ensure the Web bundle has the correct set of dependancies as well as the other bundles. Normally they would simply be resolved transitively from the bundle projects but the ‘war’ project does not pass on its dependancies; it expects them to be contained in its ‘lib’ directory. For this reason its dependancies must be given explicitly.

<!-- Required for the web bundle as dependancies are not propagated up from war build types -->

The next step is to stop the Web bundle including its dependancies in a lib directory as they will be provided by the runtime enviroment. Add the following build section to the greenpages.web POM file.


Run the following command.

mvn clean package

When the command has completed, it will have copied all of the PAR’s dependencies into the target/par-provided directory. The output from Maven should include lines like these

[INFO] [par:par]
[INFO] Assembling Artifacts for PAR '/Users/chrisfrost/Repos/GIT/greenpages/solution/
[INFO]   Added 'greenpages.app-solution.jar'
[INFO]   Added 'greenpages.jpa-solution.jar'
[INFO]   Added 'greenpages.db-solution.jar'
[INFO]   Added 'greenpages.web-solution.war'

If the dependencies are produced, proceed to the next step.