I got this sorted.
Intellij -> Select Module -> Open Module Setting -> Dependency -> Add Dependency -> select the external jar -> Scope to be test only.
This way it is working fine for test case and at the same time not being used in actual main code.
Where to keep the jar ?
Given its going to be used in test cases, I would suggest commit the jar in src/test/lib and select this path while adding dependency.
Intellij generate the .iml file(which has a list of dependency) if you commit the same in your repo then other team member can easily use without any further setup.
Now question remains for linux env or CIT environment. I think we could add this jar via CLASSPATH env variable and then starting any CIT jobs.
Mix of solution but then its working as expected for me.
One more solution :
Install the external jar in local repo and add dependency in pom.xml with test scope. Easy option it is.
Installing jar on local repo :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>3.0.0-M1</version>
<executions>
<execution>
<id>install-jar</id>
<phase>initialize</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<file>${project.basedir}/src/test/lib/somejar-1.0.jar</file>
<groupId>com.beta.gamma</groupId>
<artifactId>somejar</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
</configuration>
</execution>
<executions>
</plugin>
Now same can be added as dependency as other dependency. This will work on environments.