How do I organize a project with a shared library in Maven

Viewed 3193

I am wondering if this the correct way to structure my project and how I can configure it so that I can build/test/package all of its individual components from a single build command?

I have a Maven project that contains multiple modules- Spring apps and a "library" shared between them as a dependency. I would like to be able to build all the apps together with the library so that I can execute integration tests whenever any of the modules change (lib or app).

Ideally, I should be able to compile each component, run unit tests per app/library, run integration tests, package each component into its executable jar. At some point, this process will be run on a Jenkins server with higher-level system tests.

Right now, I am using mvn clean install spring-boot:repackage. This works for each app individually,i.e. when running from Main Project/App1/. However, when I run it from the project root Main Project/, I am getting an error that the library cannot be spring-repackage'd because the library does not have a main class. This is fine- it's a library, it does not need an entry point.

So is this the correct way to structure a multi-app project in Maven or am I doing something very wrong?

The project structure is:

Main Project
|-SharedLibrary/
  |-src/
  |-pom.xml
|-App1/
  |-src/
  |-pom.xml
|-App2/
  |-src/
  |-pom.xml
|-App3/
  |-src/
  |-pom.xml
|-pom.xml
1 Answers
Related