apache / apache/maven-jar-plugin

Preserve POSIX file permissions for entries added from classesDirectory

Open
#567 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
92
Forks
84
Avg merge
19h 45m
Merged PRs (30d)
6

Description

## Use case

A project builds a JAR on Linux and later extracts that JAR on Linux as part of assembling a distributable artifact. Some resources are executable shell scripts. The extracted scripts should retain their source POSIX permissions, such as `0755`, so they can be invoked directly.

## Current behavior

With Maven Jar Plugin 3.5.1 on Linux:

1. A resource file under `src/main/resources` is mode `0755`.
2. The copied file under `target/classes` remains mode `0755`.
3. After `mvn package`, the corresponding JAR entry has Unix mode `100644`.
4. Extracting the JAR on Linux produces a non-executable file.

The plugin creates a `DefaultFileSet` for `classesDirectory` without resource mode attributes, so Plexus Archiver falls back to its default file mode.

## Requested behavior

When creating a JAR on a POSIX filesystem, preserve the POSIX file permissions of entries added from the classes directory (or provide an opt-in configuration that does so). This would allow a JAR created on Linux and extracted on Linux to retain executable resource scripts.

This is distinct from the mode of the generated JAR file itself; it concerns the Unix mode metadata of entries inside the JAR.

## Reproduction

```sh
chmod 755 src/main/resources/hooks/session-start.sh
mvn package
zipinfo -l target/example.jar | grep session-start.sh
```

Expected entry mode: `-rwxr-xr-x` (`100755`).

Actual entry mode: `-rw-r--r--` (`100644`).

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the JAR creation path that creates a DefaultFileSet for classesDirectory, then trace how Plexus Archiver assigns entry modes when resource attributes are absent. Reproduce with the chmod and mvn package commands, and inspect target/example.jar with zipinfo -l. Done means a 0755 source script appears as 100755 in the JAR on POSIX systems without changing the generated JAR file's own mode.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.