Maven 程序集插件 chmod 输出文件夹
我正在尝试使用 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 做它不想做的事情总是让我伤心:(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这确实很奇怪,但是以下
pom.xml
片段会将 0755 模式设置为程序集的所有目录。不过,我认为这不是很可靠(面向未来),因为显然,maven 作者打算使用众所周知的 Unix 八进制表示法来指定目录访问模式,而不是十进制等价。原始信用必须位于此处: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.Original credit must go here: https://issues.apache.org/jira/browse/MASSEMBLY-494
我自己还没有尝试过,所以我不能说它是否适用于目标目录或仅适用于添加到目标目录的目录,但您确实应该尝试一下
它在 文档
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
it's in the docs
我不认为 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...