Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.gitignore file is not copied to archetype JAR - Workarounds?

Tags:

Currently in the maven-resources-plugin there is a bug that the .gitignore file is not copied to the archetype JAR. See this bug report

Short and simple question: are there workarounds for getting the file in the archetype?

Edit: setting the maven-resources-plugin version to 2.6 doesn't solve my problem (like mentioned here)

<build>     <pluginManagement>         <plugins>             <plugin>                 <artifactId>maven-resources-plugin</artifactId>                 <version>2.6</version>             </plugin>         </plugins>     </pluginManagement> </build> 
like image 481
Charmin Avatar asked Sep 15 '15 07:09

Charmin


2 Answers

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> 
like image 173
amanteaux Avatar answered Sep 19 '22 14:09

amanteaux


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.

like image 43
sdoxsee Avatar answered Sep 18 '22 14:09

sdoxsee