2011-04-27 67 views
2

在我的項目中,我最初犯了一個錯誤,並在CVS存儲庫中提交了目標目錄;我知道沒有安全的方法來從CVS中刪除一個目錄,所以我把一個.cvsignore文件放在那裏基本上忽略了一切(我不希望開發人員甚至無法正確合併來提交他們的類......) 。Maven clean插件排除.cvsignore

問題引起了我的Jenkins CI,因爲我運行的是乾淨的測試目標;基本上clean在CVS更新之前運行,所以它總是找到要更新的文件(被clean清除的.cvsignore)並觸發一個通常無用的構建。

我覺得要走的路是用排除,但我嘗試和沒有工作:

[INFO] [clean:clean {execution: default-clean}] 
[INFO] Deleting file set: **************************/target (included: [**], excluded: []) 

排除配置爲:

<plugin> 
    <artifactId>maven-clean-plugin</artifactId> 
    <executions> 
     <execution> 
      <id>not-clean</id> 
      <configuration> 
       <filesets> 
        <fileset> 
         <directory>target</directory> 
         <excludes> 
          <exclude>*cvsignore</exclude> 
         </excludes> 
         <followSymlinks>false</followSymlinks> 
        </fileset> 
       </filesets> 
      </configuration> 
      <phase>initialize</phase> 
      <goals> 
       <goal>clean</goal> 
      </goals> 
     </execution> 
    </executions> 
</plugin> 
+0

這段代碼簡直是錯的;正確的答案是我接受的答案 – 2011-04-28 08:21:07

回答

4

你可以嘗試設置<excludeDefaultDirectories>true,否則,我相信target文件夾總是會被刪除。

以下代碼片段適用於我。請注意,我使用default-clean作爲id

 <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-clean-plugin</artifactId> 
      <version>2.4.1</version> 
      <executions> 
       <execution> 
        <id>default-clean</id> 
        <configuration> 
         <excludeDefaultDirectories>true</excludeDefaultDirectories> 
         <filesets> 
          <fileset> 
           <directory>target</directory> 
           <excludes> 
            <exclude>.cvsignore</exclude> 
            <exclude>CVS</exclude> 
            <exclude>CVS/**</exclude> 
           </excludes> 
           <followSymlinks>false</followSymlinks> 
          </fileset> 
         </filesets> 
        </configuration> 
        <phase>initialize</phase> 
        <goals> 
         <goal>clean</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 
+0

問題是我想要目標目錄被清空,.cvsignore被排除。 也試過你建議沒有成功... – 2011-04-27 12:32:20

+0

@Riccardo。通過代碼段和控制檯輸出更新答案。 – Raghuram 2011-04-28 04:11:29

+0

謝謝Raghuram,你的代碼片段幾乎可以工作;我不得不調整排除了一點: \t \t \t \t \t \t \t \t \t 的.cvsignore \t \t \t \t \t \t \t \t CVS \t \t \t \t \t \t \t \t \t CVS/** \t \t \t \t \t \t \t \t \t 對不起,壞的格式,但它似乎沒有格式化意見的方式。 – 2011-04-28 08:14:42