4

I have a project with 2 files (src/foo/a.txt and src/foo/b.txt) and I want to create a zip archive where b.txt is in readonly.

Here's my environment:

  • Windows 7
  • JRE 1.8.0_112
  • Maven 3.3.3
  • maven-assembly-plugin 3.0.0
  • 7-Zip 9.20

Here's my 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>

and here's my assembly descriptor:

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

When I unzip the generated archive, and open the properties of b.txt, the "readonly" checkbox is not checked.

I'm aware of: Maven assembly plugin not applying fileMode on unpacked dependencySet and maven assembly plugin do not set file attributes but they haven't helped me much.

I tried various fileMode values (0444 or 0544) but I just can't get my file to be uncompressed in readonly mode.

Any ideas?

Community
  • 1
  • 1
Pigelvy
  • 606
  • 6
  • 17

0 Answers0