Maven 程序集插件 chmod 输出文件夹

发布于 2024-11-08 05:08:15 字数 2170 浏览 3 评论 0 原文

我正在尝试使用 maven- assembly 插件来构建我的项目 JAR 的 zip 以及运行它所需的所有库:

        <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>

我的程序集如下所示:

<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>

这可以工作并生成正确的 zip。

然后,dependencySet 上的 fileMode 标志为 LIB 内的每个元素提供 755 CHMOD。问题是,实际的 LIB 文件夹本身仍然是 777。有没有办法让 LIB 文件夹也得到 755?

让 Maven 做它不想做的事情总是让我伤心:(

I am trying to use the maven-assembly plugin like so to build a zip of my project JAR and all 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 works and makes the proper zip.

Then the fileMode flag on the dependencySet gives each element inside of LIB a 755 CHMOD. The problem is, the actual LIB folder itself stays 777. Is there a way to make the LIB folder also get a 755?

Making maven do things it doesn't want to do always makes me sad :(

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

心碎的声音 2024-11-15 05:08:15

这确实很奇怪,但是以下 pom.xml 片段会将 0755 模式设置为程序集的所有目录。不过,我认为这不是很可靠(面向未来),因为显然,maven 作者打算使用众所周知的 Unix 八进制表示法来指定目录访问模式,而不是十进制等价

        <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>

原始信用必须位于此处:https://issues.apache.org/jira/browse/ MASSEMBLY-494

This is really weird, but following snippet of pom.xml will set 0755 mode to all directories of assembly. Though, I think this isn't very reliable (future-proof), as, obviously, maven authors intended to use well-known Unix octal notation to specify directory access mode, not 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>

Original credit must go here: https://issues.apache.org/jira/browse/MASSEMBLY-494

没︽人懂的悲伤 2024-11-15 05:08:15

我自己还没有尝试过,所以我不能说它是否适用于目标目录或仅适用于添加到目标目录的目录,但您确实应该尝试一下

 <directoryMode>755</directoryMode>

它在 文档

Haven't tried it myself so I can't say if it works with the target directory or just directories added to the target directory, but you should really try out

 <directoryMode>755</directoryMode>

it's in the docs

流殇 2024-11-15 05:08:15

我不认为 maven- assembly-plugin 现在可以做到这一点。所以我只是在 bash 脚本中进行了更改......

I don't think the maven-assembly-plugin can do this right now. So I just did my changes in bash scripts...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文