Copy dependency of a maven project to specific folder

ぃ、小莉子 提交于 2020-01-01 05:03:53

问题


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

I have used mvn dependency:copy-dependencies command.

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

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?


回答1:


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

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 


来源:https://stackoverflow.com/questions/33012936/copy-dependency-of-a-maven-project-to-specific-folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!