Is it possible to exclude a package from the generated jar file?
You can configure maven-compiler-plugin to exclude your unwanted packages or files to be compiled in the first place. But you will not be able to prevent javac to compile those files if they are referenced by other packages within the source tree. To prevent that, you will need to use antrun plugin ( or write your own custom plugin), bind it to compile phase, and remove unwanted classes in ${project.build.directory}/classes. If possible, just move those pacakges/files to another source tree to become another project.