Maven:如何使用 maven-ear-plugin 将文件添加到 EAR 内的根目录?

发布于 2024-09-27 19:55:08 字数 889 浏览 4 评论 0原文

我需要在使用 maven-ear-plugin 生成的 EAR 中添加 2 个 XML 文件。

不幸的是,我还没有找到将任意文件添加到 EAR 的方法;插件的文档,内容为“EAR 插件支持以下工件: ejb、war、jar、ejb-client、rar、ejb3、par、sar、wsr 和 har”。没有什么可以添加常规文件。

org.apache.maven.plugins maven-ear-插件 2.3.1 富 富 1.4 库 ${parent.groupId} foo-web /foo org.richfaces.framework richfaces-api 公共语言 公共语言

非常感谢。

I need to add 2 XML files inside an EAR generated with maven-ear-plugin.

Unfortunately, I haven't seen a way to add an arbitrary file to an EAR; the documentation of the plugin which reads "The EAR plugin supports the following artifacts: ejb, war, jar, ejb-client, rar, ejb3, par, sar, wsr and har". There's nothing for adding a regular file.

org.apache.maven.plugins
maven-ear-plugin
2.3.1

foo
foo
1.4
lib

${parent.groupId}
foo-web
/foo

org.richfaces.framework
richfaces-api

commons-lang
commons-lang

Many thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

指尖微凉心微凉 2024-10-04 19:55:08

maven-ear-plugin 2.4.2 中,您可以使用配置元素earSourceDirectory、earSourceExcludes 和earSourceInincludes 来声明要包含在EAR 中的额外文件。

默认情况下,您只需将这些文件放置到 ${basedir}/src/main/application 文件夹中即可。

In maven-ear-plugin 2.4.2 you can use config elements earSourceDirectory, earSourceExcludes and earSourceIncludes to declare extra files to include in the EAR.

By default you simply place those files to ${basedir}/src/main/application folder.

打小就很酷 2024-10-04 19:55:08

我有同样的问题。我在 ejbs/src/main/resources 下有 ejb.properties 文件,并使用earSourceDirectory 和earSourceInincludes 将文件从ejbs 目录拉到ear。然而,它并没有可靠将其放入lib目录中。 EJB 在 . 中找不到它;它在 lib 目录中查找它。

为了解决这个问题,我创建了 src/main/application/lib 目录并创建了指向 ejb.properties 文件的链接。然后我删除了 EarSourceDirectory 和 Includes 属性。现在,当我执行 mvn clean 打包时,它会自动拉取属性文件并将其放入 Ear 的 lib 目录中。

I had the same issue. I had the ejb.properties file under ejbs/src/main/resources and had used earSourceDirectory and earSourceIncludes to pull the file from the ejbs directory to the ear. However, it did not reliably put it in the lib directory. The EJB does not find it in .; it looks for it in the lib directory.

To fix this, I created the src/main/application/lib directory and created a link to the ejb.properties file. I then removed the earSourceDirectory and Includes properties. Now when I do a mvn clean package, it automatically pulls the properties file and puts it in the lib directory of the ear.

无所的.畏惧 2024-10-04 19:55:08

很抱歉@wishihadabettername 迟到了,但我最近遇到了同样的问题,更多的是我无法移动要包含的文件,因为它们位于earSourceDirectory 之外的其他文件夹中。我阅读了 maven-ear-plugin Ear:ear 文档 并思考如何将我的 release 文件夹移动到耳朵根部。

默认绑定到生命周期阶段:package。

workDirectory - 构建期间将资源复制到的目录。

默认值为: ${project.build.directory}/${project.build.finalName}

然后我的子模块 pom.xml 看起来像这样:

<plugin>
    <artifactId>maven-resources-plugin</artifactId>
    <executions>
        <execution>
            <id>copy-resources</id>
            <phase>prepare-package</phase> <!-- before package phase -->
            <goals>
                <goal>copy-resources</goal>
            </goals>
            <configuration>
                <!-- Work Directory of Ear plugin -->
                <outputDirectory>${project.build.directory}/${project.build.finalName}</outputDirectory> 
                <resources>
                    <resource>
                        <!-- my resource folder -->
                        <directory>release</directory>
                        <filtering>true</filtering>
                    </resource>
                </resources>
            </configuration>
        </execution>
    </executions>
</plugin>

希望从现在起它可以帮助人们

Sorry to be late for @wishihadabettername but I had same issue recently, more I couldn't move the files to include because they were in other folder then earSourceDirectory. I read maven-ear-plugin ear:ear documentation and thought about how to move my release folder on the root of ear.

Binds by default to the lifecycle phase: package.

and

workDirectory - Directory that resources are copied to during the build.

Default value is: ${project.build.directory}/${project.build.finalName}.

Then my submodule pom.xml looks like this:

<plugin>
    <artifactId>maven-resources-plugin</artifactId>
    <executions>
        <execution>
            <id>copy-resources</id>
            <phase>prepare-package</phase> <!-- before package phase -->
            <goals>
                <goal>copy-resources</goal>
            </goals>
            <configuration>
                <!-- Work Directory of Ear plugin -->
                <outputDirectory>${project.build.directory}/${project.build.finalName}</outputDirectory> 
                <resources>
                    <resource>
                        <!-- my resource folder -->
                        <directory>release</directory>
                        <filtering>true</filtering>
                    </resource>
                </resources>
            </configuration>
        </execution>
    </executions>
</plugin>

Hope it help people from now on

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文