2012-11-18 66 views
1

我想使用maven-resources-plugin將資源複製到另一個目錄。Maven和maven-resources-plugin

我的資源目錄有這樣的結構:

log4j.xml 
xml 
    |_ resource-1 
    |_ resource-n 

我想只有log4.xml複製到輸出目錄。這裏是我的插件代碼:

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-resources-plugin</artifactId> 
    <version>2.6</version> 
    <configuration> 
     <outputDirectory>${glassfish.conf}</outputDirectory> 
      <resources> 
       <resource> 
        <directory>${conf.location}</directory> 
        <includes> 
         <include>**/log4j.xml</include> 
        </includes> 
        <excludes> 
         <exclude>**/xml/*</exclude> 
        </excludes> 
       </resource> 
      </resources> 
     </configuration> 
     <executions> 
      <execution> 
       <id>copy-log4j-to-glassfish</id> 
       <phase>package</phase> 
       <goals> 
        <goal>copy-resources</goal> 
       </goals> 
      </execution> 
     </executions> 
</plugin> 

但是,所有被複制到輸出目錄(log4j.xml和xml目錄)。

我試圖

<resource> 
    <directory>${conf.location}</directory> 
     <excludes> 
      <exclude>**/xml/*</exclude> 
     </excludes> 
</resource> 

或者

<resource> 
    <directory>${conf.location}</directory> 
    <includes> 
     <include>**/log4j.xml</include> 
    </includes>       
</resource> 

即使

<resource> 
    <directory>${conf.location}</directory> 
    <excludes> 
     <exclude>**/*</exclude> 
    </excludes> 
</resource> 

但目錄下的所有內容將被包括...這是什麼問題?

謝謝

回答

6

要回答安德魯Logvinov:

有了這樣的插件:

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-resources-plugin</artifactId> 
    <version>2.6</version> 
    <executions> 
     <execution> 
      <id>copy-log4j-to-glassfish</id> 
      <phase>package</phase> 
      <goals> 
       <goal>copy-resources</goal> 
      </goals> 
      <configuration> 
       <outputDirectory>${glassfish.conf}</outputDirectory> 
       <resources> 
        <resource> 
         <directory>${conf.location}</directory> 
         <includes> 
          <include>log4j.xml</include> 
         </includes> 
        </resource> 
       </resources> 
      </configuration> 
     </execution> 
    </executions> 
</plugin> 

它的工作做好了,只的log4j.xml複製。

有了現在這個插件的配置:

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-resources-plugin</artifactId> 
    <version>2.6</version> 
    <executions> 
     <execution> 
      <id>copy-log4j-to-glassfish</id> 
      <phase>package</phase> 
      <goals> 
       <goal>copy-resources</goal> 
      </goals> 
     </execution> 
    </executions> 
    <configuration> 
     <outputDirectory>${glassfish.conf}</outputDirectory> 
     <resources> 
      <resource> 
       <directory>${conf.location}</directory> 
       <includes> 
        <include>log4j.xml</include> 
       </includes> 
      </resource> 
     </resources> 
    </configuration> 
</plugin> 

我的所有文件都複製。

我檢查XSD hereconfiguration塊可以在裏面plugin或內部execution標籤,所以我不知道這是否是一個插件錯誤,或者如果這種誤解我。

+0

將'configuration'從'execution'中移出來的伎倆 –