How can I unzip a symbolic link using maven?

I have symlinks that are stored in a zip file.

When unpacking this file using the Mac OS system, symlinks are supported (meaning they are symlinks and appaer as such).

But when unpacking them with maven (and in particular the unpack-dependencies mojo), they look like simple files.

So, is there a maven plugin that retains this flag?

+3


source to share


3 answers


Consistent with the other answers, it looks like some of them are pure Java libraries to allow you to undo symbolic links.

In such a solution, in order to have a clean multiplatform build, you don't just create a module for each os, because that would lead to a classic class arms race, and, more pragmatically, it would not fit that module lifecycle.

As a consequence, I used my classic scripting solution in maven: GMaven !



which resulted in this not so pretty script

            <plugin>
                <groupId>org.codehaus.gmaven</groupId>
                <artifactId>gmaven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unzip native code using Groovy</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>execute</goal>
                        </goals>
                        <configuration>
                            <providerSelection>${gmaven.provider.version}</providerSelection>
                            <source>
<![CDATA[

def ant = new AntBuilder()

def FOLDERS_TO_EXPLORE = [] /* put here the list of folders in which zip files will be recursively searched */

def unzip(File file) {
    def RUN_ON_WINDOWS = System.getProperty("os.name").toLowerCase().indexOf("win")>=0
    if(RUN_ON_WINDOWS) {
        log.debug "unzipping windows style"
        ant.unzip(  src: file, dest:file.parentFile,  overwrite:"true")
    } else {
        def result = ant.exec(outputproperty:"text",
                 errorproperty: "error",
                 resultproperty: "exitValue",
                 dir: file.parent,
                 failonerror: true,
                 executable: "unzip") {
                       arg(value:file.name)
                 }

        if(Integer.parseInt(ant.project.properties.exitValue)!=0) {
            log.error "unable to unzip "+file.name+" exit value is "+ant.project.properties.exitValue
            log.error "=========================================================\noutput\n=========================================================\n"+ant.project.properties.text
            log.error "=========================================================\nerror\n=========================================================\n"+ant.project.properties.error
            fail("unable to unzip "+file)
        } else {
            log.info "unzipped "+file.name
        }
    }
    file.delete()
}

def unzipContentOf(File file) {
    file.eachFileRecurse { 
        if(it.name.toLowerCase().endsWith("zip")) {
            unzip(it)
        }
    }
}

FOLDERS_TO_EXPLORE.each { unzipContentOf(new File(it)) }
]]>

      

0


source


I would suggest trying truezip-maven-plugin .



+2


source


Symbolic links are not implemented on all operating systems. In fact, looking at the javadocs , I don't quite understand that the SDK supports this type of zip recording at all - from what I can tell, it's just files and disks. I would not say that this is a limitation of the dependency plugin, because of this reason.

+1


source







All Articles