17.08.2016 Views

Apache Maven 3 Cookbook

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 2<br />

You should get an output similar to:<br />

------------------------------------------------------------------<br />

[INFO] Reactor Summary:<br />

[INFO] MyLargeModularApp ........................ SUCCESS [0.439s]<br />

[INFO] MyModuleJar .............................. SUCCESS [3.047s]<br />

[INFO] MyModuleWar <strong>Maven</strong> Webapp ................. SUCCESS [0.947s]<br />

------------------------------------------------------------------<br />

[INFO] BUILD SUCCESS<br />

------------------------------------------------------------------<br />

Dependency management<br />

Dependency management can be universally acknowledged as one of the best features of<br />

<strong>Apache</strong> <strong>Maven</strong>. In Multi-modular projects, where dependencies can run into tens or even<br />

hundreds, <strong>Apache</strong> <strong>Maven</strong> excels in allowing you to retain a high degree of control and stability.<br />

<strong>Apache</strong> <strong>Maven</strong> dependencies are transient, which means <strong>Maven</strong> will automatically discover<br />

artifacts that your dependencies require. This feature has been available since <strong>Maven</strong> 2, and<br />

it especially comes in handy for many of the open source project dependencies we have in<br />

today's enterprise projects.<br />

Getting ready<br />

<strong>Maven</strong> dependencies have six possible scopes:<br />

ff<br />

ff<br />

ff<br />

ff<br />

ff<br />

ff<br />

Compile: This is the default scope. Compile dependencies are available in<br />

the classpaths.<br />

Provided: This scope assumes that the JDK or the environment provides<br />

dependencies at runtime.<br />

Runtime: Dependencies that are required at runtime and are specified in the<br />

runtime classpaths.<br />

Test: Dependencies required for test compilation and execution.<br />

System: Dependency is always available, but the JAR is provided nonetheless.<br />

Import: Imports dependencies specified in POM included via the<br />

element.<br />

31

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!