Monday, 27 August 2012

Maven Assembly/Dependency plugins useJvmChmod field WTF ?

It looks not a lot folks knows a strange named option  from the Assembly and Dependency Maven plugins.
The name is useJvmChmod. Sure when reading this name you can say: "WTF ?????".
Both plugins use a component called plexus-archiver (which pack,unpack files and can set files permissions).
By default on unix platform, this component will fork a process to do chmod command line call and for each files (ouch !!!! for large distributions or unpack goal).
So long ago now (yup 2 years is long in our world :-)), I added a configurable mode to use file permission methods from jdk1.6 and not using anymore forked command line call to chmod.
This is why it's called useJvmChmod (sorry I'm sometimes not really good on naming marketing :-)).
By the way, if your build is still 1.5 that will works as it's done trough reflection (see initial commit ).
Note this option is available since assembly plugin 2.2 and it's now available in the fresh release of dependency plugin 2.5.1 (thanks to @atlassian folks for the issue report: https://jira.codehaus.org/browse/MDEP-368).
So if you assembly plugin or use unpack goal from the dependency don't miss this attribute to true!
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-assembly-plugin</artifactId>
          or
          <artifactId>maven-dependency-plugin</artifactId>
          <configuration>
            <useJvmChmod>true</useJvmChmod>
          </configuration>
        </plugin>
NOTE: if you use useJvmChmod special permissions at group level won't be apply as it doesn't exists in java

4 comments:

Daniel Kulp said...

If it still works with Java 5 by downgrading to the chmod forking, why not just make it the default?

olamy said...

dkulp because we are 1.5 conservative :P
More seriously just to prevent to much warning logs.
BTW a false problem: we can simply remove the warning.

olamy said...

Note for myself use PosixFilePermission from 1.7

Kristian Rosenvold said...

https://jira.codehaus.org/browse/PLXCOMP-248