You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by pl...@apache.org on 2003/02/01 13:38:40 UTC

cvs commit: jakarta-turbine-maven/src/plugins-build/webserver plugin.jelly

plynch      2003/02/01 04:38:40

  Modified:    src/plugins-build/webserver plugin.jelly
  Log:
  o started adding checks for required properties and user messages - at some point investigate a way to make the messages locale specific - jelly tag library???
  o more hacks around dot property names and flaky expression handling when negative logic is used in expressions or testing for properties that should be null or not defined yet props
  
  Revision  Changes    Path
  1.8       +141 -32   jakarta-turbine-maven/src/plugins-build/webserver/plugin.jelly
  
  Index: plugin.jelly
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/plugins-build/webserver/plugin.jelly,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- plugin.jelly	31 Jan 2003 05:04:50 -0000	1.7
  +++ plugin.jelly	1 Feb 2003 12:38:39 -0000	1.8
  @@ -3,7 +3,8 @@
   <!-- ================================================================== -->
   <!-- W E B S E R V E R  P L U G I N                                     -->
   <!-- ================================================================== -->
  -<project xmlns:j="jelly:core" xmlns:ant="jelly:ant" xmlns:log="jelly:log">
  +<project xmlns:j="jelly:core" xmlns:ant="jelly:ant" xmlns:log="jelly:log"
  +  xmlns:exception="exception" xmlns:define="jelly:define">
   
     <!--==================================================================-->
     <!-- S U P P O R T E D  W E B S E R V E R S                           -->
  @@ -17,14 +18,131 @@
     <goal name="webserver:init"
       description="Initialize resources needed for the plugin">
   
  +    <!--
  +    1. First check that name and version properties have values
  +    2. Check the webserver name and version is supported by this plugin
  +    3. Check the home dir to make sure we can find the install
  +    4. Check the rest of the required properties
  +    5. Check the ports to make sure they are numbers only
  +    -->
  +
  +    <define:taglib uri="exception">
  +      <define:tag name="requiredPropertyMissing">
  +        <ant:fail message=" ">
  + --------------------------------------------------------------------------
  + | Plugin Configuration Error                                             |
  + --------------------------------------------------------------------------
  +
  +  A required property is missing a value.
  +
  +  Property name: ${propname}
  +
  +  Errors must be corrected before using this plugin.
  +
  + --------------------------------------------------------------------------
  +        </ant:fail>
  +      </define:tag>
  +      <define:tag name="invalidPropertyDirectory">
  +        <ant:fail message=" ">
  + --------------------------------------------------------------------------
  + | Plugin Configuration Error                                             |
  + --------------------------------------------------------------------------
  +
  +  A required property is pointing to an invalid directory.
  +
  +  Property name: ${propname}
  +  Invalid value: ${propvalue}
  +
  +  Errors must be corrected before using this plugin.
  +
  + --------------------------------------------------------------------------
  +        </ant:fail>
  +      </define:tag>
  +      <define:tag name="webserverNameNotSupported">
  +        <ant:fail message=" ">
  + --------------------------------------------------------------------------
  + | Plugin Configuration Error                                             |
  + --------------------------------------------------------------------------
  +
  +  The specified webserver name is currently not supported.
  +
  +  Property name: ${propname}
  +  Property value: ${propvalue}
  +
  +  For supported ${propname} values, please see the help docs.
  +
  + --------------------------------------------------------------------------
  +        </ant:fail>
  +      </define:tag>
  +      <define:tag name="webserverVersionNotSupported">
  +        <ant:fail message=" ">
  + --------------------------------------------------------------------------
  + | Plugin Configuration Error                                             |
  + --------------------------------------------------------------------------
  +
  +  The specified version for the ${webserver} webserver is currently
  +  not supported.
  +
  +  Property name: ${propname}
  +  Property value: ${propvalue}
  +
  +  For supported ${propname} values, please see the help docs.
  +
  + --------------------------------------------------------------------------
  +        </ant:fail>
  +      </define:tag>
  +    </define:taglib>
  +
  +
  +    <!-- Check all required properties for a name and version first -->
  +    <j:if test="${context.getVariable('maven.webserver.name') == null}">
  +      <exception:requiredPropertyMissing propname="maven.webserver.name" />
  +    </j:if>
  +    <j:if test="${context.getVariable('maven.webserver.version') == null}">
  +      <exception:requiredPropertyMissing propname="maven.webserver.version" />
  +    </j:if>
  +
  +    <!-- Check if the webserver name and version are supported -->
  +    <j:choose>
  +      <j:when test="${context.getVariable('maven.webserver.name') == 'apache'}">
  +        <j:choose>
  +          <j:when test="${context.getVariable('maven.webserver.version') == '2.x'}" />
  +          <j:otherwise>
  +            <exception:webserverVersionNotSupported
  +              webserver="${maven.webserver.name}"
  +              propname="maven.webserver.version"
  +              propvalue="${maven.webserver.version}" />
  +          </j:otherwise>
  +        </j:choose>
  +      </j:when>
  +      <j:otherwise>
  +        <exception:webserverNameNotSupported propname="maven.webserver.name"
  +          propvalue="${maven.webserver.name}" />
  +      </j:otherwise>
  +    </j:choose>
  +
  +    <!-- Check the home dir to see if it exists -->
  +    <ant:condition property="maven.webserver.home.exists">
  +      <ant:available file="${maven.webserver.home}" type="dir" />
  +    </ant:condition>
  +    <j:if test="${!context.getVariable('maven.webserver.home.exists')}">
  +      <exception:invalidPropertyDirectory propname="maven.webserver.home"
  +      propvalue="${maven.webserver.home}" />
  +    </j:if>
  +
  +
       <!-- a flag to see if the webserver is started -->
       <ant:condition property="maven.webserver.started">
         <ant:http url="${maven.webserver.url}" />
       </ant:condition>
   
       <!-- a flag to see if the webserver is installed -->
  -    <ant:available property="maven.webserver.installed"
  -      file="${maven.webserver.root}" type="dir" />
  +    <ant:condition property="maven.webserver.installed">
  +      <ant:and>
  +        <ant:available file="${maven.webserver.root}" type="dir" />
  +        <ant:available file="${maven.webserver.dir}" type="dir" />
  +      </ant:and>
  +    </ant:condition>
   
       <!-- convert all path related properties to their os equivalent -->
       <ant:property name="maven.webserver.home.path"
  @@ -190,22 +308,16 @@
     <!--==================================================================-->
     <goal name="webserver:stop" prereqs="webserver:init"
       description="Stop a webserver instance if started">
  -    <ant:condition property="maven.webserver.startandinstalled">
  -      <ant:and>
  -        <ant:isset property="maven.webserver.installed"/>
  -        <ant:isset property="maven.webserver.started"/>
  -      </ant:and>
  -    </ant:condition>
   
       <j:choose>
  -      <j:when test="${maven.webserver.startedandinstalled}">
  +      <j:when test="${maven.webserver.started and maven.webserver.installed}">
           <log:info trim="false">
  -Stopping the webserver...
  +Stopping the webserver ...
           </log:info>
           <attainGoal name="webserver:stop-${maven.webserver.fullname}" />
         </j:when>
         <j:otherwise>
  -        <j:if test="${webserver.goal.clean.called} == null">
  +        <j:if test="${webserver.goal.clean.called != 'true'}">
             <log:info trim="false">
   The <j:expr value="${maven.webserver.fullname}"/> is already stopped!
             </log:info>
  @@ -222,34 +334,31 @@
       description="Safely delete an installed webserver instance">
   
        <!-- property to remember what goal the user first called -->
  -    <ant:property name="webserver.goal.clean.called" value="true" />
  +    <j:set var="webserver.goal.clean.called" value="true" />
   
       <j:if test="${maven.webserver.started}">
  -      <log:info>
  -        Stopping the <j:expr value="${maven.webserver.fullname}" />
  -        webserver instance before deleting it...
  +      <log:info trim="false">
  +Stopping the <j:expr value="${maven.webserver.fullname}" /> webserver instance before deleting it ...
         </log:info>
         <attainGoal name="webserver:stop" />
       </j:if>
   
  -    <j:if test="${maven.webserver.installed}">
  -      <log:info trim="false">
  +    <j:choose>
  +      <j:when test="${maven.webserver.installed}">
  +        <log:info trim="false">
   Deleting the <j:expr value="${maven.webserver.fullname}" /> webserver instance ...
  -      </log:info>
  -
  -      <!-- allow webservers to have their own cleanup -->
  -      <attainGoal name="webserver:clean-${maven.webserver.fullname}" />
  -
  -      <!-- by default cleanup the server dir -->
  -      <ant:delete dir="${maven.webserver.dir}"/>
  -
  -    </j:if>
  -
  -    <j:if test="${maven.webserver.installed} != 'true'">
  -      <log:info trim="false">
  +        </log:info>
  +        <!-- allow webservers to have their own cleanup -->
  +        <attainGoal name="webserver:clean-${maven.webserver.fullname}" />
  +        <!-- all clean calls should cleanup the server dir -->
  +        <ant:delete dir="${maven.webserver.dir}"/>
  +      </j:when>
  +      <j:otherwise>
  +        <log:info trim="false">
   The <j:expr value="${maven.webserver.fullname}"/> webserver instance is already cleaned!
  -      </log:info>
  -    </j:if>
  +        </log:info>
  +      </j:otherwise>
  +    </j:choose>
   
     </goal>