Roy Justin
Roy Justin

Reputation: 663

Maven install 3rd party dependency in build process

I have a 3rd party dependency jar which need to be installed in order to build my project. I know this can be done using the install command, but what I need is to install it when I build my project. So no need to manually install the jar, is there a way to do it?

I found something like this to install plugins

<configuration>
<executable>mvn</executable>
<arguments>
    <argument>install:install-file</argument>
    <argument>-Dfile=${basedir}\src\main\resources\EVIPSoapServer.jar</argument>
    <argument>-DgroupId=com.company</argument>
    <argument>-DartifactId=EVIPSoapServer</argument>
    <argument>-Dversion=1.0.0</argument>
    <argument>-Dpackaging=jar</argument>
</arguments>

Is there a way to install dependencies?

Upvotes: 3

Views: 1258

Answers (2)

Roy Justin
Roy Justin

Reputation: 663

I was able to find a solution in this blog http://giallone.blogspot.com/2012/12/maven-install-missing-offline.html

Upvotes: 1

aksappy
aksappy

Reputation: 3400

A better approach will be to create a multi module maven project, with your third party lib as one module and your project as another. In the root pom.xml, you can write the sequence of build and that will take care of the installing the third party jar before your project is installed.

Here is a tutorial for you Link 1

EDIT

From the comment, it seems like you only need the dependency jar to be available while installing. For this, the best approach would be to use a system scoped dependency, with the third party jar saved in a folder inside the maven project structure itself. Example is below. Read this link. This way, maven will not check whether the jar exists in local or remote maven repo.

    <dependency>
      <groupId>javax.sql</groupId>
      <artifactId>jdbc-stdext</artifactId>
      <version>2.0</version>
      <scope>system</scope>
      <systemPath>${your.path.here}</systemPath>
    </dependency>

Upvotes: 2

Related Questions