0

Maven best practices seem like they support one project > one jar > one pom.xml.

I have a maven project that can compile and run as a command line program OR as a GUI. Is it bad to have one project with one POM file that creates 2 jars in this case (one for each run type)? Or is there a better way to do it?

Also, I have automated tests in my test package that compile and run as jar files. Is it a bad practice to keep those in the maven test structure and use the same pom file to compile them? Or is it better to put them in a different project?

JustBlossom
  • 1,259
  • 3
  • 24
  • 53

1 Answers1

4

Not in different projects, but in multiple maven modules within the same project.

Consider a maven module structure such as:

root
   core
   cli-api
   gui-api

where:

  • the core module contains all the actual business logic, and builds a typical jar
  • the cli-api module depends on core, and includes the code to run from the command line
  • the gui-api module depends on core and includes the code to run from a gui

The test classes should be within the related module.

Andrew S
  • 2,509
  • 1
  • 12
  • 14
  • Thanks! I've never used modules before, but they were pretty straightforward. They worked beautifully; the project structure makes a lot of sense this way. – JustBlossom Aug 21 '19 at 23:12