2016-05-03 20 views
0

我目前正在Maven構建中工作。我想從我的Maven構建中刪除特定的文件。我目前正在與下面的代碼嘗試:無法從Maven構建中刪除特定文件

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-war-plugin</artifactId> 
    <version>2.4</version> 
    <configuration> 
     <webResources> 
      <resource> 
       <directory>src/main/resources</directory> 
       <!-- override the destination directory for this resource --> 
       <targetPath>WEB-INF/classes</targetPath> 
       <!-- enable filtering --> 
       <filtering>true</filtering> 
       <includes> 
        <include>*.pem</include> 
        <include>*.pfx</include> 
        <include>META-INF/jpa-persistence.xml</include> 
        <include>META-INF/spring-persistence.xml</include> 
        <include>com/abc/config/build-config-${propertyenv}.properties</include> 
       </includes> 
       <excludes> 
        <exclude>%regex[(?!.*${propertyenv}/)*]</exclude> 
       </excludes> 
      </resource> 
     </webResources> 
    </configuration> 
</plugin> 

我已經在我的POM定義propertyenv物業價值:

<properties> 
    <propertyenv>abc</propertyenv> 
</properties> 

我只想從com/abc/config文件夾abc.properties文件。但建立後所有文件都存在.properties。請幫助。

+0

我想你正在尋找的http://maven.apache.org/guides/介紹/介紹到個人資料.html – Abhishek

+0

@Abhishek如何構建配置文件應該在這裏幫助?通過配置文件,您可以使用其中聲明的值激活/選擇設置。如果設置本身已經不能做什麼試圖完成的話,這有什麼幫助? –

回答

1

使用packagingExcludespackagingIncludes參數包括或最終戰

例排除文件:

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-war-plugin</artifactId> 
    <version>2.6</version> 
      .... 
    <configuration> 
      .... 
       <packagingExcludes> 
        WEB-INF/lib/pax-logging-*.jar, WEB-INF/lib/jaxb-*-2.2.7.jar 
       </packagingExcludes> 
    </configuration> 
</plugin> 
+0

謝謝,它的工作 –