Add DB2 to maven project

Unfortunately adding below dependencies to pom.xml is not enough for db2 since there is no public maven repository for it.
<dependency>
    <groupId>com.ibm.db2.jcc</groupId>
    <artifactId>db2jcc4</artifactId>
    <version>10.1</version>
</dependency>
<dependency>
    <groupId>com.ibm.db2</groupId>
    <artifactId>db2jcc_license_cu</artifactId>
    <version>10.5</version>
</dependency>
We need to add the jar files to our local maven repository. So if my directory structure looks like this:
.
├── MyMavenProject
│   ├── pom.xml
│   └── src
└── db2-connector
    ├── db2jcc4.jar
    └── db2jcc_license_cu.jar
Then I can do:
cd MyMavenProject

mvn install:install-file -Dfile=../db2-connector/db2jcc4.jar -DgroupId=com.ibm.db2.jcc -DartifactId=db2jcc4 -Dversion=10.1 -Dpackaging=jar -DgeneratePom=true -DcreateChecksum=true

mvn install:install-file -Dfile=db2jcc_license_cu.jar -DgroupId=com.ibm.db2 -DartifactId=db2jcc_license_cu -Dversion=10.5 -Dpackaging=jar -DgeneratePom=true -DcreateChecksum=true

Done! For Reference this is what I always have in my pom.xml so I remember what to do :)
<!-- Install previously: -->
<!-- mvn install:install-file -Dfile=../db2-connector/db2jcc4.jar -DgroupId=com.ibm.db2.jcc -DartifactId=db2jcc4 -Dversion=10.1 -Dpackaging=jar -DgeneratePom=true -DcreateChecksum=true -->
<dependency>
    <groupId>com.ibm.db2.jcc</groupId>
    <artifactId>db2jcc4</artifactId>
    <version>10.1</version>
</dependency>
<!-- Install previously: -->
<!-- mvn install:install-file -Dfile=db2jcc_license_cu.jar -DgroupId=com.ibm.db2 -DartifactId=db2jcc_license_cu -Dversion=10.5 -Dpackaging=jar -DgeneratePom=true -DcreateChecksum=true -->
<dependency>
    <groupId>com.ibm.db2</groupId>
    <artifactId>db2jcc_license_cu</artifactId>
    <version>10.5</version>
</dependency>

0 comments :

This work is licensed under BSD Zero Clause License | nacho4d ®