czwartek, 13 lipca 2017

[memo] purging broken JARs from Maven repository

Ever encountered dreaded "java.util.zip.ZipException: invalid LOC header (bad signature)" while building a Maven project? If yes, it means that Maven (somehow) downloaded a broken JAR into your repository. There is not much that can be done besides purging all of the "broken" JARs from the repository.

Two options are possible:

  • delete whole Maven repository - which means downloading all of the JARs, of all projects (possibly few gigs) again (!!)
  • delete only offending JARs - list can be obtained for example by issuing following command:
find  /home/me/.m2/repository/ -name "*jar" | xargs -L 1 zip -T | grep error | grep invalid

 Both options, well, suck :-) Fortunately there is a way to purge all of the JARs from local repository that pertain to only one project. It's provided by the dependency Maven plugin. Just issue
mvn dependency:purge-local-repository
and it's done. NEAT!

Brak komentarzy: