Uploaded image for project: 'Maven Assembly Plugin'
  1. Maven Assembly Plugin
  2. MASSEMBLY-918

Owner and group of files and directories

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 3.1.1
    • None
    • component descriptor
    • None

    Description

      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 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 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 for details.

      When I build on Windows - refer to 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):

      $ 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 which is used by Maven Assembly Plugin.

      I created PoC which works with some minor notes:

      1. Changes in Plexus-archiver can be found in feature/MASSEMBLY-668 branch of 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 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 branch of 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 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.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              abrarovm Marat Abrarov
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: