Maven - 将一些依赖JAR复制到warSourceDirectory中

时间:2014-01-13 13:09:08

标签: maven applet war maven-assembly-plugin maven-dependency-plugin

任何Maven插件都可以将.war项目的一个或多个依赖项(尽管不是全部)复制到其warSourceDirectorysrc/main/webapp)中吗?

我正在开发一个可以显示applet的Java Web应用程序。我希望war项目选择一些罐子的最新版本(applet的依赖项)并将它们粘贴在/src/main/webapp/中,以免我不得不将它们复制到这个地方。

我已经考虑过对小程序本身进行着色和超级运算,但是我想将这些jar分开,以便在用户只需要下载其中一个位时就可以下载一个大型jar。< / p>

1 个答案:

答案 0 :(得分:2)

dependency:copy使用此Maven Dependency Plugin

另请阅读示例页面:Copying specific artifacts

示例配置

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
    <execution>
        <id>copy</id>
        <phase>compile</phase>
        <goals>
            <goal>copy</goal>
        </goals>
        <configuration>
            <artifactItems>
                <artifactItem>
                    <groupId>junit</groupId>
                    <artifactId>junit</artifactId>
                    <version>3.8.1</version>
                    <type>jar</type>
                    <overWrite>false</overWrite>
                    <destFileName>optional-new-name.jar</destFileName>
                </artifactItem>
            </artifactItems>
            <outputDirectory>${project.build.directory}/${project.artifactId}-${project.version}/</outputDirectory>
            <overWriteReleases>false</overWriteReleases>
            <overWriteSnapshots>true</overWriteSnapshots>
        </configuration>
    </execution>
</executions>

将文件复制到src/main/webapp是个坏主意。将文件直接复制到target文件夹。

相关问题