views:

148

answers:

1

I have a multi-module project where there are various components which follow a fairly standard layout. For example:

      root (pom)
          ...
          module-NN (pom)
             module-NN-launcher (jar)
             module-NN-runtime (jar)
          ...

(where there are many module-NN projects)

Each *-launcher project uses a proprietary API to launch a framework providing a generic API. The *-runtime projects are then loaded into this framework to "do stuff".

As things currently stand, I have dependencies for the launcher defined in each *-launcher/pom.xml. Likewise, I have the generic APIs references in the *-runtime/pom.xml. I could update the project structure to be something like:

    root (pom)
        launcher (pom)
            ...
            module-NN-launcher (jar)
            ...
        runtime (pom)
            ...
            module-NN-runtime (jar)
            ...
        applications (pom)
            ...
            module-NN (pom)
            ...

And put the relevant dependencies in the launcher/runtime pom.xml files, but this makes the layout of the projects much less intuitive.

Has anyone faced this sort of problem before? What advice can you provide in producing a meaningful layout without duplicating details across similar projects?

A: 

I've done something about 90% similar.

Consider creating a project called "runtime-common". In that pom.xml, add all the runtime dependencies that are common to runtimes.

In the pom.xml for module-NN-runtime, add this

  <parent>
      <groupId>FOO</groupId>
      <artifactId>runtime-common</artifactId>
      <version>1.0.0</version>
  </parent>

Anything you add to runtime-common will be added to the child projects for runtime-common. This doesn't effect the root project's ability to build all the modules.

You'll end up with something like this:

ROOT (POM)
  Launcher-COMMON (POM)
    ...
  Launcher-1 (Jar)
    ...
  Runtime-COMMON (POM)
  Runtime-1  (Jar)
    ...    
  Runtime-2  (Jar)
    ...

You don't actually need to keep the launcher and runtime commons in the project if you don't want there there. In that case, do something like this

ROOT (POM)
  COMMON (POM)
    Runtime-COMMON (POM)
        ...    
    Launcher-COMMON (POM)
        ...    
  Launcher-1 (Jar)
    ...    
  Runtime-1  (Jar)
    ...    
  Runtime-2  (Jar)
    ...
sal