1

Maven EAR プラグインを使用してapplication.xml、WAR を含む EAR を生成しています。

その WAR を実行時に決定したいのでcontextRoot(これは JBoss AS 7 のおかげで機能します)、次のapplication.xmlようなものが含まれている必要があります。

<module>
  <web>
    <web-uri>my.war</web-uri>
    <context-root>${my.context.root}</context-root>
  </web>
</module>

my.context.rootこれは、 JBoss AS 7 内でシステム プロパティを設定し、 XML 記述子ファイル内の変数を置き換えるように JBoss を設定することで機能します。

<system-properties>
    <property name="my.context.root" value="/foo"/>
</system-properties>

<subsystem xmlns="urn:jboss:domain:ee:1.1">
  <spec-descriptor-property-replacement>true</spec-descriptor-property-replacement>
  <jboss-descriptor-property-replacement>true</jboss-descriptor-property-replacement>
</subsystem>

application.xmlEARで生成されたを編集してこれを行うと、機能します。

${my.context.root}ただし、Maven に内のコンテキスト ルートに書き込むことはできませんapplication.xml

最初にこれを試しました(何もフィルタリングされていないため、動作するはずです):

<configuration>
  <modules>
    <webModule>
      <groupId>my.group</groupId>
      <artifactId>my-war</artifactId>
      <contextRoot>${my.context.root}</contextRoot>
    </webModule>
  </modules>
</configuration>

どうやら、filteringデフォルトは に設定されていますがfalse、Maven はこれを Maven プロパティとして使用する必要があると考えています。その結果、EAR プラグインは WAR の名前を入れるだけです。

<module>
  <web>
    <web-uri>my-war.war</web-uri>
    <context-root>/my-war</context-root>
  </web>
</module>

だから私はエスケープしようとしました:

<configuration>
  <modules>
    <webModule>
      <groupId>my.group</groupId>
      <artifactId>my-war</artifactId>
      <contextRoot>\${my.context.root}</contextRoot>
    </webModule>
  </modules>
</configuration>

これは文字通り取られます:

<module>
  <web>
    <web-uri>my-war.war</web-uri>
    <context-root>\${my.context.root}</context-root>
  </web>
</module>

Maven に自分のやりたいことをさせるにはどうすればよいですか? (もちろん、application.xmlMaven 置換プラグインを使用してハッキングを試みることもできますが、それは見苦しいです...)

ヒントをありがとう!

4

1 に答える 1