- Create new java maven project in IDEA.
- create new file resource/test.txt
- add new JAR artifact, check “include in project build”
- to exclude resource/test.txt from .jar file, add to pom.xml :
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>*</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>default-jar</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<excludes>
<exclude>*</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
5. rebuild project
6. I get untitled1.jar with “test.txt” file inside
So, I want to exclude test.txt file from resulting .jar file, how I have to do it?