53

Starting from some assembly plugin version maven builds issue the following warning:

[WARNING] The assembly descriptor contains a filesystem-root relative reference,which is not cross platform compatible /

Is there any recommended ready-to-use solution for this? Direct googling provided me with lot of trash and no real help. Re-check of Maven assembly plugin help did not provide answer for me, maybe someone else has better search skill and can help.

UPDATE

Yes, this is probably because of Linux-like outputDirectory but how should I rewrite this to be portable? Looked at assembly plugin documentation and not found any portability guide.

<fileSets>
    <fileSet>
        <directory>${basedir}/src/main/resources</directory>
        <outputDirectory>/</outputDirectory>
    </fileSet>
</fileSets>
5
  • Can you show the assembly descriptor? It will probably show that somehow you reference an absolute path (/a/b/c), which is something to avoid to ensure build portability across environments
    – Tome
    Commented Feb 13, 2015 at 13:29
  • Yes this is the case if you are creating a tar file which can't contain a filesystem-root entry...which btw. does not really make sense.
    – khmarbaise
    Commented Feb 13, 2015 at 13:29
  • 1
    As you can see the outputDirectory defines a / which would in consequence mean to extract all contens to always same location. Apart from that this location is limited to the root account. Furthermore the questions is why you use fileSets to get the src/main/resources folder? Special reason for that?
    – khmarbaise
    Commented Feb 13, 2015 at 18:16
  • Yes, this is resulting .tar.gz assembly so "/" has nothing to root account and src/main/resources does not go into resulting artifact JAR but goes to .tar.gz package which includes needed additional things like scripts. I just have never tried to not provide anything through <outputDirectory/>. So @Torsten answer suits me 100%. Commented Feb 13, 2015 at 23:33
  • 1
    Had to scratch that itch a few days ago so I thought I might as well share it. Glad I could help.
    – Torsten
    Commented Feb 14, 2015 at 22:34

3 Answers 3

69

The working solution is to specify the empty outputDirectory:

<fileSets>
    <fileSet>
        <directory>${basedir}/src/main/resources</directory>
        <outputDirectory></outputDirectory>
    </fileSet>
</fileSets>
5
  • 2
    It is not always desirable to just leave it empty, what should be done if it needs to be set ? Commented Nov 19, 2015 at 6:16
  • 5
    If you like to specify a directory here then do so - this is why this parameter is here anyway. Just avoid absolute paths starting with "/".
    – Torsten
    Commented Nov 20, 2015 at 9:49
  • 2
    Or self-closing <outputDirectory/> Commented Apr 4, 2016 at 8:39
  • 2
    Another option: use . instead of /, i.e.: <outputDirectory>.</outputDirectory>.
    – otterrisk
    Commented Nov 6, 2018 at 11:03
  • @PrashantSharma See other answer using <outputDirectory>${file.separator}</outputDirectory>
    – Craigo
    Commented Jun 18, 2021 at 1:51
49

Using an empty outputDirectory element works, but I wouldn't be surprised if somebody assumed it could be safely deleted.

So, to be more explicit, you could also avoid the warning by writing:

<outputDirectory>${file.separator}</outputDirectory>
6
  • 1
    IMO this is the best approach as it works for any path not only / but also /foo/bar Commented May 13, 2016 at 10:04
  • 1
    Could you please elaborate how I would specify the file.separator property to work for both *nix platforms and windows platform?
    – vivekmore
    Commented Aug 28, 2017 at 17:31
  • 3
    @vivekmore the property is provided by maven and DOES work for both nix & windows
    – Barett
    Commented Mar 13, 2018 at 22:00
  • patforna, have you actually tried this "more explicit" part on a windows system? I don't think it actually gets rid of the warning... I think Maven is complaining about the setting starting with any slash at all. I could be wrong.
    – Barett
    Commented Mar 13, 2018 at 22:04
  • @Barett only tested this on *nix.
    – patforna
    Commented Mar 15, 2018 at 8:23
8

Note that this can happen at other locations besides just /. The above answers are correct, but don't cover this case.

Look for something like this in your assembly.xml:

<fileSets>
    <fileSet>
        <directory>${basedir}/src/main/resources</directory>
        <outputDirectory>/lib</outputDirectory>         <!-- <<< look for this -->
    </fileSet>
</fileSets>

and change to this:

<fileSets>
    <fileSet>
        <directory>${basedir}/src/main/resources</directory>
        <outputDirectory>lib</outputDirectory>
    </fileSet>
</fileSets>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.