标签: maven-clean-plugin

Maven Clean:删除目标内的目录

我尝试了很多变种,但无法完成这项工作.一个例子(孩子pom.xml):

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-clean-plugin</artifactId>
    <configuration>
        <filesets>
            <fileset>
                <directory>target</directory>
                <useDefaultExcludes>true</useDefaultExcludes>
                <excludes>
                    <exclude>myFolder</exclude>
                </excludes>
            </fileset>
        </filesets>
    </configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)

Maven总是试图删除我的文件夹.为什么?

maven maven-clean-plugin

9
推荐指数
1
解决办法
4637
查看次数

使用maven-clean-plugin删除目录

我可以用maven-clean-plugin删除目录吗?

以下配置从给定目录中删除文件,但目录本身将保留:

<plugin>
    <artifactId>maven-clean-plugin</artifactId>
    <version>2.4.1</version>
    <configuration>
        <filesets>
            <fileset>
                <directory>src/main/javascript/node_modules</directory>
                <includes>
                    <include>**/*</include>
                </includes>
                <followSymlinks>false</followSymlinks>
            </fileset>
        </filesets>
    </configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)

我检查了插件的文档,但我看不到任何删除目录的方法:http://maven.apache.org/plugins-archives/maven-clean-plugin-2.6.1/clean-mojo.html

我也需要删除目录.

java maven maven-clean-plugin

6
推荐指数
1
解决办法
3955
查看次数

maven-clean-plugin没有删除所有给定的目录

在我的项目中,.pom我设置了maven-clean-plugin这样的:

<plugin>
  <artifactId>maven-clean-plugin</artifactId>
  <version>2.6.1</version>
  <configuration>
    <filesets>
      <fileset>
        <directory>src/main/webapp/bower_components</directory>
      </fileset>
      <fileset>
        <directory>node_modules</directory>
      </fileset>
      <fileset>
        <directory>node</directory>
      </fileset>
    </filesets>
  </configuration>
 </plugin>
Run Code Online (Sandbox Code Playgroud)

插件的目的是删除由其创建的目录frontend-maven-plugin.无论如何,最后一个工作正常.


问题

现在的问题是,无论如何,永远不会删除上述文件夹之一.它始终是"中间的".我添加了3 filesets并且始终没有删除第二个,请参阅日志:

[INFO] Deleting /src/main/webapp/bower_components (includes = [], excludes = [])
[INFO] Deleting /node_modules (includes = [.bindings], excludes = [])
[INFO] Deleting /node (includes = [], excludes = [])
Run Code Online (Sandbox Code Playgroud)

如果我更改文件夹的顺序:

[INFO] Deleting /src/main/webapp/bower_components (includes = [], excludes = [])
[INFO] Deleting /node (includes = [.bindings], excludes = [])
[INFO] Deleting /node_modules (includes = …
Run Code Online (Sandbox Code Playgroud)

java maven-plugin maven-3 maven maven-clean-plugin

5
推荐指数
1
解决办法
3935
查看次数

followSymlinks 不适用于 maven-clean-plugin

我正在尝试使用“maven-clean-plugin”来删除位于 /my/path 文件夹中的其他文件。

<plugin>
   <artifactId>maven-clean-plugin</artifactId>
   <executions>
       <execution>
           <id>clean-on-cleaning</id>
           <phase>clean</phase>
           <goals>
               <goal>clean</goal>
           </goals>
           <configuration>                      
               <filesets>
                   <fileset>
                       <directory>target/dart</directory>
                   </fileset>
                   <fileset>
                       <directory>src/main/dart/.pub</directory>
                   </fileset>
                   <fileset>
                       <directory>src/main/dart/build</directory>
                   </fileset>
                   <fileset>
                       <directory>${env.APPDATA}/Pub/Cache</directory>
                   </fileset>
                   <fileset>
                       <directory>src/main/dart/packages</directory>    
                       <followSymlinks>false</followSymlinks>
                   </fileset>
               </filesets>
           </configuration>
       </execution>
   </executions>
Run Code Online (Sandbox Code Playgroud)

“src/main/dart/packages”包含链接。其中一个链接指向“src/main/dart/lib”文件夹。我已经设定:

<followSymlinks>false</followSymlinks> 
Run Code Online (Sandbox Code Playgroud)

所以它不应该删除 lib 目录中的文件。但不幸的是它确实如此。问题可能出在哪里?

环境配置:

  • Maven:apache-maven-3.3.3
  • Java 版本:1.7.0_55(也在 1.8.0_51 上试过)
  • 操作系统名称:Windows 7
  • 版本:6.1
  • 拱:amd64

maven maven-clean-plugin

5
推荐指数
1
解决办法
947
查看次数

如何在 maven clean 阶段删除文件夹?

我想在清理阶段删除一个文件夹。

我已经使用maven-clean-plugin并成功删除了它下的所有文件。

        <plugin>
            <artifactId>maven-clean-plugin</artifactId>
            <version>3.0.0</version>

            <configuration>
                <filesets>
                    <fileset>
                        <directory>GENERATED_DIR</directory>
                        <includes>
                            <include>**/*</include>
                        </includes>
                        <followSymlinks>false</followSymlinks>
                    </fileset>
                </filesets>
            </configuration>
        </plugin>
Run Code Online (Sandbox Code Playgroud)

我也想删除“GENERATED_DIR”。

maven maven-clean-plugin

3
推荐指数
1
解决办法
2436
查看次数

Maven清洁生命周期

我已经阅读过maven在很多地方的清洁和网站生命周期,但无法理解它是如何工作的.请通过一些示例向我解释Maven的清洁生命周期过程.它与构建有何不同.在构建开始之前,清洁已经完成,对吗?清洁前后阶段会发生什么.

eclipse maven maven-clean-plugin

2
推荐指数
2
解决办法
1060
查看次数

在安装阶段通过maven-plugin清除本地Maven存储库

我想.m2/repository在安装阶段之前删除整个存储库()的内容。当然,我不想手工完成,因此我正在寻找一款具有魔力的插件。到目前为止,我遇到了,maven-clean-plugin并且我正尝试按以下方式使用它:

<build>
      <sourceDirectory>src/</sourceDirectory>
      <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.2</version>
            <configuration>
               <source>${jdk.version}</source>
               <target>${jdk.version}</target>
            </configuration>
        </plugin>  
        <plugin>
        <artifactId>maven-clean-plugin</artifactId>
        <version>3.0.0</version>
        <configuration>
        <filesets>
                  <fileset>
                      <directory>${settings.localRepository}/</directory>
                      <includes>
                          <include>**/*</include>
                      </includes>
                  </fileset>
        </filesets>
        </configuration>
        <executions>
          <execution>
            <id>auto-clean</id>
            <phase>install</phase>
            <goals>
              <goal>clean</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      </plugins>
   </build>
Run Code Online (Sandbox Code Playgroud)

我希望这可以在下载新的工件之前清除整个存储库,最后target从模块中删除该文件夹。删除target文件夹是可行的,但是清除存储库还是行不通的。它确实清除了存储库,但是随后Maven抱怨缺少所需的某些工件,因此编译失败并返回以下错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.3:resources (default-resources) on project com.google.protobuf: Execution default-resources of goal org.apache.maven.plugins:maven-resources-plugin:2.3:resources failed: Plugin org.apache.maven.plugins:maven-resources-plugin:2.3 or one of its dependencies could not be resolved: Could not find artifact org.apache.maven.plugins:maven-resources-plugin:jar:2.3 -> [Help …
Run Code Online (Sandbox Code Playgroud)

maven maven-clean-plugin

0
推荐指数
1
解决办法
406
查看次数

Maven clean无法删除文件

尝试配置 maven clean 插件以删除我项目中的其他目录,但它无法正常工作。这是使用 maven 3.5 的简单复制。

开始使用简单的演示应用程序:https : //maven.apache.org/guides/getting-started/maven-in-five-minutes.html

修改pom.xml配置maven-clean-plugin

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.mycompany.app</groupId>
    <artifactId>my-app</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>Maven Quick Start Archetype</name>
    <url>http://maven.apache.org</url>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <version>3.0.0</version>
                <executions>
                    <execution>
                        <id>auto-clean</id>
                        <phase>clean</phase>
                        <goals>
                            <goal>clean</goal>
                        </goals>
                        <configuration>
                            <verbose>true</verbose>
                            <fieldsets>
                                <fieldset>
                                    <directory>${basedir}</directory>
                                    <includes>
                                        <include>demo/**</include>
                                    </includes>
                                </fieldset>
                            </fieldsets>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.2</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)

创建一个名为的虚拟目录 demo

 mkdir demo && touch demo/hello
Run Code Online (Sandbox Code Playgroud)

现在运行:

 mvn package
 mvn clean …
Run Code Online (Sandbox Code Playgroud)

java maven maven-clean-plugin

0
推荐指数
1
解决办法
7128
查看次数