apache / apache/maven-assembly-plugin

[MASSEMBLY-918] Owner and group of files and directories

Open
#1,127 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Java
Stars
110
Forks
75
Avg merge
12h 54m
Merged PRs (30d)
10

Description

**[Marat Abrarov](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=abrarovm)** opened **[MASSEMBLY-918](https://issues.apache.org/jira/browse/MASSEMBLY-918?redirect=false)** and commented

This is new feature request similar to MASSEMBLY-668 and MASSEMBLY-442 (I cannot reopen existing JIRA issues - I have no required permissions in JIRA).

Below is description of my case when I need Maven Assembly Plugin to provide ability to specify owner and group for files and directories (I need `root:root` actually). I need this ability (new feature) for TAR files created by Maven Assembly Plugin.

I use Maven Assembly Plugin to prepare TAR, because
1. I use TARs with [`ADD` Dockerfile directive](https://docs.docker.com/engine/reference/builder/#add) because I have Linux and Windows build systems so TAR is the only option to add files into Docker image with specific Unix file permissions (thanks to `fileMode` and `directoryMode` options of Maven Assembly Plugin)
2. I have old Docker 1.13.1 (I'm limited to Red Hat Docker images and RHEL 7, I cannot use [Podman](https://podman.io/) because it lacks remote access which I need because of Windows is used on some development environments) and cannot use `ADD --chown` Dockerfile directive or multi-stage Dockerfile because of version of Docker
3. I cannot use `RUN` Dockerfile directive to change Unix file permissions and / or owner / group because it duplicates files added with `ADD` or `COPY` Dockerfile directives (the only simple way to add results of build into Docker image). Refer to [The backlash of chmod/chown/mv in your Dockerfile](https://medium.com/@lmakarov/the-backlash-of-chmod-chown-mv-in-your-dockerfile-f12fe08c0b55) for details.

When I build on Windows - refer to [dockerfile-test](https://github.com/mabrarov/dockerfile-test) test project - then files are added with `root:root` owner (that's acceptable for my case). This can be tested with below commands (launch Docker container, so require Docker):

```java
$ docker run --rm abrarov/dockerfile-test ls -lh /app
$ docker run --rm abrarov/dockerfile-test ls -lh /app/bin
```

It looks like this new feature requires changing of [Plexus-archiver](https://github.com/codehaus-plexus/plexus-archiver) which is used by Maven Assembly Plugin.

I created PoC which works with some minor notes:
1. Changes in [Plexus-archiver](https://github.com/codehaus-plexus/plexus-archiver) can be found in [feature/MASSEMBLY-668](https://github.com/codehaus-plexus/plexus-archiver/compare/master...mabrarov:feature/MASSEMBLY-668) branch of [mabrarov/plexus-archiver](https://github.com/mabrarov/plexus-archiver) GitHub repository
1. Tests for new code are missing
2. JavaDoc and comments for new code are missing
3. Only TAR implementation is extended and tested manually
2. Changes in Maven Assembly Plugin can be found in [feature/MASSEMBLY-668](https://github.com/apache/maven-assembly-plugin/compare/master...mabrarov:feature/MASSEMBLY-668) branch
1. Tests for new code are missing
2. Only TAR format, `fileSets` and `dependencySets` sections of Maven Assembly descriptor are tested manually
3. Existing tests are broken because of mocking and verification which need to be adopted - build works only with `-DskipTests`
4. JavaDoc and comments for new code are missing
3. Changes in test project utilizing this new feature can be found in [feature/root_owner_in_docker_image](https://github.com/mabrarov/dockerfile-test/compare/develop...feature/root_owner_in_docker_image) branch of [mabrarov/dockerfile-test](https://github.com/mabrarov/dockerfile-test) GitHub repository
1. I had to add each directory (where I need to specify owner and group) explicitly (even parent directories) because TAR format supports permissions, owner and group of directory only if TAR directory entries are added. This is true for permissions too (`directoryMode` option in Maven Assembly Plugin descriptor), so it's existing issue of Maven Assembly Plugin - when you need to store permissions for directories in TAR then you have to add directories explicitly to ensure that TAR directory entries are created - so I find this workaround acceptable, i.e I don't see a need to change smth in [Plexus-archiver](https://github.com/codehaus-plexus/plexus-archiver) or Maven Assembly Plugin to create TAR directory entries implicitly - one may not need these at all - i.e. if it's acceptable to create directories with default permissions then one may want to omit TAR directory entries and keep just TAR file entries and so optimize TAR.

---

**Affects:** 3.1.1

**Issue Links:**
- [MASSEMBLY-668](https://issues.apache.org/jira/browse/MASSEMBLY-668) Provide a way to optionally set owner and group of archive files as tar does
(_**"duplicates"**_)

**Remote Links:**
- [mabrarov/dockerfile-test test project
](https://github.com/mabrarov/dockerfile-test)
- [PoC for changes in Maven Assembly Plugin
](https://github.com/apache/maven-assembly-plugin/compare/master...mabrarov:feature/MASSEMBLY-668)
- [PoC for changes in Plexus-archiver, required for Maven Assembly Plugin PoC
](https://github.com/codehaus-plexus/plexus-archiver/compare/master...mabrarov:feature/MASSEMBLY-668)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing MASSEMBLY-668 and the referenced PoC branches for Maven Assembly Plugin and Plexus-archiver, focusing on TAR support and the fileSets and dependencySets descriptor sections. Run the existing tests, noting that mocking changes currently leave the build working only with -DskipTests. Done means configurable owner and group values for TAR entries, with tests and JavaDoc updated.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, java
Domain
build-system, devops
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.