将Maven项目的依赖项复制到特定文件夹 [英] Copy dependency of a maven project to specific folder

查看:155
本文介绍了将Maven项目的依赖项复制到特定文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将Maven项目所需的所有jar放入特定文件夹中.

I am trying to get all the jar required for a maven project inside a particular folder.

我已经使用过mvn dependency:copy-dependencies命令.

它为我提供了taget/dependeny文件夹中所需的jar文件.

It gives me the required jar files inside taget/dependeny folder.

尽管我可以使用move或copy coommand将这些jar复制到另一个目录,但是有什么方法可以直接将依赖项复制到我选择的目录中?

Although I can use move or copy coommand to copy those jars to another directory, is there any way to copy the dependencies in directory of my choice directly?

推荐答案

您需要使用

You need to use the outputDirectory property to define the required location where you would like the jars to be copied to.

以下是您要在POM中添加的配置示例:

Here is an example of the configuration you would add in your POM:

<plugins>
...
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
            <execution>
                <id>copy-dependencies</id>
                <phase>package</phase>
                <goals>
                    <goal>copy-dependencies</goal>
                </goals>
                <configuration>
                    <outputDirectory>${project.build.directory}/alternateLocation</outputDirectory>
                </configuration>
            </execution>
        </executions>
    </plugin>
    ...
</plugins>

或者,您可以直接通过命令行传递此配置:

Alternatively you can pass this configuration directly via the command line:

mvn -DoutputDirectory=alternativeLocation dependency:copy-dependencies 

这篇关于将Maven项目的依赖项复制到特定文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆