Maven Handbook
Purpose: This document is help you how to installing maven andinstalling 3rd party JARs
1. Guide to installing Maven
InstallMaven on Windows
1. JDK and JAVA_HOME
Make sure JDK is installed, and “JAVA_HOME” variable is addedin Windows environment variable, and point to the JDK folder.
2. DownloadApache Maven
Visit thisMaven official website:http://maven.apache.org/download.cgi,choosea version and click on the download link, e.g.apache-maven-3.2.1-bin.zip
3. Extract It
Extract the downloaded zip file. In this case, we extractedto c driver and renamed the folder, e.g.C:\Maven.
4. Add MAVEN_HOME
Add a new “MAVEN_HOME” variable to the Windows environment,and point it to your Maven folder.
5. Verification
To verify Maven if installed is correctly, in command prompt,type “mvn -version”.
6. Configuring Maven
a. Configuring your local repository
Please update the configuration setting.xml(C:\Tools\Maven\apache-maven-3.1.0\conf).The location of your local repository can be changed in your userconfiguration. The default value is ${user.home}/.m2/repository/.
<localRepository>C:/M3/repository</localRepository>
b. If you have not installed Eclipse. Recommended Eclipse4.3.0 and above. It integrated with Maven plugin.
Download link https://www.eclipse.org/downloads
c. If you have installed Eclipse, but it’s not integratedMaven function.
Open Eclipse, please choose “Help” > “Install NewSoftware…”, then type the following link to download the Maven plugin.
http://download.eclipse.org/technology/m2e/releases/1.2/1.2.0.20120903-1050
If installed ok, Choose “Windows” > “Preferences” >“Maven”
Please select the settings.xml for your installed the mavenpath.
7. Import Maven project
Choose “File” > “Import” > “Existing MavenProjects”
8. Maven Command
Compilethe application: clean package install
Packagethe project: clean package package
For jetty:Start the application: clean jetty:run
ForTomcat: Start the application: clean tomcat7:run
2. Guideto installing 3rd party JARs
1.Please prepares the JAR on your local machine
eg: C:\M3\ext\kacdr\sqlframework.jar
2. Please usesmaven command to install the JAR to your local repository.
eg: mvn install:install-file-DgroupId=com.cathaypacific.sqlframework -DartifactId=sqlframework-Dversion=1.0 -Dpackaging=jar -Dfile=C:\M3\ext\kacdr\sqlframework.jar -DgeneratePom=true
3.Configure the dependency on the pom.xml file.
<dependency>
<groupId>com.cathaypacific.sqlframework</groupId>
<artifactId>sqlframework</artifactId>
<version>1.0</version>
</dependency>
4. Right click the project “KACrewDirectRequests”, select“Maven” > “Update Project…”
mvninstall:install-file -DgroupId=com.cathaypacific.sqlframework-DartifactId=sqlframework -Dversion=1.0 -Dpackaging=jar-Dfile=C:\M3\ext\kacdr\sqlframework.jar -DgeneratePom=true
5. Find Bugs uses static analysis to identify hundreds ofdifferent potential types of errors in Java programs.
Find Bugs for maven project:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<findbugsXmlOutput>true</findbugsXmlOutput>
<findbugsXmlWithMessages>true</findbugsXmlWithMessages>
<xmlOutput>true</xmlOutput>
<findbugsXmlOutputDirectory>target/site</findbugsXmlOutputDirectory>
</configuration>
</plugin>
3. Configuring localdev for CSC Maven project
1. Selectthe project, right click “Run As” > “Run Configurations…” , please add theparameter as the following:
Name=spring.profiles.default
Value=local_dev
2. Please add the comment for the following parameter on the Web.xml
<!--
<context-param>
<param-name>spring.profiles.default</param-name>
<param-value>dev</param-value>
</context-param>
-->
-server -Xms256m -Xmx512m -XX:PermSize=256m-XX:MaxPermSize=256m -XX:+CMSClassUnloadingEnabled -XX:+PrintGCDetails-Xloggc:%M2_HOME%/gc.log -XX:+HeapDumpOnOutOfMemoryError-XX:HeapDumpPath=%M2_HOME%/java_pid<pid>.hprof