0

今日、Maven war プラグインを次のように構成します。

<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
   <webXml>${basedir}/../common/WEB-INF/web.xml</webXml>
</configuration>

これにより、その web.xml を複数のプロジェクト間で共有できます。このアプローチの問題は、私の Maven プロジェクトが自己完結型ではないことです。これは、ファイル システム上の相対パスに依存します。

このようなことを何とかすることは可能ですか?:

   <webXml>classpath:com/mycompany/common/web.xml</webXml>

そしてもちろん、そのファイルをプラグインのクラスパスで利用できるようにします。

ありがとう

4

1 に答える 1

1

最初のステップはjarweb.xml. com.mycompany:common としましょう。

このようなことを何とかすることは可能ですか?:

<webXml>classpath:com/mycompany/common/web.xml</webXml>

試してみましたか、つまり、うまくいかないことがわかっていますか? その場合は、先頭に「/」(/com/...) を使用する必要があると思います。

そしてもちろん、そのファイルをプラグインのクラスパスで利用できるようにします。

それなら簡単です... com.mycompany:common に依存関係を追加して、クラスパスで使用できるようにするだけです。もちろん、Maven リポジトリで利用できる必要があります。

が機能しない場合classpath:は、私自身もよくわかりません。 を使用して JARmaven-dependency-pluginから解凍し、 で使用できるようにすることができます。web.xmlmaven-war-plugin

pom.xml

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-dependency-plugin</artifactId>
  <executions>
    <execution>
      <id>unpack-web-xml</id>
      <phase>..any phase before packaging..</phase>
      <goals>
        <goal>unpack</goal>
      </goals>
      <configuration>
        <artifactItems>
          <artifactItem>
            <groupId>com.mycompany</groupId>
            <artifactId>common</artifactId>
            <version>1.0</version>
            <outputDirectory>...dir you'll use for the war plugin later...</outputDirectory>
            <includes>/com/mycompany/common/web.xml</includes>
          </artifactItem>
        </artifactItems>
      </configuration>
    </execution>
  </executions>
</plugin>
于 2013-05-29T21:28:15.437 に答える