Code Modules

Code Modules with Maven 2

Each code module will produce a single artifact (war, ear, jar). Ideally artifacts that have an API and corresponding implementation can be separated into two separate artifacts: one code module will produce a jar with the API, the other code module produces the implementation.Artifacts will have a group identifier, artifact identifier, version, and packaging format. Generally the group identifier and version are fixed by the parent pom.

Modules reside in subdirectories of the base project. The module subdirectory does not need to be named the same as the artifact identifier, but by convention they are the same.

In the base pom.xml, modules are defined like so:

<project>
  ...
  <modules>
    <module>context-common-api</module>
    <module>portal-caching-api</module>
    ... 
  </modules>
  ...
</project>

By listing a module in the <modules> element, the Maven 2 lifecycle will be activated for that module when running maven 2 commands from the base directory. For example, running mvn compile from the base directory will compile the source code in any module with package type of jar.

Goals of modularization

  1. Define explicit dependencies between distinct "chunks" of code, especially framework code.
  2. Separate API from Implementation
    • Allow for vendors, etc to plug in their own implementations of an API
    • Well defined API's with loose coupling promotes easier-to-maintain code

So when considering the question what constitutes a module, I consider:

  1. What is the responsibility of the code in question? Code with distinct responsibility should be given its own module (imo).
    • If you can't tell what the responsibility of the code is, or mostly everything fits but for this one class, consider refactoring.
  2. Is it an API, or an implementation
  3. Will a vendor ever want to replace the impl with their own?

Module List for Maven 2 Trunk

Often times code modules can be derived from the Java package hierarchy. What I did to arrive at this list was look at the existing uPortal 3 package structure and started by creating a code module for each major package (note that the 'code moduel per package' rule is not a documented M2 convention, I just made it up).

This is a list of modules that I came up with, sometimes following the 'code module per package' rule and sometimes not. These modules can be seen in the Maven 2 Branch (note that this branch was a first-run exercise at mavenizing uP3. While it won't ever get promoted to trunk it still has some value as a sandbox).

Pre Pluto 1.1.x integration

Note that this work on the Maven 2 branch took place prior to the work Eric did on replacing Pluto 1.0.x with Pluto 1.1.x. Since the Pluto 1.0.x OM was very invasive, I imagine that with Pluto 1.1 some of these modules will be able to have a much cleaner dependency graph.

Module sub-directory

Artifact Identifier

Working Dependency Graph

Packaging Format

Notes

context-common-api

context-commmon-api

(tick)

jar

I had trouble divvying up the context code modules, but I think each deserves its own.

context-common-impl

context-common-impl

(tick)

jar

Common context implementation.

pluto-stubs

pluto-stubs

(tick)

jar

Stubs of Pluto 1.0.x interfaces

portal-caching-api

portal-caching-api

(tick)

jar

 

portal-caching-impl

portal-caching-impl

(tick)

jar

Caching API implementation.

portal-core-api

portal-core-api

(tick)

jar

I moved some servlets out of the core module to the web module.

portal-core-api

portal-core-impl

(tick)

jar

 

portal-context-api

portal-context-api

(tick)

jar

 

portal-context-impl

portal-context-impl

(tick)

jar

 

portal-context-dummy

portal-context-dummy

(error)

jar

 

portal-context-uportal2

portal-context-uportal2

(error)

jar

 

portal-rendering-api

portal-rendering-api

(tick)

jar

 

portal-rendering-impl

portal-rendering-impl

(error)

jar

 

portal-servlet

portal-servlet

(error)

jar

Not sure what is up with this one, need to revisit

portal-url-api

portal-url-api

(tick)

jar

Because url munging is now a first class citizen in uP3, I think this deserves its own module

portal-url-impl

portal-url-impl

(tick)

jar

 

problem-manager-api

problem-manager-api

(tick)

jar

 

problem-manager-impl

problem-manager-impl

(tick)

jar

 

security-api

security-api

(tick)

jar

 

security-impl

security-impl

(tick)

jar