[mojo-user] Re: [m2] Using the tomcat plugin

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[mojo-user] Re: [m2] Using the tomcat plugin

mihobson
Hi Ralph,

On 02/11/05, Ralph Pöllath <[hidden email]> wrote:

> Hi,
>
> I've successfully compiled and installed the tomcat plugin from svn,
> and tomcat:deploy works as expected. Now I'm wondering how to best
> use it.
>
> For development, I'd like to avoid zipping up the war file for each
> deployment. From gleaning at the source, I learned this means
> deploying in local mode. I guess I have to pass a parameter to the
> tomcat plugin, but I can't figure out the parameter's correct name (I
> know, this question is related to plugins in general, but I can't
> find the documentation).

Yes, I'm afraid the current situation is a bit in-between versions.
The svn version of the tomcat plugin was written to work with the
pre-mvn 2.0 version of the war plugin, in which a 'mode' config param
was used to choose between war, exploded and inplace packaging.

Since 2.0 final, the war plugin has depreciated the 'mode' config
param in preference to war:war, war:exploded and war:inplace goals,
and thus the packaging always builds the war regardless.  This means
that tomcat:deploy always causes the war to be built, irrespective of
it's configuration.

There's discussion atm on the dev list regarding m2 changes that would
allow the tomcat:deploy goal to be split into tomcat:deploy,
tomcat:exploded and tomcat:inplace goals.  Until then I'm afraid the
tomcat:deploy always causes the war to be built.

> I tried
> $ mvn -Dorg.apache.maven.plugins.maven-tomcat-plugin.mode=local
> tomcat:deploy
> and
> $ mvn -Dorg.codehaus.mojo.tomcat.mode=local tomcat:deploy
> but all I get is
> [INFO] Deploying war remotely to /myProject on http://localhost:8080/
> manager
> which means I'm running in the default remote mode.

You specify the plugin config params in your pom as follows:

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>tomcat-maven-plugin</artifactId>
        <configuration>
          <mode>...</mode>
          <url>...</url>
          <server>...</server>
          <path>...</path>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

Yep, site doc to follow.. ;)

Check the following for a general plugin config how-to:
http://maven.apache.org/guides/mini/guide-configuring-plugins.html

> I also noticed there's a mode called inplace, that uses a context.xml
> file to deploy to tomcat, and requires the war plugin to run in
> exploded mode. What's the advantage of using inplace (I assume you
> get to use a path different from project.build.finalName?), and how
> do I configure the war plugin?

Here's a summary of the modes (soon to be hopefully replaced by
individual goals):

* remote (default) - deploys the war file via http put to tomcat
* local - deploys the war file (if war mode = "war") or war dir (if
war mode != "exploded") file to tomcat via a local file path
* inplace - deploys the war dir with context.xml to tomcat via local paths

As mentioned in a similar thread, due to the war plugin changes I
intend to change the plugin to work as follows:

tomcat:deploy (depends on war:war) - deploy the war via http put to tomcat
tomcat:exploded (depends on war:exploded) - deploy the webapp dir
locally to tomcat
tomcat:inplace (depends on war:inplace) - deploy the webapp source dir
locally to tomcat

The mode config param would also be changed to take the following values:

mode = war - deploy the war file/dir
mode = context - deploy the context.xml file
mode = both - deploy the war file/dir with the context.xml file

> How does everyone else use the tomcat plugin?

Feedback on the proposed approach would be appreciated.

Cheers,

Mark
Loading...