geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tom McQueeney <...@mcqueeney.com>
Subject Maven script for projects using Geronimo
Date Sun, 19 Jun 2005 18:33:52 GMT
All,

I wrote a generic maven.xml script to use with J2EE projects targeting 
Geronimo. I'm hoping others will find it helpful. Since I'm not a Maven 
pro, I'm hoping for some suggestions for improving the script before I 
add it to the wiki.

The script follows. But first, here's how to use it:

Create or edit your Maven project.properties file with these values:

     geronimo.home=[set path to your Geronimo install directory]
     geronimo.user=system
     geronimo.password=manager

You can also set an environment variable, GERONIMO_HOME, pointing to 
your Geronimo install directory. If you do, delete the geronimo.home 
entry in the above project.properties file because it will override the 
environment variable. Remember to change the above user and password 
variables if you've changed your user/password in Geronimo's 
var/security/users.properties.

Usage examples for the Maven script:

maven list
     List stopped and started configurations
     This is a handy goal because you can see if your configuration was 
deployed but not started for some reason.

maven deploy -Djar=[path to jar|war|ear|rar] -Dplan=[path to plan file]
     Deploy a J2EE module with the given external Geronimo plan file

maven deploy-jar -Djar=[path to jar|war|ear|rar]
     Deploy a J2EE module with an embedded Geronimo plan file

maven deploy-tool-start
     Start the org/apache/geronimo/DebugConsole
     This is the debug console available under the context /debug-tool.

maven deploy-tool-stop
     Stop the org/apache/geronimo/DebugConsole configuration

maven start-config -Dconfig=[configuration to start]
     General goal to start any configuration

maven stop-config -Dconfig=[configuration to stop]
     General goal to stop any configuration

maven undeploy-config -Dconfig=[configuration to undeploy]
     General goal to undeploy any configuration

Here's the (latest) version of the maven.xml. I'll update it with any 
feedback on my blog at 
http://www.jroller.com/page/GeronimoLive/20050619#maven_script_for_projects_using

maven.xml:

<?xml version="1.0" encoding="ISO-8859-1"?>

<project
     xmlns:j="jelly:core"
     xmlns:maven="jelly:maven"
     xmlns:ant="jelly:ant"
     xmlns:geronimo="geronimo:deploy"
 >
     <property environment="env" />

     <goal name="check-props">
         <j:if test="${context.getVariable('geronimo.home') == null}">
             <j:if test="${context.getVariable('env.GERONIMO_HOME') == 
null}">
                 <fail>Please set either env-var GERONIMO_HOME or Maven 
var geronimo.home</fail>
             </j:if>

             <echo level="debug">Setting geronimo.home to 
${env.GERONIMO_HOME}</echo>
             <j:set var="geronimo.home" value="${env.GERONIMO_HOME}" />
         </j:if>

         <j:if test="${context.getVariable('war.path') == null}">
             <maven:get var="war.file" plugin="maven-war-plugin" 
property="maven.war.final.name" />
             <maven:get var="war.dir" plugin="maven-war-plugin" 
property="maven.war.build.dir" />
             <j:set var="war.path" value="${war.dir}/${war.file}" />
         </j:if>
     </goal>

     <goal name="deploy" prereqs="check-props"
         description="Deploy to Geronimo. Define properties 'jar' and 
'plan'"
     >
         <fail unless="jar" message="Requires a JAR file. Use 
-Djar=&lt;path-to-jar&gt;" />
         <fail unless="plan" message="Requires a plan file . Use 
-Dplan=&lt;path-to-plan&gt;" />

         <geronimo:distribute
 
uri="deployer:geronimo:jmx:rmi://localhost/jndi/rmi:/JMXConnector"
             username="${geronimo.user}"
             password="${geronimo.password}"
             module="${jar}"
             plan="${plan}"
         />
     </goal>

     <goal name="deploy-jar" prereqs="check-props"
         description="Deploy to Geronimo. Define property 'jar'"
     >
         <fail unless="jar" message="Requires a JAR file. Use 
-Djar=&lt;path-to-jar&gt;" />
         <geronimo:distribute
 
uri="deployer:geronimo:jmx:rmi://localhost/jndi/rmi:/JMXConnector"
             username="${geronimo.user}"
             password="${geronimo.password}"
             module="${jar}"
         />
     </goal>

     <goal name="start-config" prereqs="check-props"
         description="Start configuration defined by 'config' property"
     >
         <j:if test="${context.getVariable('config') == null}">
             <fail>Please set the 'config' variable</fail>
         </j:if>
         <geronimo:start
 
uri="deployer:geronimo:jmx:rmi://localhost/jndi/rmi:/JMXConnector"
             username="${geronimo.user}"
             password="${geronimo.password}"
             id="${config}"
         />
     </goal>

     <goal name="stop-config" prereqs="check-props"
         description="Stop configuration defined by 'config' property"
     >
         <j:if test="${context.getVariable('config') == null}">
             <fail>Please set the 'config' variable</fail>
         </j:if>
         <geronimo:stop
 
uri="deployer:geronimo:jmx:rmi://localhost/jndi/rmi:/JMXConnector"
             username="${geronimo.user}"
             password="${geronimo.password}"
             id="${config}"
         />
     </goal>

     <goal name="undeploy-config" prereqs="check-props" 
description="Undeploy the 'config' configuration">
         <j:if test="${context.getVariable('config') == null}">
             <fail>Please set the 'config' variable</fail>
         </j:if>

         <ant:echo>Undeploy ${config}</ant:echo>
         <geronimo:undeploy
 
uri="deployer:geronimo:jmx:rmi://localhost/jndi/rmi:/JMXConnector"
             username="${geronimo.user}"
             password="${geronimo.password}"
             id="${config}"
         />
     </goal>

     <goal name="debug-tool-start" prereqs="check-props" 
description="Start the debug-tool" default="true">
         <j:set var="config" value="org/apache/geronimo/DebugConsole" />
         <attainGoal name="start" />
     </goal>

     <goal name="debug-tool-stop" prereqs="check-props" 
description="Stop the debug-tool">
         <j:set var="config" value="org/apache/geronimo/DebugConsole" />
         <attainGoal name="stop" />
     </goal>

     <goal name="list" prereqs="check-props"
         description="List configurations deployed and started"
     >
         <echo level="info">Started configurations:</echo>
         <ant:java jar="${geronimo.home}/bin/deployer.jar" fork="true">
             <arg value="--user"/>
             <arg value="${geronimo.user}"/>
             <arg value="--password"/>
             <arg value="${geronimo.password}"/>
             <arg value="list-modules"/>
             <arg value="--started"/>
         </ant:java>

         <echo level="info"></echo>
         <echo level="info">Stopped configurations:</echo>
         <ant:java jar="${geronimo.home}/bin/deployer.jar" fork="true">
             <arg value="--user" />
             <arg value="${geronimo.user}" />
             <arg value="--password" />
             <arg value="${geronimo.password}" />
             <arg line="list-modules --stopped" />
         </ant:java>
     </goal>

</project>

Mime
View raw message