Sunday 5 October 2014

Adding 3rd Party jar to maven dependency.

Due to the licensing issues all the jar files may not be available in the maven repository, in that case you need to manually download the jar file and add it to the maven dependency.

Above content is framed based on the content present in the below url.
http://www.mkyong.com/maven/how-to-add-oracle-jdbc-driver-in-your-maven-local-repository/

Below is the url for installing 3rd party jar file with maven.
http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html

Steps for integrating and adding dependency  for 'AH-DDF-4.1.jar' with maven:
1. Eclipse project with out 'AH-DDF-<<Version>>.jar' integerated.

 2. Default 'pom.xml'

3. Right click on project select 'Properties' --> 'Java Build Path'

4. Default maven local repository.

5. Copy the 'AH-DDF-4.1.jar' file into the root folder of the project.

6. Open the root folder in the command prompt.
  

7. Execute the below command in command prompt(i.e. copy & paste the below command in the command prompt and press enter).
mvn install:install-file -Dfile=AH-DDF-4.1.jar -DgroupId=AH-DDF -DartifactId=AH-DDF -Dversion=4.1 -Dpackaging=jar   


8. After performing step7, 'AH-DDF-4.1.jar' is added to the maven local repository.

9. Add the below dependency in 'pom.xml' and save the file.
    <dependency>
      <groupId>AH-DDF</groupId>
      <artifactId>AH-DDF</artifactId>
      <version>4.1</version>     
    </dependency>
 
 
10. Run the command 'mvn eclipse:eclipse' in command prompt

 Note: Run the 'mvn eclipse:eclipse' command and restart the eclipse, if updated jar reference(i.e. AH-DDF-4.1.jar) is not reflecting in java build path of maven.


11. Restart the eclipse ide and right click on project select 'Properties' --> 'Java Build Path'.
      Now you can see the 'AH-DDF-4.1.jar' is updated in java build path of maven.
 

 12. Copy 'examples' folder under 'src/test/java' or 'src/main/java'

13. Update file path of excel file(i.e. workbook file)

14. Add the below dependency to pom.xml
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>3.10-FINAL</version>
    </dependency>

    <dependency>
        <groupId>dom4j</groupId>
        <artifactId>dom4j</artifactId>
        <version>1.6.1</version>
    </dependency>

    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>3.10-FINAL</version>
    </dependency>

    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml-schemas</artifactId>
        <version>3.10-FINAL</version>
    </dependency>
          
    <dependency>
        <groupId>org.apache.xmlbeans</groupId>
        <artifactId>xmlbeans</artifactId>
        <version>2.3.0</version>
    </dependency> 
 
15. Run the command 'mvn eclipse:eclipse' in command prompt.
 Note: Run the 'mvn eclipse:eclipse' command and restart the eclipse, if updated jar reference(i.e. POI API jars and other jar files) is not reflecting in java build path of maven.
    Refer step 10
 
16. Restart the eclipse ide and right click on project select 'Properties' --> 'Java Build Path'.
     Now you can see the updated jar's of POI API and other jars in java build path of maven.
    Refer step 11
   
17. Execute the program, after verifying 'AH-DDF-4.1.jar', POI API jars and other jars in the java build path of maven.


18. Output (i.e result)

No comments:

Post a Comment