Clear local maven repository via maven-plugin on install phase -
i'd delete content of entire repository (.m2/repository
) before installation phase. of course don't want hand looking plugin magic. far came across maven-clean-plugin
, trying use follows:
<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>
i expect wipe out entire repository before downloading new artifacts, , remove target
folder modules. removal of target
folders works, wiping out repository kinda not working. wipe out repository, maven complains artifacts required missing compilation fails , returns such errors:
[error] failed 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 1 of dependencies not resolved: not find artifact org.apache.maven.plugins:maven-resources-plugin:jar:2.3 -> [help 1]
i feel pretty close solution. need tweak parameter tags of plugin.
could give idea?
if clean entire local repository delete plugins needed maven , downloaded before clean runs. should use dependency plaugin delteing jars dependecies of project:
mvn dependency:purge-local-repository
in pom can use like:
<plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-dependency-plugin</artifactid> <version>2.7</version> <executions> <execution> <id>purge-local-dependencies</id> <phase>clean</phase> <goals> <goal>purge-local-repository</goal> </goals> <configuration> <resolutionfuzziness>groupid</resolutionfuzziness> <includes> <include>org.ambraproject</include> </includes> </configuration> </execution> </executions> </plugin>
Comments
Post a Comment