Understanding Maven source exclusion
$ cd && mkdir maven-experiment-clone && cd maven-experiment-clone && \
git clone https://github.com/keghani/maven-experiment.git && cd maven-experiment
...
<configuration>
<directory>com/keghani/hello</directory>
</configuration>
...
$ mvn package
$ jar tf target/maven-experiment-1.0.0.jar
Check that you see Hello.class
and Exclude.class
.
$ java -cp target/maven-experiment-1.0.0.jar com.keghani.hello.Hello
Get "Hello".
$ java -cp target/maven-experiment-1.0.0.jar com.keghani.hello.Exclude
Get "Hello" again.
...
<configuration>
<directory>com/keghani/hello</directory>
<excludes>
<exclude>com/keghani/hello/Exclude.java</exclude>
</excludes>
</configuration>
...
$ mvn clean
$ ls
Check that the target
directory is no longer present.
$ mvn package
$ jar tf target/maven-experiment-1.0.0.jar
Check that you see Hello.class
but not Exclude.class
.
$ java -cp target/maven-experiment-1.0.0.jar com.keghani.hello.Hello
Get "Hello".
Thanks to @jias0001 for the references!