I'll explain two solutions for you.
You could consider making a multi-module maven project, with a structure like this:
my_project
pom.xml
module_A
pom.xml
src
main
java
a
A.java
module_B
pom.xml
src
main
java
b
B.java
And your "parent pom" (the one at the project root level) will contain this:
<modules>
<module>module_A</module>
<module>module_B</module>
</modules>
Then you can just run mvn clean install
from the project root and look in module_A/target
and module_B/target
to find your jars which have been built.
The other solution involves using exclusions and the maven-jar-plugin (or another plugin that does the same job). Here's maven-jar-plugin example configuration, for a question similar to your own.
Hope this helps...