Maven - 将一些依赖 JAR 复制到 warSourceDirectory [英] Maven - Copy Some Dependency JARs into warSourceDirectory

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

问题描述

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

Can any Maven plugins copy one or more dependencies (although not all of them) of a .war project into its warSourceDirectory (src/main/webapp)?

我正在开发一个将显示小程序的 Java 网络应用程序.我希望 war 项目选择一些 jar(小程序的依赖项)的最新版本并将它们粘贴在 /src/main/webapp/ 中,这样我就不必到处复制它们了.

I'm working on a Java web-app that will display an applet. I'd like the war project to pick the latest version of some jars (the applet's dependencies) and stick them in /src/main/webapp/, to save me having to copy them around the place.

我已经考虑过对小程序本身进行着色和 uber-jar-ing,但我想将这些 jar 分开,以节省用户在其中只有一个位发生变化时必须下载一个巨大的 jar.

I've thought about shading and uber-jar-ing the applet itself, but I'd like to split the jars up to save users having to download one massive jar when only one of the bits in it has changed.

推荐答案

用于此 dependency:copy 来自 Maven 依赖插件.

另请阅读示例页面:复制特定工件

示例配置

<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 文件夹中.

Copying files into src/main/webapp is bad idea. Copy file directly into target folder.

这篇关于Maven - 将一些依赖 JAR 复制到 warSourceDirectory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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