使用Maven程序集插件为特定文件设置Linux文件权限

时间:2015-08-12 09:33:57

标签: java linux maven maven-3 maven-assembly-plugin

如何使用Maven程序集插件为特定文件设置文件权限?

以下工作正常,但它只包含已组装的存档中的 specificShFile.sh

<assembly>
    <formats>
        <format>zip</format>
    </formats>
    <fileSets>
        <fileSet>
            <directory>${project.build.outputDirectory}</directory>
            <outputDirectory>/</outputDirectory>
            <includes>
                <include>specificShFile.sh</include>
            </includes>
            <fileMode>0755</fileMode>
        </fileSet>
        ...
    </fileSets>
    ...
</assembly>

我想要的是所有文件都包含在zip中,但只允许设置为该特定文件。

2 个答案:

答案 0 :(得分:0)

您可以使用

 <fileSets>
          <fileSet>
            <useDefaultExcludes/>
            <outputDirectory/>
            <includes/>
            <excludes/>
            <fileMode/>
            <directoryMode/>
            <directory/>
            <lineEnding/>
            <filtered/>
          </fileSet>
  </fileSets>

更具体这样

<fileSets>
        <fileSet>
            <directory>src/main/java</directory>
            <outputDirectory>src/main/java</outputDirectory>
            <includes>
                <include>**</include>
            </includes>
            <useDefaultExcludes>true</useDefaultExcludes>
            <fileMode>0644</fileMode>
            <directoryMode>0755</directoryMode>
        </fileSet>
    </fileSets>

答案 1 :(得分:0)

非常感谢@SubOptimal的提示,这是对我有用的解决方案:

<assembly>
    <formats>
        <format>zip</format>
    </formats>
    <fileSets>
        <fileSet>
            <directory>${project.build.outputDirectory}</directory>
            <outputDirectory>/</outputDirectory>
            <excludes>
                <exclude>specificShFile.sh</exclude>
            </excludes>
        </fileSet>
        <fileSet>
            <directory>${project.build.outputDirectory}</directory>
            <outputDirectory>/</outputDirectory>
            <includes>
                <include>specificShFile.sh</include>
            </includes>
            <fileMode>0755</fileMode>
        </fileSet>
        ...
    </fileSets>
    ...
</assembly>