Is there a way to add a pom type dependency to my POM and get all its modules?
JavaMail is a good example. Maven Central Repo has a parent POM called:
I believe you can create your own POM which aggregates the dependencies you want, and then in your original project add a dependency on that aggregate pom. You will still have to add dependencies on each individual module in your dependency POM, but it will be abstracted from the actual project POMs and allows those dependencies to be managed in one place, which could become useful if you end up having multiple projects that depend on that set of dependencies.
In your example you could create a new pom like this:
4.0.0
com.mycompany
mail-deps
1.0.0
pom
com.sun.mail
mail
1.5.0
com.sun.mail
mailapi
1.5.0
com.sun.mail
mailapijar
1.5.0
com.sun.mail
imap
1.5.0
com.sun.mail
gimap
1.5.0
com.sun.mail
pop3
1.5.0
com.sun.mail
dsn
1.5.0
Then in your original project just add:
...
src/main/java/com/mycompany
...
com.mycompany
mail-deps
1.0.0
pom