Maven Assembly Plugin
  1. Maven Assembly Plugin
  2. MASSEMBLY-343

add symbolic links managment (java7+ only supported)

    Details

    • Type: Wish Wish
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.2-beta-2
    • Fix Version/s: 2.5
    • Component/s: None
    • Labels:
      None
    • Environment:
      linux, ubuntu
    • Patch Submitted:
      Yes
    • Number of attachments :
      3

      Description

      i need to buid archives ( tar for example ) with symbolic links

      the plugin build an archive with a file containing the destination of the link, not the link itself

      => the plugin need an option to know if deferencement of links is needed
      this is just like -h option of tar
      -h, --dereference
      don't dump symlinks; dump the files they point to

      actually, if you do an archive of /lib, for example, many file will be in double with diffÒ©rent names. extract of archive will not be the exactly the same as the source of the archive. => this is a test !

      1. MASSEMBLY-343_maven-assembly-plugin_fixed.patch
        38 kB
        Zuhayr Khan
      2. MASSEMBLY-343_maven-assembly-plugin.patch
        39 kB
        Zuhayr Khan
      3. symlink-test.tar.gz
        2 kB
        Hitanjan Sarkar

        Issue Links

          Activity

          Hide
          Zuhayr Khan added a comment - - edited

          I have implemented a solution for symbolic link support in maven-assembly-plugin with changes to plexus-io and plexus-archive (see my comments on PLXCOMP-117)

          I added definitions to the assembly format that allow for symlinks to be defined in an assembly.xml as follows...

          <symlinks>
          <symlink>
          <name>symlink_name</name>
          <destination>../symlink_destination</destination>
          </symlink>
          </symlinks>

          ...I think this is in-keeping with other resources, but I'm happy to hear others' views.

          I will attach a patch for consideration; I think/hope I have followed the coding standards - I am watching this and PLXCOMP-117 so please feel free to ask any questions through comments on whichever is appropriate.

          Show
          Zuhayr Khan added a comment - - edited I have implemented a solution for symbolic link support in maven-assembly-plugin with changes to plexus-io and plexus-archive (see my comments on PLXCOMP-117 ) I added definitions to the assembly format that allow for symlinks to be defined in an assembly.xml as follows... <symlinks> <symlink> <name>symlink_name</name> <destination>../symlink_destination</destination> </symlink> </symlinks> ...I think this is in-keeping with other resources, but I'm happy to hear others' views. I will attach a patch for consideration; I think/hope I have followed the coding standards - I am watching this and PLXCOMP-117 so please feel free to ask any questions through comments on whichever is appropriate.
          Hide
          Zuhayr Khan added a comment -

          This patch (MASSEMBLY-343_maven-assembly-plugin.patch) adds support for symlinks to maven-assembly-plugin

          Show
          Zuhayr Khan added a comment - This patch ( MASSEMBLY-343 _maven-assembly-plugin.patch) adds support for symlinks to maven-assembly-plugin
          Hide
          Ahmed El-Madhoun added a comment -

          Hi Zuhayr,

          I am running into a similar issue where I really need to support sym links as part of the assembly procedure. Do you know what version of the assembly plugin this patch is for? I would like to apply this patch and use it if possible.

          Thanks in advance.

          Show
          Ahmed El-Madhoun added a comment - Hi Zuhayr, I am running into a similar issue where I really need to support sym links as part of the assembly procedure. Do you know what version of the assembly plugin this patch is for? I would like to apply this patch and use it if possible. Thanks in advance.
          Hide
          Zuhayr Khan added a comment - - edited

          Hi Ahmed,

          The version I had locally which I patched was maven-assembly-plugin:2.2.1

          Hope that helps.

          BTW.. there's more comment and discussion on it's possible inclusion on the PLXCOMP-117 issue. I'm more than happy to adjust/re-work these solutions so it can form part of the actual released plugin if there's sufficient interest.

          Zuhayr

          Show
          Zuhayr Khan added a comment - - edited Hi Ahmed, The version I had locally which I patched was maven-assembly-plugin:2.2.1 Hope that helps. BTW.. there's more comment and discussion on it's possible inclusion on the PLXCOMP-117 issue. I'm more than happy to adjust/re-work these solutions so it can form part of the actual released plugin if there's sufficient interest. Zuhayr
          Hide
          Ahmed El-Madhoun added a comment -

          Hi Zuhayr,

          Thanks for the response. I am trying out this patch and I am just having little trouble applying the patches. From what you have told me, I am using the following maven plugin and plexus components:

          maven-assembly-plugin 2.2.1
          plexus-archiver 1.1
          plexus-io 1.0.1

          I do get some failures applying the patch, I did not look further into it, but I will later tonight. I just want to check that I am using the right versions.

          Thanks again and great work so far, any reason why this is not yet officially incorporated?

          Show
          Ahmed El-Madhoun added a comment - Hi Zuhayr, Thanks for the response. I am trying out this patch and I am just having little trouble applying the patches. From what you have told me, I am using the following maven plugin and plexus components: maven-assembly-plugin 2.2.1 plexus-archiver 1.1 plexus-io 1.0.1 I do get some failures applying the patch, I did not look further into it, but I will later tonight. I just want to check that I am using the right versions. Thanks again and great work so far, any reason why this is not yet officially incorporated?
          Hide
          Ahmed El-Madhoun added a comment -

          Hi Zuhayr,

          I was able to get the proper revisions of the maven plugins and plexus components (as listed above), however, I am having trouble building the assembly plugin. All code patches fine, except that I run into this issue:

          [INFO] -------------------------------------------------------------
          [ERROR] COMPILATION ERROR :
          [INFO] -------------------------------------------------------------
          [ERROR] /home/aelmadho/ASSEMBLY/maven/plugins/maven-assembly-plugin-2.2.1/target/generated-sources/modello/org/apache/maven/plugin/assembly/model/io/xpp3/AssemblyXpp3Writer.java:[291,119] error: unclosed string literal
          [ERROR] /home/aelmadho/ASSEMBLY/maven/plugins/maven-assembly-plugin-2.2.1/target/generated-sources/modello/org/apache/maven/plugin/assembly/model/io/xpp3/AssemblyXpp3Writer.java:[292,10] error: unclosed string lite

          The file in context (AssemblyXpp3Writer) looks like this at line 291-292:

          if ( ( dependencySet.getOutputFileNameMapping() != null ) && !dependencySet.getOutputFileNameMapping().equals( "$

          {artifact.artifactId}

          $

          {artifact.version}

          $

          {dashClassifier?}

          .$

          {artifact.extension}

          " ) )

          { serializer.startTag( NAMESPACE, "outputFileNameMapping" ).text( dependencySet.getOutputFileNameMapping() ).endTag( NAMESPACE, "outputFileNameMapping" ); }

          There seems to be a "\n" character at the end of the logical comparison that the parser fails. I am not very familiar with Xpp3, I need to do some more reading there, but I was hoping to try and generate maven artifacts including symlinks using the solution you have proposed.

          Any idea on how I can proceed?

          Thanks a bunch.

          Show
          Ahmed El-Madhoun added a comment - Hi Zuhayr, I was able to get the proper revisions of the maven plugins and plexus components (as listed above), however, I am having trouble building the assembly plugin. All code patches fine, except that I run into this issue: [INFO] ------------------------------------------------------------- [ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] /home/aelmadho/ASSEMBLY/maven/plugins/maven-assembly-plugin-2.2.1/target/generated-sources/modello/org/apache/maven/plugin/assembly/model/io/xpp3/AssemblyXpp3Writer.java: [291,119] error: unclosed string literal [ERROR] /home/aelmadho/ASSEMBLY/maven/plugins/maven-assembly-plugin-2.2.1/target/generated-sources/modello/org/apache/maven/plugin/assembly/model/io/xpp3/AssemblyXpp3Writer.java: [292,10] error: unclosed string lite The file in context (AssemblyXpp3Writer) looks like this at line 291-292: if ( ( dependencySet.getOutputFileNameMapping() != null ) && !dependencySet.getOutputFileNameMapping().equals( "$ {artifact.artifactId} $ {artifact.version} $ {dashClassifier?} .$ {artifact.extension} " ) ) { serializer.startTag( NAMESPACE, "outputFileNameMapping" ).text( dependencySet.getOutputFileNameMapping() ).endTag( NAMESPACE, "outputFileNameMapping" ); } There seems to be a "\n" character at the end of the logical comparison that the parser fails. I am not very familiar with Xpp3, I need to do some more reading there, but I was hoping to try and generate maven artifacts including symlinks using the solution you have proposed. Any idea on how I can proceed? Thanks a bunch.
          Hide
          Zuhayr Khan added a comment -

          Thanks Ahmed - seems a rogue line-ending caused the issue you noted.

          I now attached a fixed version of the patch. Hopefully this should solve your problem.

          Zuhayr

          Show
          Zuhayr Khan added a comment - Thanks Ahmed - seems a rogue line-ending caused the issue you noted. I now attached a fixed version of the patch. Hopefully this should solve your problem. Zuhayr
          Hide
          Ahmed El-Madhoun added a comment -

          Hi Zuhayr,

          Thanks for the fix, I am now able to build and test the patch. I am not seeing the symlinks respected. I am simply using assembly to archive an artifact that contains a number of symlinks, but they are all hard links.

          Do I need to specify any configuration in the descriptor to ensure that symlinks are kept?

          Show
          Ahmed El-Madhoun added a comment - Hi Zuhayr, Thanks for the fix, I am now able to build and test the patch. I am not seeing the symlinks respected. I am simply using assembly to archive an artifact that contains a number of symlinks, but they are all hard links. Do I need to specify any configuration in the descriptor to ensure that symlinks are kept?
          Hide
          Ahmed El-Madhoun added a comment -

          By the way, I am using Maven 3, but I don't think that is an issue, would it be?

          Show
          Ahmed El-Madhoun added a comment - By the way, I am using Maven 3, but I don't think that is an issue, would it be?
          Hide
          Zuhayr Khan added a comment -

          It sounds like you're hoping that the assembly plugin will look at symlinks on your file-system and include them within the assembled package?

          This use case is what the discussion on PLXCOMP-117 covers. In summary, because of the lack of system-agnostic support for symbolic links (pre Java 7?) plexus-io doesn't read/identify symlinks in this manner.

          The patch here simply allows you to configure symlinks within the assembly-definition such that they are recorded in the tar/zip file as symlinks.

          If I've understood your use case correctly, to take advantage of this, you'd need to add a "symlinks" element (see my initial comment on this) to your assembly-definition that correspond to the actual symlinks on your file system.

          Hope that helps.

          Show
          Zuhayr Khan added a comment - It sounds like you're hoping that the assembly plugin will look at symlinks on your file-system and include them within the assembled package? This use case is what the discussion on PLXCOMP-117 covers. In summary, because of the lack of system-agnostic support for symbolic links (pre Java 7?) plexus-io doesn't read/identify symlinks in this manner. The patch here simply allows you to configure symlinks within the assembly-definition such that they are recorded in the tar/zip file as symlinks. If I've understood your use case correctly, to take advantage of this, you'd need to add a "symlinks" element (see my initial comment on this) to your assembly-definition that correspond to the actual symlinks on your file system. Hope that helps.
          Hide
          Ahmed El-Madhoun added a comment -

          I kind of figured that out once I looked more into the patch and this case. I am thinking of porting assembly plugin into JDK7 with ability to automatically package symlinks, would you be interested in helping out?

          Show
          Ahmed El-Madhoun added a comment - I kind of figured that out once I looked more into the patch and this case. I am thinking of porting assembly plugin into JDK7 with ability to automatically package symlinks, would you be interested in helping out?
          Hide
          Kristian Rosenvold added a comment -

          Symbolic links will work when archiver 2.6.1 is installed, but only for jdk 7 and above.

          Show
          Kristian Rosenvold added a comment - Symbolic links will work when archiver 2.6.1 is installed, but only for jdk 7 and above.
          Hide
          Kristian Rosenvold added a comment -

          Fixed with plexus-archiver upgrade. This will not be supported for < java7

          Show
          Kristian Rosenvold added a comment - Fixed with plexus-archiver upgrade. This will not be supported for < java7
          Hide
          Daniel Seidewitz added a comment -

          Is the patch really included in release 2.5? Because I just tried to create an assembly with <symlinks/> in the descriptor and it doesn't recognize the element. Also I looked at the source for 2.5 and it seems the patch was not included.

          Show
          Daniel Seidewitz added a comment - Is the patch really included in release 2.5? Because I just tried to create an assembly with <symlinks/> in the descriptor and it doesn't recognize the element. Also I looked at the source for 2.5 and it seems the patch was not included.
          Hide
          Kristian Rosenvold added a comment -

          No, this patch was not included. But symlinks existing on the file system will be added to the archive as one would expect as parts of filesets or similar.

          Show
          Kristian Rosenvold added a comment - No, this patch was not included. But symlinks existing on the file system will be added to the archive as one would expect as parts of filesets or similar.
          Hide
          Kristian Rosenvold added a comment -

          I suppose it might be viable to add a "symlinkTarget" attribute to the "file" element to make a symlink in the descriptor

          Show
          Kristian Rosenvold added a comment - I suppose it might be viable to add a "symlinkTarget" attribute to the "file" element to make a symlink in the descriptor
          Hide
          Kristian Rosenvold added a comment -

          I've been thinking a little more about this, and there is definitely room for some way to create a symlink in the descriptor. I'll see if your patch is still fresh and try to find out what you've been thinking.

          Show
          Kristian Rosenvold added a comment - I've been thinking a little more about this, and there is definitely room for some way to create a symlink in the descriptor. I'll see if your patch is still fresh and try to find out what you've been thinking.
          Hide
          Hitanjan Sarkar added a comment -

          Hi Kristian,

          The symbolic links do not get resolved with plugin v2.5 thanks for including the fix, but I see the link converted into an empty directory instead. Am I missing something here ?

          Show
          Hitanjan Sarkar added a comment - Hi Kristian, The symbolic links do not get resolved with plugin v2.5 thanks for including the fix, but I see the link converted into an empty directory instead. Am I missing something here ?
          Hide
          Kristian Rosenvold added a comment -

          What platform are you running on ? Can you produce a small test project ?

          Show
          Kristian Rosenvold added a comment - What platform are you running on ? Can you produce a small test project ?
          Hide
          Hitanjan Sarkar added a comment -

          Symlink test project.
          Contains a symlink generator (symlinks generated using ant-runer and bundled using assembly plugin) and a symlink consumer that unwraps the dependency using (dependency plugin).

          My objective is to pack a symlink (using assembly) and unpack it (using dependency-unpack) and see if links remain intact.

          With assembly-plugin v2.4, the links get resolved into a regular folder structure (dereferenced basically) at the end of the assembly.
          With v2.5, atleast the assembly-generated artifact should bundle symlinks. But instead the symlinks appear as empty directories.

          Show
          Hitanjan Sarkar added a comment - Symlink test project. Contains a symlink generator (symlinks generated using ant-runer and bundled using assembly plugin) and a symlink consumer that unwraps the dependency using (dependency plugin). My objective is to pack a symlink (using assembly) and unpack it (using dependency-unpack) and see if links remain intact. With assembly-plugin v2.4, the links get resolved into a regular folder structure (dereferenced basically) at the end of the assembly. With v2.5, atleast the assembly-generated artifact should bundle symlinks. But instead the symlinks appear as empty directories.
          Hide
          Hitanjan Sarkar added a comment -

          I 've tested this on OS X Yosemite, Ubuntu Desktop 14.04, and Suse Linux Enterprise Server.
          All versions of Java have been 7+ and Oracle JDK ( I hope any JDK>=7 should have worked).
          Java version "1.7.0_71"

          I have attached a 'symlink-test' project.

          Show
          Hitanjan Sarkar added a comment - I 've tested this on OS X Yosemite, Ubuntu Desktop 14.04, and Suse Linux Enterprise Server. All versions of Java have been 7+ and Oracle JDK ( I hope any JDK>=7 should have worked). Java version "1.7.0_71" I have attached a 'symlink-test' project.
          Hide
          Kristian Rosenvold added a comment -

          @Hitanjan Sarkar Would you min dcreating a separat issue for this ? 2.5.2 is not too far off and I'll definitely take a look at this !

          Show
          Kristian Rosenvold added a comment - @Hitanjan Sarkar Would you min dcreating a separat issue for this ? 2.5.2 is not too far off and I'll definitely take a look at this !
          Hide
          Hitanjan Sarkar added a comment -

          Sure Kristian, will do.
          Thanks !!!

          Any idea of the tentative date when 2.5.2 might be released ?

          Also, there is a corresponding outstanding issue on the dependency plugin, tracked here - http://jira.codehaus.org/browse/MDEP-68
          Would you be the right person to ask about this too ?
          From whatever little I seem to have gathered on this, since the plexus-io and plexus-archiver plugins have this fix in, the dependency plugin would probably need to be re-released with the updated plexus dependencies or something similar ?

          Show
          Hitanjan Sarkar added a comment - Sure Kristian, will do. Thanks !!! Any idea of the tentative date when 2.5.2 might be released ? Also, there is a corresponding outstanding issue on the dependency plugin, tracked here - http://jira.codehaus.org/browse/MDEP-68 Would you be the right person to ask about this too ? From whatever little I seem to have gathered on this, since the plexus-io and plexus-archiver plugins have this fix in, the dependency plugin would probably need to be re-released with the updated plexus dependencies or something similar ?
          Hide
          Hitanjan Sarkar added a comment -
          Show
          Hitanjan Sarkar added a comment - Created the issue here - https://jira.codehaus.org/browse/MASSEMBLY-731

            People

            • Assignee:
              Kristian Rosenvold
              Reporter:
              Godet Gilles
            • Votes:
              9 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: