1

これは、EAR のパッケージ化中に発生しています。

私の pom.xml は、 /lib フォルダーの外に projectA.jar ファイルと projectB.war を含める必要がある ear ファイルをパッケージ化しています。どうやら、projectA.jar ファイルは想定されていない /lib フォルダー内に移動しています。これらの 2 つのプロジェクトがライブラリの外にある必要があることを示す application.xml があります。

質問 : projectA.jar を /lib フォルダー内にバンドルするのではなく、/lib フォルダーの外にバンドルするように Maven に指示するにはどうすればよいですか?

私の EAR 構造は次のようになります。

MyWebEAR

\lib
\META-INF
projectA.jar
ProjectB.war

以下は私のポンです。

<dependencies>
    <dependency>
        <groupId>com.xxx.sms</groupId> 
        <artifactId>projectA</artifactId> 
        <version>1.0-SNAPSHOT</version>             
    </dependency>
    <dependency>
        <groupId>com.xxx</groupId>
        <artifactId>projectB</artifactId>
        <version>1.0-SNAPSHOT</version>
        <type>war</type>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <artifactId>maven-ear-plugin</artifactId>
            <configuration>
                <defaultLibBundleDir>lib</defaultLibBundleDir>
                <earSourceDirectory>${basedir}</earSourceDirectory>
                <earSourceIncludes>META-INF/*</earSourceIncludes>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                    </manifest>
                </archive>
                <generateApplicationXml>false</generateApplicationXml>
                <applicationXML>${basedir}/META-INF/application.xml</applicationXML>
            </configuration>
        </plugin>
    </plugins>
    <finalName>MyWebEAR</finalName>
</build>

御時間ありがとうございます。

4

2 に答える 2

5

You need to specifically define a jarModule configuration in the modules section of your maven-ear-plugin configuration for the projectA dependency and explicitly set where you want the jar placed.

So your POM would be:

<plugin>
    <artifactId>maven-ear-plugin</artifactId>
    <configuration>
        <defaultLibBundleDir>lib</defaultLibBundleDir>
        <earSourceDirectory>${basedir}</earSourceDirectory>
        <earSourceIncludes>META-INF/*</earSourceIncludes>
        <archive>
            <manifest>
                <addClasspath>true</addClasspath>
            </manifest>
        </archive>
        <generateApplicationXml>false</generateApplicationXml>
        <applicationXML>${basedir}/META-INF/application.xml</applicationXML>
        <modules>
            <jarModule>
                <groupId>com.xxx.sms</groupId>
                <artifactId>projectA</artifactId>
                <bundleDir>/</bundleDir>
            </jarModule>
        </modules>
    </configuration>
</plugin>

The value (/) in the bundleDir tells the maven-ear-plugin to place projectA's jar in the root folder of the ear instead of the default location of lib.

You can see details on this in the plugins documentation here: http://maven.apache.org/plugins/maven-ear-plugin/examples/customizing-module-location.html

于 2013-10-24T06:51:00.413 に答える