Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude file directory, by assembly plugin MAVEN

I would be pleasant, if you could help me to figure out this problem.

When I build my project to .zip with maven <assembly> plugin.

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">

<id>dev</id>
<formats>
    <format>zip</format>
</formats>

<fileSets>

    <fileSet>
        <directory>${basedir}</directory>
        <includes>
            <include>/environments/dev/**/*.sh</include>
            <include>/environments/dev/**/*.jil</include>
            <include>/environments/dev/**/*.properties</include>
            <include>/environments/dev/**/log4j2.xml</include>  
        </includes>  
    </fileSet>

</fileSets>

<dependencySets>
    <dependencySet>
        <outputDirectory>/lib</outputDirectory>
        <useProjectArtifact>true</useProjectArtifact>
        <scope>runtime</scope>
    </dependencySet>
</dependencySets>

I receive the following file structure:

build.zip----> environments__
                            |_DEV_
                                  |_bin
                                  |_properties
                                  |_....

My goal is:

To get the following file structure after maven build:

 build.zip----> 
                                  |_bin
                                  |_properties
                                  |_....

Without environments and DEV folders.

I've read in the maven documentation (http://maven.apache.org/plugins/maven-assembly-plugin/advanced-descriptor-topics.html) that we can exclude some file directories. This way:

<assembly> 
    ....

    <fileSets> 
        <fileSet>
            <directory>${basedir}</directory>
            <includes>
              ....
            </includes>
            <excludes>
                <exclude>/environments/dev</exclude>
            </excludes>
        </fileSet> 
    </fileSets>

    <dependencySets>
        <dependencySet>
            <outputDirectory>/lib</outputDirectory>
            <useProjectArtifact>true</useProjectArtifact>
            <scope>runtime</scope>
        </dependencySet>
    </dependencySets>
</assembly>

But it doesn't help. I still have previous file structure.

like image 791
Sergii Lisnychyi Avatar asked Oct 18 '13 13:10

Sergii Lisnychyi


1 Answers

You want to set the root of your directory to /environments/dev

<fileSet>
    <directory>${basedir}/environments/dev</directory>
    <outputDirectory>/</outputDirectory>
    <filtered>false</filtered>
</fileSet>
like image 92
Pignic Avatar answered Sep 28 '22 12:09

Pignic