У меня есть проект с двумя файлами (src/foo/a.txt и src/foo/b.txt), и я хочу создать zip-архив, в котором b.txt доступен только для чтения.
Вот моя среда:
- Windows 7
- JRE 1.8.0_112
- Мавен 3.3.3
- maven-сборка-плагин 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, флажок «только для чтения» не ставится.
Мне известно о: Плагин сборки Maven не применяет fileMode к распакованному dependencySet и плагин сборки maven не устанавливает атрибуты файла но они мне не сильно помогли.
Я пробовал различные значения fileMode (0444 или 0544), но я просто не могу распаковать мой файл в режиме только для чтения.
Любые идеи?