【问题标题】:Use Maven assembly plugin to set Linux file permissions even when run on other platforms?即使在其他平台上运行,也使用 Maven 程序集插件设置 Linux 文件权限?
【发布时间】:2011-06-10 19:16:29
【问题描述】:

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

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

例子:

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

这将创建三个文件

  • -project.tar.bz2
  • -project.tar.gz
  • -project-zip

我想将 tar 文件中的所有 *.sh 文件的文件权限设置为“可执行”。

【问题讨论】:

    标签: java maven file-permissions tar maven-assembly-plugin


    【解决方案1】:

    在 cmets 中询问如何为目录设置权限,以便它们不会以 d--------- 权限结束。答案很简单——使用directoryMode

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

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

      • 如果我用 Tycho 编译我的插件 Eclipse RCp 它是如何工作的?我需要在哪里写这些文件?我只有一些 pomx.xml 文件... Tycho 有“fileMode”吗?
      • 它将我的 bin/ 目录设置为 d--------- 权限:\。里面的文件没问题。
      • 这将创建具有 775 权限的文件的 tar,所有目录(文件夹)甚至没有读取权限(d--------)。为此应该怎么做?
      猜你喜欢
      • 2011-04-10
      • 2015-11-04
      • 1970-01-01
      • 2016-03-23
      • 2013-09-09
      • 2017-01-28
      • 2013-01-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多