2015-10-05 69 views
-1

我需要使用maven來複制一些文件。這裏是我的文件夾結構是什麼樣子: `使用maven複製文件

+code 
    +trunk 
     +delivery 
      -pom.xml 
     +myFramework 
      +catalog 
       -pom.xml 
       +target 
        +classes 
         -catalog.properties 
         -catalog.xml 
      +orders 
       -pom.xml 
       +target 
        +classes 
         -orders.properties 
         -orders.xml 
      +common 
       -pom.xml 
       +target 
        +classes 
         -common.properties 
         -common.xml 
      -pom.xml 
     +myOther 
      +stuff 
       +moreStuff 
        +target 
         +classes 
          -moreStuff.properties 
        -pom.xml 
       -pom.xml 
      -pom.xml 
     +Test 
     -pom.xml 
+distros 
    +dome` 

的加分(+)是目錄和減號( - )的文件。

我必須對傳遞文件夾中的pom.xml進行更改。需要發生的事情是,需要將catalog,orders,common和moreStuff文件夾中的屬性和xml文件複製到dome文件夾。

因此,執行傳遞pom後的最終結果是dome目錄包含catalog.properties,catalog.xml,orders.properties,orders.xml,common.properties,common.xml和moreStuff.properties。

+0

我認爲這與您可以用程序集插件完成的工作完全匹配:http://maven.apache.org/plugins/maven-assembly-plugin/(假設您想創建可分發文件)。否則資源插件應該已經可以做你想做的事了。目錄結構是否重要?是否可以將distros文件夾移動到目標/最頂層的pom.xml中?這將簡化路徑處理。 – wemu

回答

0

我對root pom(主幹下)進行了更改,而不是對交付pom進行更改。這是我怎麼會做這樣的:從目標/ classes文件夾複製它們,而不是

<build> 
    <plugins> 
     <plugin> 
     <artifactId>maven-resources-plugin</artifactId> 
     <version>2.6</version> 
     <executions> 
      <execution> 
       <id>copy-resources</id> 
       <phase>process-resources</phase> 
       <goals> 
        <goal>copy-resources</goal> 
       </goals> 
       <configuration> 
        <outputDirectory>C:/distros/dome</outputDirectory> 
        <resources> 
        <resource> 
         <directory>src\main\resources</directory> 
         <excludes> 
          <exclude> ... </exclude> 
         </excludes> 
         <filtering>true</filtering> 
        </resource> 
        </resources> 
       </configuration> 
      </execution> 
     </executions> 
     </plugin> 
    </plugins> 
</build> 

,我結束了在SRC /主/資源文件夾(在原來的問題沒有說明)複製資源文件。