top of page

Maven : Know-how !

  • Writer: khyati sehgal
    khyati sehgal
  • Aug 7, 2014
  • 2 min read

To build the Enterprise Edition applications we use Maven.

Please download and install Maven. The build is tested with version 2.2.1 and 2.0.9.

The maven build should be able to set up the sources out of the box. The build should construct all components of the application (e.g. Java Archives, Web application archives, Flex application, etc.) automatically and consolidate them to deployable packages.

The architecture of the maven project

  1. src/main You can make partitioning of your project by keeping all the feature-specific files in the main package.

  2. src/test You can make segregation of your project by storing all the files having unit tests, integration tests, end to end tests in the test package.

  3. pom.xml This is an XML file in which you can put various important parts of your project like profiles, configurations, dependencies, etc.

  4. The main advantage of POM is that you can download dependencies by putting it here. No need to add separate jars, apart from all others which are creating artifacts, defining goals, versions, snapshots, configurations of your project.

Managing memory

Maven uses a lot of jar files that are downloaded from repositories to a local cache the first time the build is run. The first build may take quite a while for that reason.

Sometimes maven takes up a lot of memory to build and runs out of memory. To avoid this problem, please set the following variable in your environment.

(windows start button -> settings -> control panel -> system -> advanced -> environment variables -> system variables -> new):

name: MAVEN_OPTS value: -Xmx768M

Conversion of Java project into Maven specific project via Eclipse IDE

  1. For this, you need to import the Java project in the eclipse IDE.

File–> Import –> Select .

Type ‘project’ in the search bar, then select ‘Existing projects into Workspace’ under the ‘General category.

  1. Once the project is imported in your workspace in Eclipse IDE, right-click on the project.

  2. Click on ‘Configure’ option –> ‘Convert to Maven project’.

By doing the above steps you can get a pom.xml in your project and you are done with the conversion.

The basic structure of POM.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>java</groupId>
  <artifactId>java</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>java</name>
  <description>java</description>
</project>

DISCLAIMER Before doing this make sure you have installed MAVEN in your Eclipse IDE from Eclipse Market Place.

Else you will not get the required capabilities.

Comments


bottom of page