首页 > 代码库 > question --> maven assembly plugin 修改文件默认权限

question --> maven assembly plugin 修改文件默认权限

 

使用maven assembly plugin插件添加执行脚本时,发现默认权限为644,还需要手动添加执行权限。这很麻烦,于是查看文档

官方文档 http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html#class_fileSet

fileMode String Similar to a UNIX permission, sets the file mode of the files included. THIS IS AN OCTAL VALUE. Format: (User)(Group)(Other) where each component is a sum of Read = 4, Write = 2, and Execute = 1. For example, the value 0644 translates to User read-write, Group and Other read-only. The default value is 0644. (more on unix-style permissions)

可知道默认文件权限为0644,所以调整权限0744即可。

 1 <assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
 2           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 3           xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
 4     <id></id>
 5     <formats>
 6         <format>dir</format>
 7         <format>tar.gz</format>
 8     </formats>
 9     <includeBaseDirectory>false</includeBaseDirectory>
10     <fileSets>
11         <fileSet>
12             <directory>target/classes</directory>
13             <includes>
14                 <include>**/*.*</include>
15             </includes>
16             <outputDirectory>gpay-report/classes</outputDirectory>
17         </fileSet>
18 
19         <fileSet>
20             <directory>../</directory>
21             <includes>
22                 <include>start.sh</include>
23             </includes>
24             <!--修改文件默认权限0644,需要有执行权限-->
25             <fileMode>0744</fileMode>
26             <outputDirectory>gpay-report</outputDirectory>
27         </fileSet>
28     </fileSets>
29 
30     <dependencySets>
31         <dependencySet>
32             <useProjectArtifact>false</useProjectArtifact>
33             <outputDirectory>gpay-report/lib</outputDirectory>
34             <scope>runtime</scope>
35         </dependencySet>
36     </dependencySets>
37 </assembly>

 

question --> maven assembly plugin 修改文件默认权限