我有一个包含2个文件的项目(src / foo / a.txt和src / foo / b.txt),我想创建一个zip存档,其中b.txt是readonly .
这是我的环境:
-
Windows 7
-
JRE 1.8.0_112
-
Maven 3.3.3
-
maven-assembly-plugin 3.0.0
-
7-Zip 9.20
这是我的pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.foo</groupId>
<artifactId>foo-zip</artifactId>
<version>0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<phase>package</phase>
<goals><goal>single</goal></goals>
</execution>
</executions>
<configuration>
<encoding>UTF-8</encoding>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/foo-assembly.xml</descriptor>
</descriptors>
</configuration>
</plugin>
</plugins>
</build>
</project>
这是我的汇编描述符:
<?xml version="1.0" encoding="UTF-8"?>
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>foo-zip</id>
<includeBaseDirectory>false</includeBaseDirectory>
<formats><format>zip</format></formats>
<fileSets>
<fileSet>
<directory>src/foo</directory>
<excludes><exclude>b.txt</exclude></excludes>
<outputDirectory />
</fileSet>
<fileSet>
<directory>src/foo</directory>
<includes><include>b.txt</include></includes>
<fileMode>0444</fileMode>
<outputDirectory />
</fileSet>
</fileSets>
</assembly>
当我解压缩生成的存档并打开b.txt的属性时,不会选中“readonly”复选框 .
我知道:Maven assembly plugin not applying fileMode on unpacked dependencySet和maven assembly plugin do not set file attributes但他们没有帮助我 .
我尝试了各种fileMode值(0444或0544),但我无法让我的文件在readonly模式下解压缩 .
有任何想法吗?