简体   繁体   中英

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?

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM