I am trying to exclude some java files from src/main/java and also some yml files from src/main/resources folder while building the jar using spring boot maven plugin. I have tried the following options:
Option 1 in maven-jar-plugin
<configuration>
<excludes>
<exclude>**/security/**/*.java</exclude>
<exclude>**/application-*.yml</exclude>
</excludes>
</configuration>
Option 2 resources in build tag:
<resources>
<resource>
<directory>src/main</directory>
<excludes>
<exclude>**/security/*</exclude>
<exclude>**/application-*.yml</exclude>
</excludes>
<filtering>false</filtering>
</resource>
</resources>
Option 1 and both are removing the java files from the generated jar.
But option 2 changes structure in JAR it includes java and resource folder.
Any pointer for the above is greatly appreciated.
I found solution, as following; it is using the maven jar plugin exclusions. There were issues in maven wildcard which was provided earlier.
Edit: Not the right approach to include java files which are removed while buliding artifact as suggested by JF Meier and khmarbaise. But solution is still valid for files exclusion.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<excludes>
<exclude>**/security/**</exclude>
<exclude>**/application-*.yml</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>repackage</id>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>