Ickbinet
Ickbinet

Reputation: 277

Java Webapp modules

I have a core webapp and want to extended it by several optional modules (jar files). These modules can contain Servlets, Filters etc.

Development:

Since the modules are optional I think that using maven modules with a parent is not the way to go, because the parent always contains all modules and I do not want to have a parent per deployment scenario.

So a normal maven project per optional webapp module... But how do I manage that the core and the module always use the same dependencies? Do I have to create a parent pom for both which contains all the dependencies and other shared settings (Java version etc)?

Deployment:

What is the recommendation here? Always repackage the war? Copy the module jar into the exploded WEB-INF/lib? Could it deployed at runtime too?

Upvotes: 2

Views: 463

Answers (1)

Jan Larsen
Jan Larsen

Reputation: 871

It sounds like you are looking to configure and build all the possible configurations seperately instead of using or making some truly dynamic module loading system.

In that case the simplest way is to have a war-project per configuration:

You should have a module pom-project that does nothing but build all other projects. This could be the parent project, but I would use a seperate project. EDIT: I would place this project in the root of your repository and place all other projects in sub-folders. That goes well with IDEs and release tools.

You should have a parent pom-project that does Maven <dependencyManagement> for managing all dependency versions in all projects and has any general build configuration that all other projects need. All other projects except the module project has this as parent.

You will probably need a common jar-project for common code used in many modules.

You should have a jar-project for your core application.

You should have a jar-project for each module.

For each configuration you need a war-project that is nothing but a pom-file declaring the needed dependencies and mayby some property files. They will build your products.

If you want to have special configuration for the war-projects (deployment, test etc.) you can make an intermediary parent for them. It should have the general parent as parent.

Now you can build everything with the module project and end up with a war-file for each configuration.

Upvotes: 2

Related Questions