maven-plugins/jboss/plugin.jelly

323 lines
12 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:util="jelly:util"
xmlns:jmx="jmx"
xmlns:define="jelly:define">
<!--
========================================================================
Default goal.
========================================================================
-->
<goal name="jboss"
description="Creates a specific JBoss server configuration"
prereqs="jboss:configure"/>
<!--
========================================================================
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 custom JBoss server configuration directory structure.
========================================================================
-->
<goal name="jboss:configure"
description="Creates a specific JBoss server configuration"
prereqs="jboss:init">
<!-- 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}" overwrite="true">
<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}" overwrite="true">
<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>
</goal>
<!--
========================================================================
Generates the zipped distributable. This goal is called automatically
by the "jboss:package-*" goals.
========================================================================
-->
<goal name="jboss:dist">
<!-- 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>
<!--
========================================================================
Creates a custom JBoss server configuration directory structure,
packaging an EAR in it.
========================================================================
-->
<goal name="jboss:package-ear"
description="Creates a specific JBoss server configuration (with EAR)"
prereqs="jboss:init,ear:ear,jboss:configure">
<!-- 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}"/>
<attainGoal name="jboss:dist"/>
</goal>
<!--
========================================================================
Creates a custom JBoss server configuration directory structure,
packaging a WAR in it.
========================================================================
-->
<goal name="jboss:package-war"
description="Creates a specific JBoss server configuration (with WAR)"
prereqs="jboss:init,war:war,jboss:configure">
<j:set var="warBuildDir"
value="${pom.getPluginContext('maven-war-plugin').getVariable('maven.war.build.dir')}"/>
<j:set var="warFinalName"
value="${pom.getPluginContext('maven-war-plugin').getVariable('maven.war.final.name')}"/>
<!-- Copy the WAR to install to the JBoss deploy dir. -->
<copy file="${warBuildDir}/${warFinalName}"
todir="${maven.jboss.build.deploy.dir}"/>
<attainGoal name="jboss:dist"/>
</goal>
<!--
========================================================================
Creates a custom JBoss server configuration directory structure,
packaging an EJB-JAR in it.
========================================================================
-->
<goal name="jboss:package-ejb"
description="Creates a specific JBoss server configuration (with EJB-JAR)"
prereqs="jboss:init,ejb:ejb,jboss:configure">
<!-- Copy the EJB-JAR to install to the JBoss deploy dir. -->
<copy file="${maven.build.dir}/${maven.final.name}.jar"
todir="${maven.jboss.build.deploy.dir}"/>
<attainGoal name="jboss:dist"/>
</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 -->
<util:file var="jbossfile"
name="${maven.jboss.build.dir}/${maven.jboss.conf.name}"/>
<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.
Note: The war plugin's war:webapp goal will create an exploded warfile
at ${maven.build.dir}/${pom.artifactId}. If you want to deploy
that then it really should be ${maven.build.dir}/${pom.artifactId}.war.
Thus, in your project.properties, you should set maven.war.webapp.dir
to ${maven.build.dir}/${pom.artifactId}.war. In an ideal world that
would be the default value. I'm not sure why it isn't and I don't
want to change it because someone may be relying on the existing
behavior.
You have been warned!
========================================================================
-->
<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>