maven-plugins/jboss/plugin.jelly

248 lines
9.4 KiB
XML

<?xml version="1.0"?>
<!--
=============================================================================
JBoss plugin for Maven. Contains JBoss related goals useful for
packaging and deploying applications.
=============================================================================
-->
<project
xmlns:j="jelly:core"
xmlns:jmx="jmx"
xmlns:define="jelly:define">
<!--
========================================================================
Default goal.
========================================================================
-->
<goal name="jboss"
description="Creates a specific JBoss server configuration"
prereqs="jboss:package"/>
<!--
========================================================================
Initializations.
========================================================================
-->
<goal name="jboss:init">
<!-- Check if the maven.jboss.home mandatory property is set -->
<j:set var="jbosshomeX" value="${maven.jboss.home}X"/>
<j:choose>
<j:when test="${jbosshomeX == 'X'}">
<fail>You need to set the maven.jboss.home property</fail>
</j:when>
<j:otherwise>
<echo>Using JBoss from ${maven.jboss.home} ...</echo>
</j:otherwise>
</j:choose>
<property name="maven.jboss.build.deploy.dir"
value="${maven.jboss.build.dir}/${maven.jboss.conf.name}/deploy"/>
<property name="maven.jboss.build.lib.dir"
value="${maven.jboss.build.dir}/${maven.jboss.conf.name}/lib"/>
<property name="maven.jboss.build.conf.dir"
value="${maven.jboss.build.dir}/${maven.jboss.conf.name}/conf"/>
</goal>
<!--
========================================================================
Creates a JBoss server configuration directory structure, packaging
the application EAR in it.
========================================================================
-->
<goal name="jboss:package"
description="Creates a specific JBoss server configuration"
prereqs="ear:ear,jboss:init">
<!-- Copy the EAR to install to the JBoss deploy dir. -->
<copy file="${maven.build.dir}/${maven.final.name}.ear"
todir="${maven.jboss.build.deploy.dir}"/>
<!-- Copy the JBoss jars from an existing JBoss default server
configuration to our specific configuration -->
<copy todir="${maven.jboss.build.lib.dir}">
<fileset dir="${maven.jboss.default.lib.dir}"
includes="${maven.jboss.default.lib.includes}"
excludes="${maven.jboss.default.lib.excludes}"/>
</copy>
<!-- Copy the JBoss default conf files from an existing JBoss
server configuration to our specific configuration -->
<copy todir="${maven.jboss.build.conf.dir}">
<fileset dir="${maven.jboss.default.conf.dir}"
includes="${maven.jboss.default.conf.includes}"
excludes="${maven.jboss.default.conf.excludes}"/>
</copy>
<!-- Copy the JBoss default deploy files from an existing JBoss
server configuration to our specific configuration -->
<copy todir="${maven.jboss.build.deploy.dir}">
<fileset dir="${maven.jboss.default.deploy.dir}"
includes="${maven.jboss.default.deploy.includes}"
excludes="${maven.jboss.default.deploy.excludes}"/>
</copy>
<!-- Copy the application-specific JBoss conf files to our
specific configuration (if any) -->
<j:set var="jbossconfX" value="${maven.jboss.conf.dir}X"/>
<j:if test="${jbossconfX != 'X'}">
<copy todir="${maven.jboss.build.conf.dir}">
<fileset dir="${maven.jboss.conf.dir}"/>
</copy>
</j:if>
<!-- Copy the application-specific JBoss deploy files to our
specific configuration (if any) -->
<j:set var="jbossdeployX" value="${maven.jboss.deploy.dir}X"/>
<j:if test="${jbossdeployX != 'X'}">
<copy todir="${maven.jboss.build.deploy.dir}">
<fileset dir="${maven.jboss.deploy.dir}"/>
</copy>
</j:if>
<!-- Copy the application-specific conf files to our
specific configuration (if any) -->
<j:set var="jbossappconfX" value="${maven.jboss.appconf.dir}X"/>
<j:if test="${jbossappconfX != 'X'}">
<copy todir="${maven.jboss.build.conf.dir}">
<fileset dir="${maven.jboss.appconf.dir}"/>
</copy>
</j:if>
<!-- Generate the distributable -->
<zip destfile="${maven.build.dir}/${pom.artifactId}-${pom.currentVersion}.zip">
<zipfileset dir="${maven.jboss.build.dir}/${maven.jboss.conf.name}"
prefix="${maven.jboss.conf.name}"/>
</zip>
</goal>
<!--
========================================================================
Start JBoss using our specific server configuration.
========================================================================
-->
<goal name="jboss:start" prereqs="jboss:init"
description="Starts JBoss with our specific server configuration">
<!-- Construct a URL valid on any OS -->
<j:new var="jbossfile" className="java.io.File">
<j:arg value="${maven.jboss.build.dir}/${maven.jboss.conf.name}"/>
</j:new>
<j:set var="jbossurl" value="${jbossfile.toURL()}"/>
<java classname="org.jboss.Main" fork="yes" dir="${maven.jboss.home}/bin">
<sysproperty key="program.name" file="${maven.jboss.home}/bin/run.bat"/>
<sysproperty key="jboss.server.home.dir"
file="${maven.jboss.build.dir}/${maven.jboss.conf.name}"/>
<sysproperty key="jboss.server.home.url" value="${jbossurl}"/>
<arg line="-c ${maven.jboss.conf.name}"/>
<classpath>
<pathelement location="${maven.jboss.home}/bin/run.jar"/>
<pathelement path="${java.home}/../lib/tools.jar"/>
</classpath>
</java>
</goal>
<!--
========================================================================
Stop JBoss.
========================================================================
-->
<goal name="jboss:stop" prereqs="jboss:init"
description="Stops JBoss">
<java classname="org.jboss.Shutdown" fork="yes">
<arg value="${maven.jboss.hostname}"/>
<classpath>
<pathelement location="${maven.jboss.home}/bin/shutdown.jar"/>
</classpath>
</java>
</goal>
<!--
========================================================================
Various deploy/undeploy goals
========================================================================
-->
<goal name="jboss:deploy-exploded-warfile" prereqs="war:webapp"
description="Invoke the 'war:webapp' goal and deploy the result. Note that 'maven.war.webapp.dir' *must* end with '.war' for this to work correctly.">
<jmx:deploy jmx.deploy.file='${context.getVariable("maven.war.webapp.dir")}'/>
</goal>
<goal name="jboss:undeploy-exploded-warfile"
description="Undeploy the result of the 'war:webapp' goal. Note that 'maven.war.webapp.dir' *must* end with '.war' for this to work correctly.">
<jmx:undeploy jmx.deploy.file='${context.getVariable("maven.war.webapp.dir")}'/>
</goal>
<goal name="jboss:deploy-warfile" prereqs="war:war"
description="Invoke the 'war' goal and deploy the result">
<jmx:deploy jmx.deploy.file='${maven.build.dir}/${maven.war.final.name}'/>
</goal>
<goal name="jboss:undeploy-warfile" prereqs="war:init"
description="Undeploy the result of the 'war' goal">
<jmx:undeploy jmx.deploy.file='${maven.build.dir}/${maven.war.final.name}'/>
</goal>
<!-- Once maven has a goal that will build a jarfile of EJBs, this should
list it as a prereq -->
<goal name="jboss:deploy-ejb"
description="Deploy ${maven.final.name}.jar">
<jmx:deploy jmx.deploy.file='${maven.build.dir}/${maven.final.name}.jar'/>
</goal>
<goal name="jboss:undeploy-ejb"
description="Undeploy ${maven.final.name}.jar">
<jmx:undeploy jmx.deploy.file='${maven.build.dir}/${maven.final.name}.jar'/>
</goal>
<!-- Once maven has a goal that will build an earfile of EJBs, this should
list it as a prereq -->
<goal name="jboss:deploy-ear"
description="Deploy ${maven.final.name}.ear">
<jmx:deploy jmx.deploy.file='${maven.build.dir}/${maven.final.name}.ear'/>
</goal>
<goal name="jboss:undeploy-ear"
description="Undeploy ${maven.final.name}.ear">
<jmx:undeploy jmx.deploy.file='${maven.build.dir}/${maven.final.name}.ear'/>
</goal>
<!--
========================================================================
JMX tags to deploy and undeploy "things"
========================================================================
-->
<define:taglib uri="jmx">
<define:tag name="deploy">
<j:set var="maven.jboss.jmx.url.undeploy"
value='${pom.getPluginContext("maven-jboss-plugin").getVariable("maven.jboss.jmx.url.undeploy")}'/>
<get dest="deploy.log"
src="${maven.jboss.jmx.url.undeploy}file:${jmx.deploy.file}"/>
<j:set var="maven.jboss.jmx.url.deploy"
value='${pom.getPluginContext("maven-jboss-plugin").getVariable("maven.jboss.jmx.url.deploy")}'/>
<get dest="deploy.log"
src="${maven.jboss.jmx.url.deploy}file:${jmx.deploy.file}"/>
</define:tag>
<define:tag name="undeploy">
<j:set var="maven.jboss.jmx.url.undeploy"
value='${pom.getPluginContext("maven-jboss-plugin").getVariable("maven.jboss.jmx.url.undeploy")}'/>
<get dest="deploy.log"
src="${maven.jboss.jmx.url.undeploy}file:${jmx.deploy.file}"/>
</define:tag>
</define:taglib>
</project>