2010-03-10 53 views
1

我會利用覆蓋這樣喜歡副本只是 「file.xml」 無文件夾結構:如何使用疊加層複製文件夾結構的指定文件?

<overlays> 
    <overlay> 
     <groupId>com.mygroup</groupId> 
     <artifactId>my_comp</artifactId> 
     <includes> 
     <include>WEB-INF/folder1/folder2/file.xml</include> 
     </includes> 
     <targetPath>WEB-INF/otherFolder</targetPath> 
     <type>war</type> 
    </overlay> 
    </overlays> 

換句話說:從WEB-INF /文件夾1 /文件夾2/和地方複製file.xmlWEB-INF/otherFolder

任何想法?

回答

0

據我所知,這是不可能與覆蓋,覆蓋的內容是「原樣」添加到targetPath(默認爲webapp的根結構)。

如果你想file.xml可在另一個位置,你就必須覆蓋之前調整在my_comp WAR 它的位置。

2

我沒有找到如何通過重疊來解決問題。所以我只好用兩個插件Maven的依賴,插件Maven的戰爭插件

 <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-dependency-plugin</artifactId> 
      <version>2.1</version> 
      <executions> 
       <execution> 
       <id>copy</id> 
       <phase>process-resources</phase> 
       <goals> 
        <goal>unpack</goal> 
       </goals> 
       <configuration> 
       <artifactItems> 
        <artifactItem> 
         <groupId>com.mygroup</groupId> 
         <artifactId>my_comp</artifactId> 
         <type>war</type> 
         <overWrite>true</overWrite> 
         <outputDirectory>${project.build.directory}/tmp</outputDirectory> 
         <includes>WEB-INF/folder1/folder2/file.xml</includes> 
       </artifactItem> 
      </artifactItems> 
      </configuration> 
      </execution> 
     </executions> 
    </plugin> 
    <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-war-plugin</artifactId> 
     <version>2.1-beta-1</version> 
     <configuration> 
     <webResources> 
      <resource> 
        <directory>${project.build.directory}/tmp/WEB-INF/folder1/folder2</directory> 
        <targetPath>WEB-INF/otherFolder</targetPath> 
      </resource> 
     </webResources> 
     </configuration> 
    </plugin> 

連接到過程資源階段的第一個插件。第二個調用階段當所有覆蓋合併。 疊加層應用了一個首選策略(因此如果一個文件已被覆蓋層複製,它將不會被複制)如果我複製了我的file.xml(通過插件),那麼它不會被覆蓋任何覆蓋。

這太複雜了!

相關問題