即使在其他平台上运行,使用Maven程序集插件来设置Linux文件权限?

问题描述 投票:18回答:2

类似的问题:Can Ant's tar task set a Linux file permission even when the task is used on other platforms?

如果我使用带有'project'描述符的Maven 2程序集插件,有没有办法将shell脚本权限设置为可执行文件,例如包含的build.sh脚本文件?

例:

        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <descriptorRefs>
                    <descriptorRef>project</descriptorRef>
                </descriptorRefs>
            </configuration>
        </plugin>

这将创建三个文件

  • - 项目
  • Prajektataragaja
  • -project-ZIP

我想将tar文件中所有* .sh文件的文件权限设置为'executable'。

java maven file-permissions tar maven-assembly-plugin
2个回答
44
投票

这可以使用Maven Assembly Plugin fileMode中提供的assembly descriptor参数来完成。例如

<assembly>
    ...
    <fileSets>
        <fileSet>
            <directory>${project.build.directory}/bin</directory>
            <outputDirectory>/bin</outputDirectory>
            <includes>
                <include>*.sh</include>
            </includes>
            <fileMode>0755</fileMode>
        </fileSet>
        ...
    </fileSets>
    ...
</assembly>

1
投票

在评论中询问如何为目录设置permisions,以便它们不会以qazxsw poi权限结束。答案很简单 - 使用qazxsw poi:

d---------
© www.soinside.com 2019 - 2024. All rights reserved.