.gitignore file is not copied to archetype JAR - Workarounds?
The bug is now fixed in the maven-resources-plugin.
To include the .gitignore file, the maven-resources-plugin plugin should be set explicitly in the archetype pom.xml
file with the configuration value addDefaultExcludes
set to false
:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<addDefaultExcludes>false</addDefaultExcludes>
</configuration>
</plugin>
As @amanteaux says, adding addDefaultExcludes
with false
ensures that the maven-resources-plugin copies the .gitignore
file to target/classes
, however, maven-jar-plugin (> 2.4) won't copy .gitignore
to the resulting jar. See this stackoverflow comment for more information. So one workaround would be, in addition to the flag above for maven-resources-plugin, rollback maven-jar-plugin to 2.4.