Deploying to tomcat with maven


Trying to echive something simple with maven can sometimes be frustraiting,
We need to deploy a few web apps to tomcat and place them as exploded wars and jars in a file system directory and point to them with tomcat contexts.
there is a maven-tomcat-deploy-sample that simulates the real structure of the sources,a very simple one, and solves part of the requirements, but we have still unsolved isuues and any help is most welcome.

from the README:

the sample is made of two main applications with submodules, kuku and kiki.

the structure is:

main-reactor -
    repo-parent - (parent afor all, declares repositories)
    main-parent - (parent for all sub modules,inherits repo-parent)
    tomcat-deploy - (module to install tomcat, inherits repo-parent)
    kiki-reactor -
        kiki-core - (parent is main-parent)
        kiki-web - (parent is main-parent)
    kuku-reactor -
        kuku-core - (parent is main-parent)
        kuku-web - (parent is main-parent)

the reactors are only reactors.
all sub module inherit main-parent.
reactrors inherit each other from down up.

what it tries to achieve:

home -
    app -
       lib -
            all jars go here
       webapp -
            all wars go here, exploded
    tomcat -
        tomcat installed here


Behaviour should be:
deploy is by explicitly activating a deploy profile.
if running maven from the top most reactor everything should be deployed.
if tomcat does not exists it should be installed. echived partially.
if running from a second level reactor everything under it should be deployed.
if running a single module only it should be deployed.
deployment includes all dependencies.
all jars should go to the lib folder.
all wars should go to the webapp folder, exploded.
the exploded wars should not contain their dependencies under WEB-INF/lib. could not echive that with war:exploded.

we would like:
1) that dependencies are NOT copied more then once,
    for example all projects depend on log4j,it will be copied to the lib folder for every
    sub module, hopefully overriding each other with the same file.

2) we don't want to touch every sub module pom,
    if a sub module is added it should be deployed automatically when invoking the deploy profile. the solution currentlly fulfils that.

current implementation :
all submodules inherit from main-parent.
a 'deploy' profile in main-parent does the job of copying wars and jars to their
    deploy location.
the profile overrides configuration of maven jar and war plugins to build the artifact to
the deploy location instead of the default location. this results is no files under
maven target, i have no idea what it can do to unit tests.
a tomcat-deploy module installs tomcat, it is activated by edding it as module to the 'deploy' profile.

if tomcat exists it should not be installed, tried to do that with a 'mising file' activation but it doesn't work, its always active.
also , the tomcat-deploy module is only activated when we run maven from the top most reactor, not from other modules or reactors,
the way it is now the first build must be done from the top most reactor so all sub modules are deployed and tomcat installed.

this demo uses tomcat 5 from the central repo.

to test run:
change those properties to point to a home folder:
    main-parent:   deploy.home
    tomcat-deploy: tomcat.install.location

    mvn clean install -Pdeploy