1

後で大きな耳のファイルに含めるために、細い戦争を構築しようとしています。ear ビルドは私の war のプロジェクトとは完全に独立しており、適切なマニフェスト ファイルを使用してスキニー war を提供することを期待しています。

私が直面している問題は、戦争の manifest.mf ファイルを取得して、提供された jar が ear の /libs フォルダーにあり、コンパイル/ランタイム jar が戦争にあることを指定することです。つまり、manifest.mf クラスパス エントリは次のようになります。

Class-Path: libs/commons-lang.jar commons-codec.jar

commons-lang のスコープは提供され、ear の libs ディレクトリにあることが期待されます。

commons-codec はコンパイル時であり、戦争の一部になることが予想されます。

maven-war-pluginを調べましたが、提供された依存関係だけにclasspathPrefixを提供する方法がわかりません 。

提案してください?


最終的に採用されたソリューション (ヒントとリンクを提供してくれたすべての人に感謝します) ear によって提供された依存関係を提供する必要があり、これはハックに気づきました: fake-application.xml :

 <plugin>
    <!--required to fix the war's manifest and skinny the war-->
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-ear-plugin</artifactId>
    <version>2.10.1</version>
    <configuration>
        <defaultLibBundleDir>lib/</defaultLibBundleDir>
        <skinnyWars>true</skinnyWars>
        <generateApplicationXml>true</generateApplicationXml>
        <applicationXml>${project.basedir}/src/test/fake-ear/fake-application.xml</applicationXml>
    </configuration>
    <executions>
        <execution>
            <phase>verify</phase>
            <goals><goal>ear</goal></goals>
        </execution>
    </executions>
 </plugin>

次に、この新しいスキニー ウォーをリポジトリにデプロイし、maven デプロイ プラグインを使用して行いました。

<plugin>
    <!--used in release build to deploy skinny war to nexus-->
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-deploy-plugin</artifactId>
    <version>2.8.2</version>
    <executions>
        <execution>
            <id>deploy-file</id>
            <phase>install</phase>
            <goals>
                <goal>deploy-file</goal>
            </goals>
            <configuration>
                <!--location of the skinny war after maven-ear-plugin builds it-->
                <file>${project.build.directory}/${project.artifactId}-${project.version}/${artifactid}-${project.parent.version}.war</file>
                <repositoryId>releases</repositoryId>
                <url>${distributionManagement.repository.url}</url>
                <groupId>${project.parent.groupId}</groupId>
                <artifactId>${artifactid}</artifactId>
                <version>${project.parent.version}</version>
                <packaging>war</packaging>
            </configuration>
        </execution>
    </executions>
</plugin>
4

1 に答える 1

0

@Tunaki のmaven-ear-plugin提案は全体論的には優れているようですが、とにかく見てみましょう: https://maven.apache.org/plugins/maven-shade-plugin/examples/executable-jar.html

次の方法でマニフェストを変更できます。

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>2.4.3</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <transformers>
                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                  <manifestEntries>
                    <Class-Path>libs/commons-lang.jar commons-codec.jar</Class-Path>
                  </manifestEntries>
                </transformer>
              </transformers>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  ...
</project>
于 2016-11-09T14:27:06.453 に答える