17.08.2016 Views

Apache Maven 3 Cookbook

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 5<br />

│<br />

└───WEB-INF<br />

└───target<br />

├───classes<br />

├───maven-archiver<br />

├───surefire<br />

└───testWebApp<br />

├───META-INF<br />

└───WEB-INF<br />

└───classes<br />

You can run the commands to compile and test the project.<br />

$ mvn compile<br />

$ mvn test<br />

$ mvn install<br />

On installation, it will be packaged and deployed in the local repository like any other <strong>Maven</strong><br />

project. It can also be deployed into a remote repository.<br />

There's more...<br />

If you have a look, you will find the project source/main/webapp folder consisting of<br />

index.jsp. Make suitable changes to that file such as adding some HTML:<br />

<br />

<br />

Hello World!<br />

<br />

<br />

Now that we have the build phase plugin set up, we can proceed to built the project:<br />

$ mvn install<br />

After a successful build, the target folder has been generated. In the target folder, you will<br />

find a WAR file named testWebApp.war. Take a closer look at the project POM file and<br />

you will find that the packaging in there will be set to WAR and the final artifact reflects this<br />

packaging property:<br />

...<br />

testWebApp<br />

war<br />

1.0-SNAPSHOT<br />

...<br />

99

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

Saved successfully!

Ooh no, something went wrong!