Showing posts with label maven. Show all posts
Showing posts with label maven. Show all posts

Sunday, January 11, 2015

Maven Install


For Windows:

  • You need a Java Development Kit (JDK).
  • Explode maven. say C:\Program Files\Apache Software Foundation/apache-maven-X.X.X
  • Add the following environment variables.
    • Set JAVA_HOME=C:\Program Files\Java\jdk-X.X.X
    • Set Path=%Path%;%JAVA_HOME%\bin
    • Set M2_HOME=C:\Program Files\Apache Software Foundation\apache-maven-X.X.X
    • Set M2=%M2_HOME%\bin
    • Set Path=%Path%;%M2%
  • Run mvn --version

For Linux:

~$ tar -xzvf apache-maven-x.y.z-bin.tar.gz
~$ sudo cp -R /extracted/path/to/maven/apache-maven-x.y.z /usr/local
~$ cd /usr/local/apache-maven-x.y.z/bin/
~$ sudo ln -s /usr/local/apache-maven-x.y.z/bin/mvn /usr/bin/mvn

Saturday, October 5, 2013

Add Oracle driver to Maven

  1. Download driver ojdbc6.jar from oracle.
  2. Install driver to maven local repository with the following command.
  3. mvn install:install-file -Dfile={driver/path/ojdbc.jar} -DgroupId=com.oracle 
    -DartifactId=ojdbc6 -Dversion=11.2.0 -Dpackaging=jar
  4. Copy following to your pom.xml.
    <!-- Oracle DB driver -->
    <dependency>
     <groupId>com.oracle</groupId>
     <artifactId>ojdbc6</artifactId>
     <version>11.2.0</version>
    </dependency>
    

Sunday, June 2, 2013

Maven ( POM ) Best Practices


  • Make the build reproducible
    • Always specify a version for Maven2 plugins
    • Minimize number of SNASPHOT dependencies
    • Use dependency management section
    • Beware of relocation in maven repo
    • After a dependency modification, double check the produced artifacts
  • Use and abuse of modules
    • more “technical/layered”
    • more business oriented
  • Make the build maintainable
    • Prefer default directory layout
    • Avoid duplication by moving common tags to parent pom
    • Always specify a version of dependencies in a parent pom
    • Use Properties Liberally
    • Minimize the number of Profiles
  • Make the build portable
    • Don’t commit eclipse and maven artifacts
    • Don't modify pom/artifactsin your "enterprise" repository

Additionally:
  • Make use of maven-resources-plugin. E.g. As below in pom.
<plugin>
<!-- http://maven.apache.org/plugins/maven-resources-plugin/ -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<configuration>
<delimiters>
<delimiter>@*@</delimiter>
</delimiters>
<useDefaultDelimiters>false</useDefaultDelimiters>
<nonFilteredFileExtensions> 
<nonFilteredFileExtension>xls</nonFilteredFileExtension> 
<nonFilteredFileExtension>xlsx</nonFilteredFileExtension> <nonFilteredFileExtension>pdf</nonFilteredFileExtension> 
</nonFilteredFileExtensions>
</configuration>
</plugin>