Invalid LOC header(bad signature)

前端 未结 3 1631
无人及你
无人及你 2020-12-20 15:11

I am getting this error during my Maven build.

Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:2.4.3:shade (default) on project dl4j-examples: Err

3条回答
  •  不知归路
    2020-12-20 15:51

    I've been facing this issue for a long time

    So I decided to automate the identification and the removal of corrupt jars

    this is the util class I created for this purpose:

    import java.io.File;
    import java.io.IOException;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    import java.util.jar.JarFile;
    
    public class MavenFix {
    
        public static void main(String[] args) throws IOException {
            Files.walk(Paths.get("C:/data/.m2/repository"))
            .filter(file -> file.toString().endsWith("jar"))
            .forEach(path -> {
                try {
                    System.out.print(".");
                    new JarFile(path.toString(), true).getManifest();
                } catch (Exception e) {
                    System.out.println();
                    System.out.println(path + " - " + e.getMessage());
                    try {
                        cleanAndDeleteDirectory(path.getParent().toFile());
                    } catch (IOException e1) {
                        System.err.println(e1.getMessage());
                    }
                }
            });
        }
    
        public static void cleanAndDeleteDirectory(File dir) throws IOException {
            File[] files = dir.listFiles();
            if (files != null && files.length > 0) {
                for (File aFile : files) {
                    Files.delete(aFile.toPath());
                }
            }
            Files.delete(dir.toPath());
        }
    }
    

提交回复
热议问题