Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Relative directories don't seem to work with filesets in maven assembly descriptors. Any way to do this?

According to the maven assembly plugin docs, relative directories are allowed, but ".." doesn't seem to work at all.

For reasons I cannot go into (and I cannot change), there are some files outside of the maven project directory I want to include in the assembly.

/-
---maven-project/
---some-crap/

I have tried various things:

<fileSets>
    <fileSet>
        <directory>${project.basedir}/../some-crap</directory>
        <outputDirectory>crapdir</outputDirectory>
        <includes>
            <include>**/*</include>
        </includes>
    </fileSet>
</fileset>

or

<fileSets>
    <fileSet>
        <directory>${project.basedir}</directory>
        <outputDirectory>crapdir</outputDirectory>
        <includes>
            <include>../some-crap/**/*</include>
        </includes>
    </fileSet>
</fileset>

or

<fileSets>
    <fileSet>
        <directory>../some-crap</directory>
        <outputDirectory>crapdir</outputDirectory>
        <includes>
            <include>**/*</include>
        </includes>
    </fileSet>
</fileset>

etc. My maven version is 3.0.4 (latest)

Outside of writing something in ant to fetch this stuff or copying it to my target dir before assembling, is there anything I can do?

I really think the assembly plugin is treating ".." as a directory name and not "go up one level".

Thanks.

like image 530
marathon Avatar asked Nov 04 '22 05:11

marathon


1 Answers

How about using maven-antrun-plugin to copy files to your project dir before assembling?

       <plugin>
           <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-antrun-plugin</artifactId>
           <executions>
               <execution>
                   <id>prepare-deploy-package</id>
                   <phase>prepare-package</phase>
                   <goals>
                       <goal>run</goal>
                   </goals>
                   <configuration>
                       <tasks>
                           <copy todir="${project.build.directory}">
                               <fileset dir="../xxxx">
                               </fileset>
                           </copy>
                       </tasks>
                   </configuration>
               </execution>
           </executions>
       </plugin>
like image 146
Jintian DENG Avatar answered Nov 09 '22 15:11

Jintian DENG