Maven – Exclude Resources From Jar

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:


Leave a Reply

Your email address will not be published. Required fields are marked *