TomEE Maven Plugin


With last TomEE release OpenEJB/TomEE community released a maven plugin to ease the TomEE usage (inspired from Jetty one for instance). Here is its common usage.

The minimum to make it working is to include the following plugin in your build:

<plugin>
  <groupId>org.apache.openejb.maven</groupId>
  <artifactId>tomee-maven-plugin</artifactId>
  <version>1.0-alpha-1</version> <!-- 1.0.0-SNAPSHOT for snapshot -->
  <configuration>
    <tomeeVersion>${tomee.version}</tomeeVersion>
    <tomeeClassifier>plus</tomeeClassifier>
  </configuration>
</plugin>

The available commands can be discovered running:

mvn tomee:help

It will print you the following output:

 Available commands:
  - tomee:run: run and wait the server
  - tomee:start: run the server
  - tomee:stop: stop the server (to use with start)
  - tomee:configtest: run configtest tomcat command
  - tomee:deploy : deploy path archive
  - tomee:undeploy : undeploy path archive. Note it should be the same path than the one used in deploy command
  - tomee:list: list ejbs deployed
  - tomee:help: this

About the configuration here is a table trying to summarize what is available:

Name System property to override the value Description
tomeeShutdownPort tomee-plugin.http The http port to use.
tomeeHttpPort tomee-plugin.shutdown The shutdown port to use.
args tomee-plugin.args Additional JVM arguments.
debug tomee-plugin.debug Activate remote debugging on TomEE.
debugPort tomee-plugin.debugPort Port to use for remote debugging when debug=true.
config tomee-plugin.conf Folder containing your custom configuration (src/main/tomee/conf by default).
bin tomee-plugin.bin Folder containing your custom scripts (src/main/tomee/bin by default).
lib tomee-plugin.lib Folder containing your custom libraries (src/main/tomee/lib by default).
systemVariables no Additional system properties.
libs no Additional libraries put in tomee/lib. It understands maven format groupId:artifactId:version
webapps no Additional webapps. It understands maven format too.
apps (on trunk) no Additional ear or jar/ejbmodule. It understands maven format too.
warFile no Path to the webapp, default is using the war of current project.
removeDefaultWebapps tomee-plugin.removeDefaultWebapps Remove or not tomcat webapps (manager, host-manager…) to gain some seconds at startup.
tomeeVersion tomee-plugin.version The version of the TomEE artifact used to deploy the application.
tomeeGroupId tomee-plugin.groupId The groupId of the TomEE artifact used to deploy the application.
tomeeArtifactId tomee-plugin.artifactId The artifactId of the TomEE artifact used to deploy the application
tomeeType tomee-plugin.type The type of the TomEE artifact used to deploy the application (zip).
tomeeClassifier tomee-plugin.classifier The classifier of the TomEE artifact used to deploy the application (zip). apacheRepos tomee-plugin.apache-repos A maven repository URL to add when looking for TomEE.

Sample:

<plugin>
  <groupId>org.apache.openejb.maven</groupId>
  <artifactId>tomee-maven-plugin</artifactId>
  <version>1.0-alpha-1</version>
  <configuration> <!-- all has default -->
    <tomeeVersion>1.0.0</tomeeVersion> <!-- 1.1.0-SNAPSHOT for tomee release -->
    <tomeeClassifier>plus</tomeeClassifier> <!-- default = webprofile -->
    <debug>false</debug>
    <debugPort>5005</debugPort>
    <args>-Dfoo=bar</args>
    <config>${project.basedir}/src/test/tomee/conf</config>
    <libs>
      <lib>mysql:mysql-connector-java:5.1.20</lib>
    </libs>
    <webapps>
       <webapp>org.superbiz:my-simple-webapp:1.0.0</webapp>
    </webapps>
  </configuration>
</plugin>

Note on trunk: on trunk this plugin is also usable in projects which are not war. For instance you can use it in a pom project to simply test some integration between 2 webapps, one webapp and an ejbmodule and so on. Another enhancement on trunk is a more relevant logging. In alpha version logs were not very useful excepted for tomee:run.

Note 2: if you look in target/apache-tomee you’ll have a classical TomEE you can use without any plugin or IDE.

Finally don’t forget to run package before tomee:run or tomee:start otherwise it will not deploy anything.

Advertisement

7 thoughts on “TomEE Maven Plugin

  1. Juan Manuel

    Neat, thanks a lot !
    Although, run and start seem to be swapped on version 1.0-alpha-1.
    Nevertheless, boosted my productivity a lot.

    Reply
  2. Tao

    Can you provide a full sample working pom.xml file?
    I tried different ways, never worked.

    Many thanks!

    Reply
  3. Juan Llado (@jllado)

    Hi Romain,

    Do you know if there is a property like maven.tomcat.skip for the tomee plugin? Sometimes I need to skip the integrations tests and I would like to avoid the tomee start

    Thanks!!

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s