简体   繁体   中英

maven assembly plugin excludes .gitignore

Maven assembly plugin exludes .gitignore files in the final zip package. How do I include .gitignore in the final output zip? I tried include **/*, but didn't work.

My assembly file:

<id>assembly</id>
<includeBaseDirectory>false</includeBaseDirectory>
<formats>
    <format>zip</format>
</formats>
<fileSets>
    <fileSet>
        <directory>${project.build.directory}/work</directory>
        <outputDirectory>/</outputDirectory>
        <excludes>
            <exclude>How*.html</exclude>
        </excludes>
    </fileSet>
</fileSets>`

Assembly plugin:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.5.5</version>
    <configuration>
        <descriptors>
            <descriptor>assembly/config.xml</descriptor>
        </descriptors>
    </configuration>
    <executions>
        <execution>
            <id>build-archive</id>
            <phase>package</phase>
            <goals>
                <goal>single</goal>
            </goals>
        </execution>
    </executions>
</plugin>

After some research, I found that .gitignore and other source repository control files (.svn) are excluded in the final package. Maven does this by default. I had to explicitly set the flag - false to include .gitignore files.

As per maven documentation - useDefaultExcludes -

Whether standard exclusion patterns, such as those matching CVS and Subversion metadata files, should be used when calculating the files affected by this set. For backward compatibility, the default value is true

.

Three suggestions:

1- Try files element beside fileSet in your assembly file. It specifies which single files to include in the assembly. A file is specified by providing one or more of file subelements.

2- Set baseDirectory properly. for example

<baseDirectory>../</baseDirectory>

3- Or, set includeBaseDirectory to true

<includeBaseDirectory>true</includeBaseDirectory>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM