Java – Maven assembly plug-in Chmod output folder

I'm trying to use a maven assembly plug-in like this to build the zip of my project jar and all the libraries needed to run it:

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.2.1</version>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <descriptors>
<descriptor>src/main/assembly/exportWithDepends.xml</descriptor>
                            </descriptors>
                            <finalName>myname</finalName>
                            <appendAssemblyId>false</appendAssemblyId>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

My assembly looks like:

<assembly>
    <id>jar-with-dependencies</id>
    <formats>
        <format>zip</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>
    <dependencySets>
        <dependencySet>
            <unpack>false</unpack>
            <scope>runtime</scope>
            <outputDirectory>lib</outputDirectory>
            <useProjectArtifact>true</useProjectArtifact>
            <fileMode>755</fileMode>
        </dependencySet>
    </dependencySets>
    <files>
        <file>  
<source>${project.build.directory}/${project.build.finalName}.jar</source>
        </file>
    </files>
</assembly>

This applies to making suitable zippers

Then, the FileMode flag on the dependencyset provides 755 Chmod for each element in the lib The problem is that the actual lib folder itself remains 777 Is there any way to get the Lib folder 755?

It always hurts me to let Maven do something it doesn't want to do:(

Solution

It's really strange, but the POM below The XML fragment sets the 0755 mode to all directories of the assembly Although, I don't think this is very reliable (for the future), because obviously, the Maven author intends to use the well-known UNIX octal representation to specify the directory access mode, rather than the decimal equivalent

<plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <archiverConfig>
                    <!-- 493D == 0755,seems to be assembly plugin bug -->
                    <defaultDirectoryMode>493</defaultDirectoryMode>
                </archiverConfig>
            </configuration>

The original credit must be here: https://issues.apache.org/jira/browse/MASSEMBLY-494

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>