简体   繁体   English

EAR中的Maven组装JAR

[英]Maven assembly JAR in EAR

For reasons that I won't go into, I need to build the following structure: 由于我不愿讨论的原因,我需要构建以下结构:

EAR
 |
 |-- Uber-JAR
 |
 |-- WAR

I can build the uber JAR with the Maven Assembly plugin, but when I try to include it in the EAR (built with the Maven EAR plugin) it includes a normal JAR version, which has no sources (because I'm using the uber JAR to pull all the sources in the project together). 我可以使用Maven Assembly插件构建uber JAR,但是当我尝试将其包含在EAR(使用Maven EAR插件构建)中时,它包含一个普通的JAR版本,没有任何源代码(因为我使用的是uber JAR)以将项目中的所有来源整合在一起)。

How can I get the uber JAR included in the EAR? 如何获得EAR中包含的超级JAR?

This is one way to fix it. 这是修复它的一种方法。 If there's a better way I'd like to know it :) 如果有更好的方法,我想知道:)

Just include: 只需包括:

<earSourceDirectory>${basedir}</earSourceDirectory>
<earSourceIncludes>/path/to/jar.jar</earSourceIncludes>

in the EAR plugin configuration. 在EAR插件配置中。

EDIT: Seems I spoke too soon. 编辑:似乎我讲得太早了。 In the project's parent pom I have all the modules listed to build, with the uber JAR above the EAR module (as the last two modules). 在项目的父pom中,我列出了所有要构建的模块,其中UBER JAR位于EAR模块上方(作为最后两个模块)。

It won't build the whole project: 它不会构建整个项目:

'Artifact <ARTIFACT> (included by module) does not have an artifact with a file'

EDIT (again): 编辑(再次):

Final Answer 最终答案

So, finally, in the configuration for the Maven Assembly plugin, I have: 因此,最后,在Maven Assembly插件的配置中,我有:

<configuration>
    ...
    <finalName>myjarname</finalName>
</configuration>

This creates a JAR file called simply 'myjarname.jar'. 这将创建一个JAR文件,简称为“ myjarname.jar”。

In the Maven EAR plugin configuration, I use the following structure: 在Maven EAR插件配置中,我使用以下结构:

<configuration>
    ...
    <modules>
        ...
        <ejbModule>
            <groupId>com.mygroup</groupId>
            <artifactId>myartifact</artifactId>
            <bundleFileName>myjarname.jar</bundleFileName>
        </ejbModule>
    </modules>
</configuration>

This grabs the specific jar and puts it in the EAR. 这将抓取特定的罐子并将其放入EAR中。 Voila! 瞧!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM