0

I have the following directory structure:

MyProject/
   - temp/
     - cat_A/
         - tmp/
         - file_A
     - cat_B/
         - tmp/
         - file_B

I am using maven-assembly-plugin. I want to create a tar.gz file with the content to be like following:

output/
  - cat_A/
    - file_A
  - cat_B/
    - file_B

I tried to make a custom descriptor as following:

<assembly …>
   <id>my-result</id>
  <formats>
    <format>tar.gz</format>
  </formats>
  <fileSets>
    <fileSet>
      <directory>${project.baseDir}/temp</directory>
      <outputDirectory>output</outputDirectory>

      <!-- tried to exclude tmp/ folder-->

        <excludes>
            <exclude>${project.baseDir}/temp/cat_A/tmp</exclude>
            <exclude>${project.baseDir}/temp/cat_B/tmp</exclude>
        </excludes>

    </fileSet>
  </fileSets>
</assembly>

But the final output still contains the tmp/ folder.

How to exclude the tmp/ folder and achieve the result I want?

user842225
  • 5,445
  • 15
  • 69
  • 119
  • Ah...excludes as the [docs](http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html#class_fileSet) describes? – khmarbaise Feb 25 '15 at 13:34
  • Ah...in fileSets there is not ``...just remote it. Take a look into the docs. – khmarbaise Feb 25 '15 at 14:02
  • @khmarbaise, please check my update again. I tried with exclude, but the tmp/ folders are still included in the final output. – user842225 Feb 25 '15 at 14:12

1 Answers1

0

Because it's a directory you have to change your exclusion to:

    <excludes>
        <exclude>/cat_A/tmp/**</exclude>
        <exclude>/cat_B/tmp/**</exclude>
    </excludes>

Update: Without ${project.baseDir}/temp because it's relative to your directory

This and that provide further information.

Community
  • 1
  • 1
Jan
  • 1,004
  • 6
  • 23
  • lol. Sry seems I am having a bad day. Corrected my answer. You're absolutely right... – Jan Feb 25 '15 at 15:39
  • Thanks, but now the output is empty. I need to check for a while – user842225 Feb 25 '15 at 15:47
  • It seems it excludes the cat_A/tmp/** including the parent directory. That's why I got empty output – user842225 Feb 25 '15 at 15:53
  • Hmm maybe another minor failure: try `cat_A/tmp/**` without `/` at the beginning – Jan Feb 25 '15 at 15:56
  • tried, still, empty output :( , also tried `cat_A/tmp` – user842225 Feb 25 '15 at 15:58
  • I think the last version without `/` at the beginning is right and something is wrong with `${project.baseDir}/temp`. Maybe because it can't resolve the variable?! It's just a feeling because I played a bit around with the directory and got different outputs on the console but somehow it doesn't build my zip... – Jan Feb 25 '15 at 16:33