jford       2004/04/21 21:03:04

  Modified:    plugin   plugin.jelly
  Log:
  Add example app generation
  
  Revision  Changes    Path
  1.8       +142 -1    jakarta-jetspeed/plugin/plugin.jelly
  
  Index: plugin.jelly
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/plugin/plugin.jelly,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- plugin.jelly      21 Apr 2004 23:04:48 -0000      1.7
  +++ plugin.jelly      22 Apr 2004 04:03:04 -0000      1.8
  @@ -19,7 +19,13 @@
       Jetspeed plugin for Maven.

     =============================================================================

   -->

  -<project xmlns:j="jelly:core" xmlns:u="jelly:util">

  +<project 

  +  xmlns:j="jelly:core"

  +  xmlns:i="jelly:interaction"

  +  xmlns:ant="jelly:ant" 

  +  xmlns:define="jelly:define"

  +  xmlns:u="jelly:util"

  +  xmlns:jetspeed="jetspeed">

       <!--

        ========================================================================

          Create the custom WAR from binary distribution

  @@ -246,5 +252,140 @@
           </copy>        

           <unwar src="${maven.war.appserver.home}/webapps/${pom.artifactId}.war" 
dest="${maven.war.appserver.home}/webapps/${pom.artifactId}"/>

       </goal>

  +    

  +    <define:taglib uri="jetspeed">

  +    <!--

  +     |

  +     | @template

  +     |

  +     -->

  +    <define:tag name="generate">

  +      <!-- Get the template -->

  +      <!-- create a temporary variable with no dots in the name to get around a 
jexl bug -->

  +      <j:set var="presettemplate" value="${template}"/>

  +      <j:if test="${empty(presettemplate)}">

  +        <i:ask question="${maven.jetspeed.genapp.prompt.template}" 
answer="template" default="${maven.jetspeed.genapp.default.template}"/>

  +      </j:if>

  +      

  +      <!-- If template is in the user's home directory, use it -->    

  +      <u:available file="${user.home}/.maven/template/${template}">

  +        <j:set var="maven.jetspeed.genapp.template.dir" 
value="${user.home}/.maven/template/${template}"/>

  +      </u:available>

  +      

  +      <j:set var="currenttemplatedir" 
value="${maven.jetspeed.genapp.template.dir}"/>

  +      <j:if test="${empty(currenttemplatedir)}">

  +        <!-- The template was not found in user.home, check in the plugin resources 
-->

  +        <u:available file="${plugin.resources}/${template}">

  +          <j:set var="maven.jetspeed.genapp.template.dir" 
value="${plugin.resources}/${template}"/>

  +        </u:available>

  +      </j:if>

  +      

  +      <j:set var="currenttemplatedir" 
value="${maven.jetspeed.genapp.template.dir}"/>

  +      <j:if test="${empty(currenttemplatedir)}">

  +        <fail>

  +          Unable to locate a template named ${template}

  +        </fail>

  +      </j:if>

  +      

  +      <!-- Ensure that the template has a template-resources directory and use it 
-->

  +      <u:available file="${maven.jetspeed.genapp.template.dir}/template-resources">

  +        <!-- Set resources dir to the template resources directory -->

  +        <j:set var="maven.jetspeed.genapp.resources" 
value="${maven.jetspeed.genapp.template.dir}/template-resources"/>

  +      </u:available>

  +  

  +      <!-- Check that we have a template-resources directory, if not the template 
is broken -->

  +      <j:set var="currenttemplateresources" 
value="${maven.jetspeed.genapp.resources}"/>

  +      <j:if test="${empty(currenttemplateresources)}">

  +        <fail>

  +          Found a template in ${maven.jetspeed.genapp.template.dir}, but it was 
broken.

  +        </fail>

  +      </j:if>

  +      

  +      <!-- Load template properties if available -->

  +      <u:available file="${maven.jetspeed.genapp.template.dir}/template.properties">

  +        <u:properties 
file="${maven.jetspeed.genapp.template.dir}/template.properties"/>

  +      </u:available>

  +      

  +      <!-- Ensure we have a project id, name, and package -->

  +      

  +      <j:set var="presetid" value="${maven.jetspeed.genapp.template.id}"/>

  +      <j:if test="${empty(presetid)}">

  +        <i:ask question="${maven.jetspeed.genapp.prompt.id}" 
answer="maven.jetspeed.genapp.template.id" 
default="${maven.jetspeed.genapp.default.id}"/>

  +      </j:if>

  +      

  +      <j:set var="presetname" value="${maven.jetspeed.genapp.template.name}"/>

  +      <j:if test="${empty(presetname)}">

  +        <i:ask question="${maven.jetspeed.genapp.prompt.name}" 
answer="maven.jetspeed.genapp.template.name" 
default="${maven.jetspeed.genapp.default.name}"/>

  +      </j:if>

  +      

  +      <j:set var="presetpackage" value="${maven.jetspeed.genapp.template.package}"/>

  +      <j:if test="${empty(presetpackage)}">

  +        <i:ask question="${maven.jetspeed.genapp.prompt.package}" 
answer="maven.jetspeed.genapp.template.package" 
default="${maven.jetspeed.genapp.default.package}"/>

  +      </j:if>

  +      

  +      <!-- Turn the specified package into a path -->

  +      <u:replace var="appPath" oldChar="." newChar="/" 
value="${maven.jetspeed.genapp.template.package}"/>

  +      

  +      <!-- We want to substitute in the id, name, and package name. -->

  +      <filter token="ID" value="${maven.jetspeed.genapp.template.id}"/>

  +      <filter token="NAME" value="${maven.jetspeed.genapp.template.name}"/>

  +      <filter token="PACKAGE" value="${maven.jetspeed.genapp.template.package}"/>

  +  

  +      <!-- split the list of dirs that need repackaged -->

  +      <u:tokenize var="maven.jetspeed.genapp.repackage.split" 
delim=",">${maven.jetspeed.genapp.repackage}</u:tokenize>

  +  

  +      <!-- copy resources that need repackaged, eg java files -->

  +      <j:forEach var="res" items="${maven.jetspeed.genapp.repackage.split}">

  +        <ant:copy todir="${basedir}/src/${res}/${appPath}" 

  +              filtering="true">

  +          <ant:fileset dir="${maven.jetspeed.genapp.resources}/src/${res}" />

  +        </ant:copy>      

  +      </j:forEach>

  +      

  +      <u:tokenize var="maven.jetspeed.genapp.properties.split" 
delim=",">${maven.jetspeed.genapp.properties}</u:tokenize>

  +      <!-- copy resources that need repackaged, eg java files -->

  +      <j:forEach var="res" items="${maven.jetspeed.genapp.properties.split}">

  +        <ant:copy todir="${basedir}/src/${res}" 

  +              filtering="true">

  +          <ant:fileset dir="${maven.jetspeed.genapp.resources}/src/${res}" />

  +        </ant:copy>

  +      </j:forEach>

  +  

  +      <!-- copy resources that just need filtered, eg project.xml -->

  +      <ant:copy todir="${basedir}" filtering="true">      

  +        <ant:fileset dir="${maven.jetspeed.genapp.resources}">

  +          <j:forEach var="res" items="${maven.jetspeed.genapp.filter}">

  +            <include name="${res}"/>

  +          </j:forEach>

  +        </ant:fileset>

  +      </ant:copy>

  +  

  +      <!-- copy rest of app unfiltered -->

  +      <ant:copy todir="${basedir}">      

  +        <ant:fileset dir="${maven.jetspeed.genapp.resources}">

  +          <ant:exclude name="src/java"/>

  +          <ant:exclude name="src/test"/>

  +          <j:forEach var="res" items="${maven.jetspeed.genapp.filter}">

  +            <exclude name="${res}"/>

  +          </j:forEach>

  +          <j:forEach var="res" items="${maven.jetspeed.genapp.repackage.split}">

  +            <exclude name="src/${res}/**"/>

  +          </j:forEach>

  +        </ant:fileset>

  +      </ant:copy>

  +      

  +      <!-- Run the specific jelly script for the template -->

  +      <u:available file="${maven.jetspeed.genapp.template.dir}/template.jelly">

  +        <echo>Use template.jelly file present in 
${maven.jetspeed.genapp.template.dir}.</echo>

  +        <j:import file="${maven.jetspeed.genapp.template.dir}/template.jelly" 
inherit="true"/> 

  +      </u:available>

  +    </define:tag>

  +  </define:taglib>

  +  

  +  <goal name="jetspeed:genapp">

  +     <!--<attainGoal name="genapp"/>-->

  +     <jetspeed:generate template="${maven.jetspeed.genapp.template}"/>

  +  </goal>

  +  

       

   </project>

  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to