Extract Directory

12 views
Skip to first unread message

conrad.w...@gmail.com

unread,
Dec 18, 2010, 11:02:25 AM12/18/10
to maven-external-dependency-plugin
Hi all,

Thanks for a great mojo. I am currenyl trying to use it to put an OS X
app in my repository.

I have the following in my pom

<artifactItem>
<groupId>com.adobe</groupId>
<artifactId>flashplayer</artifactId>
<version>10.1</version>
<packaging>app</packaging>
<downloadUrl>http://download.macromedia.com/pub/flashplayer/updaters/
10/flashplayer_10_sa_debug.app.zip</downloadUrl>
<extractFile>Flash Player Debugger.app</extractFile>
</artifactItem>

Everything downloads correctly, but because OS X apps are actually
directories the build complains reports the following

[INFO] downloading artifact from URL:
http://download.macromedia.com/pub/flashplayer/updaters/10/flashplayer_10_sa_debug.app.zip
[INFO] extracting target file from downloaded compressed file: Flash
Player Debugger.app
.
.
.
[ERROR] Failed to execute goal com.savage7.maven.plugins:maven-
external-dependency-plugin:0.5-SONATYPE-r116:resolve-external
(default) on project flexmojos-tester: Could not find target artifact
file to extract from downloaded resouce:
[ERROR] groupId : com.adobe
[ERROR] artifactId : flashplayer
[ERROR] version : 10.1
[ERROR] extractFile : Flash Player Debugger.app
[ERROR] download URL : http://download.macromedia.com/pub/flashplayer/updaters/10/flashplayer_10_sa_debug.app.zip

I checked out the source code from subversion (because I am quite
willing to try and offer a patch for this myself), but unfortunatey
when I do a mvn clean install for the mojo it asks me for a gpg
password and I have no idea what to type in - typing in nothing, or
something means that it just fails.

[INFO] --- maven-gpg-plugin:1.1:sign (sign-artifacts) @ maven-external-
dependency-plugin ---
GPG Passphrase: *

Any clues - or do you want to try and make the plugin work with OS X
app directories?


Thanks

Conrad

Robert Savage

unread,
Dec 18, 2010, 11:11:37 AM12/18/10
to maven-external-d...@googlegroups.com
Hi Conrad,

I don't mind helping out, but would not be able to look into this issue for
a few days.
If you would like to try to work on it and submit a patch, you can comment
out the "maven-gpg-plugin" in the POM file to get past the GPG password
thing.
GPG signing was required for releasing into the public maven repository, but
I should have made it an optional execution under a special profile name so
that it would not block other trying to compile with maven or at least
limited execution to the DEPLOY phase. I don't know off the top of my head
why this would be failing for OSX. I have run this plugin on my Mac before
for certain projects, but maybe not under the same conditions of extracting
a file.

Thanks, Robert

Conrad Winchester

unread,
Dec 18, 2010, 11:16:57 AM12/18/10
to maven-external-d...@googlegroups.com
Thanks for your prompt response - I'll let you know how I get on with my investigations.

Conrad

Robert Savage

unread,
Dec 18, 2010, 2:56:46 PM12/18/10
to maven-external-d...@googlegroups.com
I did check in an updated POM file that moves the GPG to a custom profile. So GPG singing should not bother you anymore.

Thanks, Robert

Conrad Winchester

unread,
Dec 21, 2010, 2:02:18 AM12/21/10
to maven-external-d...@googlegroups.com
Hi Robert,

I have made some progress with getting a zip of an OS X app to work, however I am running into an issue that I don't know how to approach and wonder if you have any clues.

Basically an OS X app is a directory wrapper around an executable. I can use the mojo to download a zip containing the app and get it unpacked (only small changes required), however during the unpacking process the executable flag on the executable is lost, which means that the app will not run.

Take a look at

>>> http://download.macromedia.com/pub/flashplayer/updaters/
>>> 10/flashplayer_10_sa_debug.app.zip

unzip it and explore the .app directory you end up with. In Contents/MacOS/ you will find 'Flash Player Debugger' which must be executable.

I believe the problem lies with

org.codehaus.plexus.archiver.zip.AbstractZipUnArchiver

and in particular with


if ( !isIgnorePermissions() && mode != null )
{
ArchiveEntryUtils.chmod( f, mode.intValue(), getLogger(), isUseJvmChmod() );
}

Where mode is passed in as null (I think).

Essentially the unarchiver has to honour the execute permissions of the files it is anarchiving, and currently it is not - do you have any idea how to make that happen?


Conrad

Conrad Winchester

unread,
Dec 28, 2010, 9:33:53 AM12/28/10
to maven-external-d...@googlegroups.com
Hi again Robert,

OK I have reached this stage:

I have changed ResolveExternalDependancyMojo.java to allow unpacking of directories  without needing them to be repackaged.


                           if (extractedFile.isFile())
                           {
                               FileUtils.copyFile(extractedFile, artifactFile);
                           }
                           else if (extractedFile.isDirectory())
                           {
                               if (artifactItem.isRepack())
                               {
                                   Archiver archiver = archiverManager.getArchiver(artifactFile);
                                   archiver.setDestFile(artifactFile);
                                   archiver.addDirectory(extractedFile);
                                   archiver.createArchive();
                               }
                               else
                               {
                                   File targetDirectory = new File(parentDirectory.getAbsolutePath()+"/"+artifactFile.getName());
                                   targetDirectory.mkdir();
                                   FileUtils.copyDirectoryStructure( extractedFile, targetDirectory );
                               }
                           }
                           else
                           {

And if I have


             <artifactItem>
               <groupId>com.adobe</groupId>
               <artifactId>flashplayer</artifactId>
               <version>10.1</version>
               <packaging>app</packaging>

               <extractFile>Flash Player Debugger.app</extractFile>
             </artifactItem>

In my pom, this seems to work initially - in fact that I end up with the following directory structure in my staging directory

$ ls -la /Users/conrad/Documents/flexmojos-aggregator/flexmojos-testing/flexmojos-tester/target/dependencies
total ...
drwxr-xr-x  6 conrad  staff       204 28 Dec 14:14 .
drwxr-xr-x  7 conrad  staff       238 28 Dec 14:14 ..
drwxr-xr-x  3 conrad  staff       102 28 Dec 14:14 flashplayer-10.1.app

So I seem to getting the right directory into the staging directory.

However two things are wrong. I get the following error message

[ERROR] 
org.codehaus.plexus.digest.DigesterException: Unable to calculate the MD5 hashcode for /Users/conrad/Documents/flexmojos-aggregator/flexmojos-testing/flexmojos-tester/target/dependencies/flashplayer-10.1.app: /Users/conrad/Documents/flexmojos-aggregator/flexmojos-testing/flexmojos-tester/target/dependencies/flashplayer-10.1.app (No such file or directory)

even though the directory is definitely there and also I have the problem that I mentioned before - i.e. the actual executable file in the app has lost its execute permissions - If I just unzip the file myself then the execute permissions are not lost.

I have reached my limit of knowledge at the moment - are you able to offer any advice?



Conrad

Robert Savage

unread,
Dec 28, 2010, 11:32:09 AM12/28/10
to maven-external-d...@googlegroups.com

You may try to set the following two additional configuration options on the artifactItem to avoid the checksum error


<artifactItem>
<groupId>com.adobe</groupId>
<artifactId>flashplayer</artifactId>
<version>10.1</version>
<packaging>app</packaging>
<extractFile>Flash Player Debugger.app</extractFile>
<skipChecksumVerification>true</skipChecksumVerification>
<createChecksum>false</createChecksum>
</artifactItem>

This may get past the checksum errors, because the build it probably looking for a file and not a directory to perform the Md5 and SHA calculations against. 
Am looking into the org.codehaus.plexus.archiver.zip.AbstractZipUnArchiver a bit now.  

Thanks, Robert

Robert Savage

unread,
Dec 28, 2010, 12:17:21 PM12/28/10
to maven-external-d...@googlegroups.com
This bug report looks like there is a problem with the plexus ZIP unarchiver.

I added a vote on this item, you may want to do the same and add a comment that you have experienced this issue as well. 

In the meantime, would it be possible for you to add an ANT task as part of your maven build to apply the correct permissions to the file(s) after it is downloaded and extracted?  

I know this is not ideal, but may be a viable workaround for now.  

-Robert



On Dec 28, 2010, at 8:33 AM, Conrad Winchester wrote:

Robert Savage

unread,
Dec 28, 2010, 12:27:09 PM12/28/10
to maven-external-d...@googlegroups.com

Hi Conrad, 

I also just noticed that there is a newer version of plexus-archiver (1.2) available. 

You may want to try upgrading the maven dependency plugin project to this newer version to see if this issue goes away.  

        <dependency>
          <groupId>org.codehaus.plexus</groupId>
          <artifactId>plexus-archiver</artifactId>
          <version>1.2</version>
        </dependency> 


Thanks, Robert


On Dec 28, 2010, at 8:33 AM, Conrad Winchester wrote:

Reply all
Reply to author
Forward
0 new messages