As part of a development deployment - I need to SCP a zipped folder of assets to a virtual machine, and then extract it there.

Is there a plugin(s) that will do this, before I roll my own?

1 Answer 1


I found the maven-antrun-plugin is perfect for this kind of thing.

Taken from this StackOverflow answer



                    <plugin>          <groupId>org.apache.maven.plugins</groupId>



                                    <fileset id="zipfiles.to.copy" dir="${archives.source}" includes = "*.zip">
                                        <include name = "*unminified.zip"/>
                                        <include name = "*thirdparty.zip"/> 
                                    <!-- copy the archives to the remote server -->
                                    <scp todir="${user}:${password}@${vagrant.host}:${archives.destination}">
                                        <fileset refid="zipfiles.to.copy" />

                            <!-- Build the command line for unzip - the idea here is to turn the local
                                 paths into the corresponding paths on the remote, i.e. to turn
                                 C:\path\to\zipfiles\file1.zip;C:\path\to\zipfiles\file2.zip... into
                                 /home/testuser/archives/file1.zip /home/testuser/archives/file2.zip

                                 For this to work there must be no spaces in any of the zipfile names.
                             <pathconvert targetos="unix"  pathsep=" " property="unzip.files" refid="zipfiles.to.copy">
                                <map from="${basedir}/${archives.source}" to="${archives.destination}" />

                            <!-- execute the command.  Use the "-d" option to unzip so it will work
                            whatever the "current" directory on the remote side -->
                            <sshexec host="${vagrant.host}" username="${user}" password="${password}"
                                command="/bin/sh -c '
                                for zipfile in ${unzip.files}; do
                                /usr/bin/unzip  -o -d ${unzip.destination} $$zipfile ; done '" />


The one thing to be aware of is the use of your ${archive.source} and ${basedir} in the pathconvert command.

I made it this way because you need to explicit with the full path name in the pathconvert - but you want to be relative in sourcing where they're from in the first place.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.