2016-10-04 28 views
0

在我的項目,模塊C具有己父A.運行Maven潔淨的插件不清洗默認目標目錄

父父B A POM

<pluginManagement> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-clean-plugin</artifactId> 
      <version>3.0.0</version> 
     </plugin> 
    </plugins> 
</pluginManagement> 

父乙POM

<pluginManagement> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-clean-plugin</artifactId> 
      <executions> 
       <execution> 
        <id>clean-extra-files</id> 
        <goals> 
         <goal>clean</goal> 
        </goals> 
        <configuration> 
         <filesets> 
          <fileset> 
           <directory>C:\foo\bar</directory> 
           <includes> 
            <include>foo*.jar</include> 
           </includes> 
           <followSymlinks>false</followSymlinks> 
          </fileset> 
         </filesets> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 
</pluginManagement> 

模塊C POM

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-clean-plugin</artifactId> 
    <executions> 
     <execution> 
      <id>clean-extra-files</id> 
      <phase>pre-integration-test</phase> 
     </execution> 
    </executions> 
</plugin> 

當我運行mvn clean pre-integration-test

[INFO] --- maven-clean-plugin:3.0.0:clean (clean-extra-files) @ foo-c --- 
[INFO] Deleting C:\dev\workspace\foo-a\foo-b\foo-c\target 
[INFO] Deleting C:\foo\bar (includes = [foo*.jar], excludes = []) 

兩個默認的目標目錄,我的其他目錄中清洗。但是,我只希望清理附加目錄。

如何防止clean-extra-files清除默認目標目錄?

如果這是不可能的,還有什麼其他選項用於清理不需要的文件?

ENV:Java的:6時,Eclipse:月神,Maven的:3.2

回答

0

它似乎並沒有成爲一個方式與Maven的清理插件做到這一點,所以我使用this post啓發的antrun任務:

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-antrun-plugin</artifactId> 
    <executions> 
     <execution> 
      <id>delete-install-files</id> 
      <phase>pre-integration-test</phase> 
      <goals> 
       <goal>run</goal> 
      </goals> 
      <configuration> 
       <tasks> 
        <delete> 
         <fileset dir="C:\foo\bar" 
          includes="foo*.jar" /> 
        </delete> 
       </tasks> 
      </configuration> 
     </execution> 
    </executions> 
</plugin> 
0

我相信是有,你可以使用 「排除」 標籤。

<fileset> 
     <directory>some/relative/path</directory> 
     <includes> 
     <include>**/*.tmp</include> 
     <include>**/*.log</include> 
     </includes> 
     <excludes> 
     <exclude>**/important.log</exclude> 
     <exclude>**/another-important.log</exclude> 
     </excludes> 
     <followSymlinks>false</followSymlinks> 
    </fileset> 

http://maven.apache.org/plugins/maven-clean-plugin/examples/delete_additional_files.html

http://maven.40175.n5.nabble.com/How-to-delete-a-directory-td123552.html

+0

這隻在我在文件集中定義的目錄上排除。目標目錄上的默認清除仍然會觸發。 –

相關問題