我想.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>
我希望这会在下载新工件之前清除整个存储库,最后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 1]
我觉得我非常接近解决方案。可能我只需要调整插件的参数标签。
谁能给个主意?