2017-03-10 8 views
0

リソースを個別の実行タグでフィルタリングすることは可能ですか? 私の目標は、それぞれ異なるフィルタファイルを使用してリソースをフィルタリングした2つのwarファイルを作成することです。 実際には、このソリューションは動作しません。変数には値はありません。 <jta-data-source>${ds-jta}</jta-data-source> - maven-war-plugin-commentedセクションの外にフィルタとリソースタグを追加する必要があります。 スニペットに示されているように、実行構成でこの「フィルタリング」を指定することは可能だと思いました。Maven warプラグインを別々に実行してリソースをフィルタリングする

<build> 
<!-- I dont want to add this here - I want to have it in execution 
    <resources> 
     <resource> 
     <directory>src/main/resources</directory> 
     <filtering>true</filtering> 
     </resource> 
    </resources> 
    <filters> 
     <filter>config/1.properties</filter> 
    </filters> --> 
<plugins> 
    <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-war-plugin</artifactId> 
     <version>3.0.0</version> 
     <executions> 
     <execution> 
      <id>1</id> 
      <phase>package</phase> 
      <configuration> 
       <filters> 
        <filter>config/1.properties</filter> 
       </filters> 
       <classifier>-1</classifier> 
       <webappDirectory>${project.build.directory}/${project.build.finalName}-1</webappDirectory> 
       <webResources> 
        <resource> 
        <directory>src/main/resources</directory> 
        <filtering>true</filtering> 
        </resource> 
       </webResources> 
      </configuration> 
      <goals> 
       <goal>war</goal> 
      </goals> 
     </execution> 
     <execution> 
      <id>2</id> 
      <phase>package</phase> 
      <configuration> 
       <filters> 
        <filter>config/2.properties</filter> 
       </filters> 
       <classifier>-2</classifier> 
       <webappDirectory>${project.build.directory}/${project.build.finalName}-2</webappDirectory> 
       <webResources> 
        <resource> 
        <directory>src/main/resources</directory> 
        <filtering>true</filtering> 
        </resource> 
       </webResources> 
      </configuration> 
      <goals> 
       <goal>war</goal> 
      </goals> 
     </execution> 
     </executions> 
    </plugin> 
</plugins> 
</build> 

私は何が欠けていますか?

答えて

0

は、Mavenの戦争 - プラグインによって作成された.warは次のようになります。

├── myapp.war 
    │   ├── index.html │   
    │   ├── myapp.properties 
    │   ├── logback.xml 
    │   ├── META-INF 
    │   │   ├── persistence.xml  
    │   │   
    │   └── WEB-INF     
    │    ├── classes 
    │    │   ├── myapp.properties 
    │    │   ├── logback.xml 
    │    │   ├── META-INF 
    │    │   │   ├── persistence.xml 

私はpersistence.xmlで定義されたタグ<jta-data-source>${ds-server-jta}</jta-data-source>の 'DS-サーバーJTA' 変数フィルタリングしたかったです。 Maven-war-pluginはMETA-INFにあるpersistence.xmlのみをフィルタリングしました。 maven-war-pluginがこの.warを両方のMETA-INFで作成し、1つのpersistence.xmlだけがフィルタリングされたという事実(WEB-INF/classes/META-INF/persistence.xmlのものです)次のようになります。

<webResources> 
    <resource> 
     <directory>src/main/resources</directory> 
     <filtering>true</filtering> 
     <targetPath>WEB-INF/classes</targetPath> 
    </resource> 
    <resource> 
     <directory>src/main/resources</directory> 
     <filtering>true</filtering> 
    </resource> 
</webResources> 

これは、フィルタするリソースを明示的に指示し、両方のファイルが必要に応じて変更されるようにします。

しかし、META-INFのPersistence.xmlは、アプリケーションサーバー(Glassfish)では使用されていませんが、とにかくmaven-war-pluginによって作成されます。サーバーによって使用されるものは、WEB-INF/classes/META-INF/persistence.xmlです。 私は最初の未使用のappserver META-INFカタログを自分の.warに作成しないようにしようとしていますが、その詳細はほんのわずかです。

関連する問題