maven 打包的同时将生成的jar复制到指定路径

相关资料来自百|度|知|道:

<build>
    <outputDirectory>src/main/webapp/WEB-INF/classes</outputDirectory>
    <testOutputDirectory>src/main/webapp/WEB-INF/classes</testOutputDirectory>
    <plugins>
        <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions>
                <execution>
                    <id>copy-lib-src-webapps</id>
                    <phase>package</phase>
                    <configuration>
                        <tasks>
                           <!-- <delete dir="src/main/webapp/WEB-INF/lib" />-->
                            <copy todir="${project.web-common.lib-targetPath}">
                                <fileset dir="${project.commonmodule.lib-source.directory}">
                                    <include name="*" />
                                </fileset>
                            </copy>
                        </tasks>
                    </configuration>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

目的:将打包后生成的jar复制到指定路径
阻碍:命令mvn package后,才生成jar的包,如果单纯的用resources方法复制文件,是无法在package时复制一个还未存在的东西到某地的。
解决:添加antrun plugin,达到更改打包和复制的顺序的目的,使打包之后再复制成为可能。
PS:在project中properties里规定的路径,project的module可以理解使用。


Maven实战(九)——打包的技巧


你可能感兴趣的:(maven 打包的同时将生成的jar复制到指定路径)