Your SlideShare is downloading. ×
0
Maven
Maven
Maven
Maven
Maven
Maven
Maven
Maven
Maven
Maven
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Maven

3,031

Published on

Tutorials for how to use maven as a build script.

Tutorials for how to use maven as a build script.

0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,031
On Slideshare
0
From Embeds
0
Number of Embeds
9
Actions
Shares
0
Downloads
75
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Apache Maven
  • 2. Apache Maven <ul><li>This presentation to illustrate how to use maven for build scripts </li></ul><ul><li>It always difficult for developers where and how to start a simple example to understand to write maven script for the projects. </li></ul><ul><li>I try to show in this presentation how we can leverage the maven for build scripts. </li></ul><ul><li>If you unable to follow or understand the process, Please do contact me at below details. </li></ul><ul><li>E-mail: [email_address] </li></ul><ul><li> www.ravireddyjsf.blogspot.com </li></ul><ul><li> Ravi Reddy ( [email_address] ) </li></ul>
  • 3. Apache Maven <ul><li>Java Project </li></ul><ul><li> We start to build a simple jar for a Java project in Eclipse IDE </li></ul><ul><li> </li></ul><ul><ul><li>Create a simple MavenJavaDemo java project in the eclipse make sure your project structure (circled in red color) and build path should look similar shown in below figures. </li></ul></ul>
  • 4. Apache Maven <ul><li>POM.xml </li></ul><ul><li><project xmlns= &quot;http://maven.apache.org/POM/4.0.0&quot; </li></ul><ul><li> xmlns:xsi= &quot;http://www.w3.org/2001/XMLSchema-instance&quot; </li></ul><ul><li> xsi:schemaLocation= &quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd&quot; > </li></ul><ul><li><modelVersion>4.0.0</modelVersion> </li></ul><ul><li><groupId>ravi-demos.com.maven.demo</groupId> </li></ul><ul><li><artifactId>MavenJavaDemo</artifactId> </li></ul><ul><li><packaging>jar</packaging> </li></ul><ul><li><version>0.0.1-SNAPSHOT</version> </li></ul><ul><li><name>Example for build script- Maven </name> </li></ul><ul><li><description>Example to create a build script using maven </description> </li></ul><ul><li><!-- Add Java 1.6 plugin --> </li></ul><ul><li><build> </li></ul><ul><li> <plugins> </li></ul><ul><li> <plugin> </li></ul><ul><li><groupId>org.apache.maven.plugins</groupId> </li></ul><ul><li><artifactId> maven -compiler- plugin </artifactId> </li></ul><ul><li><configuration> </li></ul><ul><li> <source>1.6</source> </li></ul><ul><li> <target>1.6</target> </li></ul><ul><li></configuration> </li></ul><ul><li> </plugin> </li></ul><ul><li></plugins> </li></ul><ul><li></build> </li></ul><ul><li></project> </li></ul>
  • 5. Apache Maven <ul><li>Web Application Project </li></ul><ul><li>In this tutorial we build a simple *.war file for a Web application project in Eclipse IDE </li></ul><ul><li>Create a simple MavenWebAppDemo java project in the eclipse make sure your project structure (circled in red color) and build path should look similar shown in below figures. </li></ul>
  • 6. Apache Maven <ul><li>POM.xml </li></ul><ul><ul><li><project xmlns= &quot;http://maven.apache.org/POM/4.0.0&quot; </li></ul></ul><ul><ul><li> xmlns:xsi= &quot;http://www.w3.org/2001/XMLSchema-instance&quot; </li></ul></ul><ul><ul><li> xsi:schemaLocation= &quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd&quot; > </li></ul></ul><ul><ul><li><modelVersion>4.0.0</modelVersion> </li></ul></ul><ul><ul><li><groupId>ravi-demos.com.maven.demo</groupId> </li></ul></ul><ul><ul><li><artifactId>MavenWebAppDemo</artifactId> </li></ul></ul><ul><ul><li><packaging>war</packaging> </li></ul></ul><ul><ul><li><name>Example for maven build script for web app </name> </li></ul></ul><ul><ul><li><version>0.0.1-SNAPSHOT</version> </li></ul></ul><ul><ul><li><description>Example for maven build script for web application</description> </li></ul></ul><ul><ul><li><!-- Adding dependency jars required for the project. --> </li></ul></ul><ul><ul><li><dependencies> </li></ul></ul><ul><ul><li><dependency> </li></ul></ul><ul><ul><li> <groupId>javax.servlet</groupId> </li></ul></ul><ul><ul><li> <artifactId> servlet - api </artifactId> </li></ul></ul><ul><ul><li> <version>2.4</version> </li></ul></ul><ul><ul><li> <scope>provided</scope> </li></ul></ul><ul><ul><li></dependency> </li></ul></ul><ul><ul><li></dependencies> </li></ul></ul><ul><ul><li><build> </li></ul></ul><ul><ul><li><plugins> </li></ul></ul><ul><ul><li><plugin> </li></ul></ul><ul><ul><li><groupId>org.apache.maven.plugins</groupId> </li></ul></ul><ul><ul><li><artifactId> maven -war- plugin </artifactId> </li></ul></ul><ul><ul><li><configuration> </li></ul></ul>
  • 7. Apache Maven <ul><li><webResources> </li></ul><ul><li><resource> </li></ul><ul><ul><li><directory>${ basedir }/ src /main/java</directory> </li></ul></ul><ul><ul><li><targetPath>WEB-INF/classes</targetPath> </li></ul></ul><ul><ul><li> <includes> </li></ul></ul><ul><ul><li> <include>**/*.properties</include> </li></ul></ul><ul><ul><li> <include>**/*. xml </include> </li></ul></ul><ul><ul><li> <include>**/*. jsp </include> </li></ul></ul><ul><ul><li> </includes> </li></ul></ul><ul><ul><li></resource> </li></ul></ul><ul><li></webResources> </li></ul><ul><li></configuration> </li></ul><ul><li></plugin> </li></ul><ul><li><plugin> </li></ul><ul><li><artifactId> maven -compiler- plugin </artifactId> </li></ul><ul><li><configuration> </li></ul><ul><li><source>1.6</source> </li></ul><ul><li><target>1.6</target> </li></ul><ul><li></configuration> </li></ul><ul><li></plugin> </li></ul><ul><li></plugins> </li></ul><ul><li></build> </li></ul><ul><li></project> </li></ul>
  • 8. Apache Maven <ul><li>Enterprise (EAR) Application Project </li></ul><ul><li>In this tutorial we build a simple *.ear file for a Enterprise application project in Eclipse IDE </li></ul><ul><li>Create a simple MavenEarDemo java project in the eclipse make sure your project structure (circled in red color) and build path should look similar shown in below figures. </li></ul>
  • 9. Apache Maven <ul><li>POM.xml </li></ul><ul><li><project xmlns= &quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi= &quot;http://www.w3.org/2001/XMLSchema-instance&quot; </li></ul><ul><li> xsi:schemaLocation= &quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd&quot; > </li></ul><ul><li><modelVersion>4.0.0</modelVersion> </li></ul><ul><li><groupId>ravi-demos.com.maven.demo</groupId> </li></ul><ul><li><artifactId>MavenEarDemo</artifactId> </li></ul><ul><li><packaging>ear</packaging> </li></ul><ul><li><name>Example for maven build script for ear app</name> </li></ul><ul><li><version>0.0.1-SNAPSHOT</version> </li></ul><ul><li><description>Example for build script for ear application</description> </li></ul><ul><li><!-- Adding dependency jars required for the project. --> </li></ul><ul><li><dependencies> </li></ul><ul><li><!-- Web module to be bundled in EAR --> </li></ul><ul><ul><li><dependency> </li></ul></ul><ul><ul><li><groupId>ravi-demos.com.maven.demo</groupId> </li></ul></ul><ul><ul><li><artifactId>MavenWebAppDemo</artifactId> </li></ul></ul><ul><ul><li><version>0.0.1-SNAPSHOT</version> </li></ul></ul><ul><ul><li><type>war</type> </li></ul></ul><ul><ul><li></dependency> </li></ul></ul><ul><ul><li><!-- EJB/Jar module to be bundled in EAR --> </li></ul></ul><ul><ul><li><dependency> </li></ul></ul><ul><ul><li><groupId>ravi-demos.com.maven.demo</groupId> </li></ul></ul><ul><ul><li><artifactId>MavenJavaDemo</artifactId> </li></ul></ul><ul><ul><li><version>0.0.1-SNAPSHOT</version> </li></ul></ul><ul><ul><li><scope>provided</scope> </li></ul></ul><ul><ul><li></dependency> </li></ul></ul><ul><li></dependencies> </li></ul>
  • 10. Apache Maven <ul><li><build> </li></ul><ul><li><plugins> </li></ul><ul><ul><li><plugin> </li></ul></ul><ul><ul><li><groupId>org.apache.maven.plugins</groupId> </li></ul></ul><ul><ul><li><artifactId>maven-ear-plugin</artifactId> </li></ul></ul><ul><ul><li><configuration> </li></ul></ul><ul><ul><li><manifestFile>src/main/application/META-INF/MANIFEST.MF</manifestFile> </li></ul></ul><ul><ul><li><earSourceDirectory>src/main/application/</earSourceDirectory> </li></ul></ul><ul><ul><li><earSourceExcludes>META-INF/MANIFEST.MF</earSourceExcludes> </li></ul></ul><ul><ul><li><modules> </li></ul></ul><ul><ul><ul><li><webModule> </li></ul></ul></ul><ul><ul><ul><li><groupId>ravi-demos.com.maven.demo</groupId> </li></ul></ul></ul><ul><ul><ul><li><artifactId>MavenWebAppDemo</artifactId> </li></ul></ul></ul><ul><ul><ul><li><contextRoot>/MavenWebAppDemo-0.0.1-SNAPSHOT</contextRoot> </li></ul></ul></ul><ul><ul><ul><li><bundleFileName>MavenWebAppDemo-0.0.1-SNAPSHOT.war</bundleFileName> </li></ul></ul></ul><ul><ul><ul><li></webModule> </li></ul></ul></ul><ul><ul><li></modules> </li></ul></ul><ul><ul><li></configuration> </li></ul></ul><ul><ul><li></plugin> </li></ul></ul><ul><ul><li><plugin> </li></ul></ul><ul><ul><li><artifactId>maven-compiler-plugin</artifactId> </li></ul></ul><ul><ul><li><configuration> </li></ul></ul><ul><ul><li><source>1.6</source> </li></ul></ul><ul><ul><li><target>1.6</target> </li></ul></ul><ul><ul><li></configuration> </li></ul></ul><ul><ul><li></plugin> </li></ul></ul><ul><li></plugins> </li></ul><ul><li></build> </li></ul><ul><li></project> </li></ul>

×