How to copy .gitignore file to the archetype JAR?

406 Views Asked by At

I'm trying to include the .gitignore file to the jar. I tried everything but it still not copying the .gitignore file. Here is my resources and jar plugins

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.0.2</version>
          <configuration>
            <addDefaultExcludes>false</addDefaultExcludes>
          </configuration>
        </plugin>
        <plugin>
          <artifactId>maven-jar-plugin</artifactId>
          <version>2.4</version>
          <configuration>
            <includes>.gitignore</includes>
          </configuration>
        </plugin>


I even tried maven-resources-plugin with 3.1.0, but it's not adding? How to achieve it?

1

There are 1 best solutions below

0
Sjoerd Hemminga On

Archetype jars are created by the archetype plugin. So you have to configure that by setting the useDefaultExcludes to false:

        <plugin>
          <artifactId>maven-archetype-plugin</artifactId>
          <configuration>
            <useDefaultExcludes>false</useDefaultExcludes>
          </configuration>
        </plugin>

Note that the configuration key is called useDefaultExcludes as opposed to addDefaultExcludes for resources plugin.

I don't know why people are saying it doesn't make sense to add .gitignore to an archetype jar. I find it very useful to make sure target/ and the like are automatically ignored.