A project I was working on recently had some… interesting packages in the source code. There was a test package, a config package, and a notes package. By placing these non-source items in the source folder, they were being included in the final jar that maven would build.
The ideal solution here is to move these packages to more appropriate places, such as a test source folder, a relative config folder in the application’s root, and maybe a private wiki for the team, respectively.
However, not even having enough time to do the work I was assigned, I decided I would at least prevent these items from cluttering up the jar, and I would return to move them properly at a later time.
You’ll want to use the maven-jar-plugin, and configure excludes as absolute package paths:
<plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.3.1</version> <configuration> <excludes> <exclude>test/</exclude> <exclude>config/</exclude> <exclude>example/package/path/notes</exclude> </excludes> </configuration> </plugin> </plugins>