jvanzyl     2003/11/30 13:26:27

  Modified:    genapp   plugin.jelly plugin.properties project.xml
               genapp/xdocs changes.xml properties.xml
  Log:
  o applying patches for MPGENAPP-1
  
  http://jira.codehaus.org/secure/ViewIssue.jspa?key=MPGENAPP-1
  
  Revision  Changes    Path
  1.5       +47 -33    maven-plugins/genapp/plugin.jelly
  
  Index: plugin.jelly
  ===================================================================
  RCS file: /home/cvs/maven-plugins/genapp/plugin.jelly,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- plugin.jelly      25 Nov 2003 15:56:18 -0000      1.4
  +++ plugin.jelly      30 Nov 2003 21:26:26 -0000      1.5
  @@ -25,18 +25,20 @@
             <i:ask question="${maven.genapp.prompt.template}" answer="template" 
default="${maven.genapp.default.template}"/>
           </j:if>
         
  +        <!-- Search the template in the plugin resources at first place -->
  +        <u:available file="${plugin.resources}/${template}">
  +          <j:set var="maven.genapp.template.dir" 
value="${plugin.resources}/${template}"/>
  +        </u:available>
  +      
           <!-- If template is in the user's home directory, use it -->    
           <u:available file="${user.home}/.maven/template/${template}">
             <j:set var="maven.genapp.template.dir" 
value="${user.home}/.maven/template/${template}"/>
           </u:available>
         
  -        <j:set var="currenttemplatedir" value="${maven.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.genapp.template.dir" 
value="${plugin.resources}/${template}"/>
  -          </u:available>
  -        </j:if>
  +        <!-- If template is in a given template repository, use it -->    
  +        <u:available file="${maven.genapp.template.repository}/${template}">
  +          <j:set var="maven.genapp.template.dir" 
value="${maven.genapp.template.repository}/${template}"/>
  +        </u:available>
         </j:if>
         
         <j:set var="currenttemplatedir" value="${maven.genapp.template.dir}"/>
  @@ -64,34 +66,46 @@
         <u:available file="${maven.genapp.template.dir}/template.properties">
           <u:properties file="${maven.genapp.template.dir}/template.properties"/>
         </u:available>
  -      
  -      <!-- Ensure we have a project id, name, and package -->
  -      
  -      <j:set var="presetid" value="${maven.genapp.template.id}"/>
  -      <j:if test="${empty(presetid)}">
  -        <i:ask question="${maven.genapp.prompt.id}" 
answer="maven.genapp.template.id" default="${maven.genapp.default.id}"/>
  -      </j:if>
  -      
  -      <j:set var="presetname" value="${maven.genapp.template.name}"/>
  -      <j:if test="${empty(presetname)}">
  -        <i:ask question="${maven.genapp.prompt.name}" 
answer="maven.genapp.template.name" default="${maven.genapp.default.name}"/>
  -      </j:if>
  -      
  -      <j:set var="presetpackage" value="${maven.genapp.template.package}"/>
  -      <j:if test="${empty(presetpackage)}">
  -        <i:ask question="${maven.genapp.prompt.package}" 
answer="maven.genapp.template.package" default="${maven.genapp.default.package}"/>
  -      </j:if>
  -      
  +
  +      <!-- Split variables manually, since jelly does not support this currently. 
-->
  +      <u:tokenize var="maven.genapp.param.split" 
delim=",">${maven.genapp.param}</u:tokenize>
  +
  +      <j:forEach var="var" items="${maven.genapp.param.split}">
  +        <j:set var="varname">maven.genapp.template.${var}</j:set>
  +        <j:set var="presetval" value="${context.findVariable(varname)}"/>
  +        <j:if test="${empty(presetval)}">
  +          <j:set var="varname">maven.genapp.default.${var}</j:set>
  +          <j:set var="defaultval" value="${context.findVariable(varname)}"/>
  +          <j:set var="varname">maven.genapp.prompt.${var}</j:set>
  +          <j:set var="prompt" value="${context.findVariable(varname)}"/>
  +          <j:if test="${empty(prompt)}">
  +            <j:set var="maven.genapp.template.${var}" value="${defaultval}"/>
  +          </j:if>
  +          <j:if test="${!empty(prompt)}">
  +            <i:ask question="${prompt}" answer="maven.genapp.template.${var}" 
default="${defaultval}"/>
  +          </j:if>
  +        </j:if>
  +        <j:invoke method="toUpperCase" on="${var}" var="placeholder" />
  +        <j:set var="varname">maven.genapp.template.${var}</j:set>
  +        <j:set var="value" value="${context.findVariable(varname)}"/>
  +        <filter token="${placeholder}" value="${value}"/>
  +      </j:forEach>
  +
  +      <!-- Show used variables for template -->
  +      <ant:echo>Parameters used in template:</ant:echo>
  +      <j:forEach var="var" items="${maven.genapp.param.split}">
  +        <j:set var="varname">maven.genapp.template.${var}</j:set>
  +        <j:set var="value" value="${context.findVariable(varname)}"/>
  +        <j:invoke method="toUpperCase" on="${var}" var="placeholder" />
  +        <ant:echo>${varname} (${placeholder}):${value}</ant:echo>
  +      </j:forEach>
  +
         <!-- Turn the specified package into a path -->
         <u:replace var="appPath" oldChar="." newChar="/" 
value="${maven.genapp.template.package}"/>
  -      
  -      <!-- We want to substitute in the id, name, and package name. -->
  -      <filter token="ID" value="${maven.genapp.template.id}"/>
  -      <filter token="NAME" value="${maven.genapp.template.name}"/>
  -      <filter token="PACKAGE" value="${maven.genapp.template.package}"/>
  -  
  -      <!-- split the list of dirs that need repackaged -->
  +
  +      <!-- split variables manually, since jelly does not support this currently. 
-->
         <u:tokenize var="maven.genapp.repackage.split" 
delim=",">${maven.genapp.repackage}</u:tokenize>
  +      <u:tokenize var="maven.genapp.filter.split" 
delim=",">${maven.genapp.filter}</u:tokenize>
     
         <!-- copy resources that need repackaged, eg java files -->
         <j:forEach var="res" items="${maven.genapp.repackage.split}">
  @@ -104,7 +118,7 @@
         <!-- copy resources that just need filtered, eg project.xml -->
         <ant:copy todir="${basedir}" filtering="true">      
           <ant:fileset dir="${maven.genapp.resources}">
  -          <j:forEach var="res" items="${maven.genapp.filter}">
  +          <j:forEach var="res" items="${maven.genapp.filter.split}">
               <include name="${res}"/>
             </j:forEach>
           </ant:fileset>
  
  
  
  1.2       +15 -13    maven-plugins/genapp/plugin.properties
  
  Index: plugin.properties
  ===================================================================
  RCS file: /home/cvs/maven-plugins/genapp/plugin.properties,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- plugin.properties 25 Aug 2003 09:43:14 -0000      1.1
  +++ plugin.properties 30 Nov 2003 21:26:26 -0000      1.2
  @@ -1,13 +1,15 @@
  -maven.genapp.resources=${plugin.resources}/default
  -
  -maven.genapp.prompt.template=Enter a project template to use:
  -
  -maven.genapp.prompt.id=Please specify an id for your application: 
  -maven.genapp.prompt.name=Please specify a name for your application: 
  -maven.genapp.prompt.package=Please specify the package for your application: 
  -
  -maven.genapp.default.template=default
  -
  -maven.genapp.default.id=app
  -maven.genapp.default.name=Example Application
  -maven.genapp.default.package=example.app
  \ No newline at end of file
  +maven.genapp.prompt.template=Enter a project template to use:
  +maven.genapp.default.template=default
  +
  +maven.genapp.param=id,name,package,user
  +
  +maven.genapp.default.id=app
  +maven.genapp.prompt.id=Please specify an id for your application: 
  +
  +maven.genapp.default.name=Example Application
  +maven.genapp.prompt.name=Please specify a name for your application: 
  +
  +maven.genapp.default.package=example.app
  +maven.genapp.prompt.package=Please specify the package for your application: 
  +
  +maven.genapp.default.user=${user.name}
  
  
  
  1.15      +8 -2      maven-plugins/genapp/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/maven-plugins/genapp/project.xml,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- project.xml       10 Oct 2003 19:21:00 -0000      1.14
  +++ project.xml       30 Nov 2003 21:26:26 -0000      1.15
  @@ -1,11 +1,11 @@
  -<?xml version="1.0" encoding="UTF-8"?>
  +<?xml version="1.0" encoding="ISO-8859-1"?>
   
   <project>
     <extend>../project.xml</extend>
     <pomVersion>3</pomVersion>
     <id>maven-genapp-plugin</id>
     <name>Maven Genapp Plugin</name>
  -  <currentVersion>2.0</currentVersion>
  +  <currentVersion>2.1-SNAPSHOT</currentVersion>
     <shortDescription>A collection of example projects showing how to use maven in 
different situations</shortDescription>
     <url>http://maven.apache.org/reference/plugins/genapp/</url>
     <siteDirectory>/www/maven.apache.org/reference/plugins/genapp/</siteDirectory>
  @@ -38,6 +38,12 @@
       <contributor>
         <name>Ryan Hoegg</name>
         <email>[EMAIL PROTECTED]</email>
  +    </contributor>
  +    <contributor>
  +      <name>J�rg Schaible</name>
  +      <id>joehni</id>
  +      <email>[EMAIL PROTECTED]</email>
  +      <organization>Elsag-Solutions AG</organization>
       </contributor>
     </contributors>
     <dependencies>
  
  
  
  1.4       +31 -0     maven-plugins/genapp/xdocs/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/maven-plugins/genapp/xdocs/changes.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- changes.xml       29 Sep 2003 06:18:40 -0000      1.3
  +++ changes.xml       30 Nov 2003 21:26:26 -0000      1.4
  @@ -5,6 +5,37 @@
       <author email="[EMAIL PROTECTED]">dIon Gillard</author>
     </properties>
     <body>
  +    <release version="2.1" date="SNAPSHOT">
  +      <action dev="joehni" type="add">
  +        Support of configuration files in the template starting 
  +        with a dot (e.g. .cvsignore).
  +      </action>
  +      <action dev="joehni" type="fix">
  +        Fix usage of explicit template provided with the property
  +        maven.genapp.template.dir. Suppress question for template
  +        name, since it is implicit.
  +      </action>
  +      <action dev="joehni" type="add">
  +        Add property maven.genapp.template.repository to support
  +        a user-defined location for own templates. This allows a
  +        CVS-based template management for a company.
  +      </action>
  +      <action dev="joehni" type="fix">
  +        Fix usage of a comma-separated string as value for property
  +        maven.genapp.filter to define multiple files.
  +      </action>
  +      <action dev="joehni" type="add">
  +        Add property maven.genapp.template.user to support the
  +        user's account name in the filter with @[EMAIL PROTECTED] The default
  +        value is the system property user.name.
  +      </action>
  +      <action dev="joehni" type="add">
  +        Support user-defined parameters for filtering.
  +      </action>
  +      <action dev="joehni" type="update">
  +        Update and improve documentation for properties.
  +      </action>
  +    </release>
       <release version="2.0" date="2003-09-29">
         <action dev="evenisse" type="update">
           Add a taglib for use the generation in other plugins.
  
  
  
  1.3       +141 -76   maven-plugins/genapp/xdocs/properties.xml
  
  Index: properties.xml
  ===================================================================
  RCS file: /home/cvs/maven-plugins/genapp/xdocs/properties.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- properties.xml    25 Aug 2003 09:43:14 -0000      1.2
  +++ properties.xml    30 Nov 2003 21:26:26 -0000      1.3
  @@ -1,76 +1,141 @@
  -<?xml version="1.0" encoding="ISO-8859-1"?>
  -<document>
  -
  -  <properties>
  -    <title>Properties</title>
  -    <author email="[EMAIL PROTECTED]">dIon Gillard</author>
  -  </properties>
  -
  -  <body>
  -    <section name="Application Generation Settings">
  -      <div>Some of these properties are prompted for when the plugin runs, if not 
already specified.</div>
  -      <table>
  -        
<tr><th>Property</th><th>Optional?</th><th>Description</th><th>Default</th></tr>
  -        <tr>
  -          <td>maven.genapp.template</td>
  -          <td>Yes</td>
  -          <td>
  -            Specifies the template to use when generating the application.
  -            If this property is not defined, the user will be prompted.
  -          </td>
  -          <td>
  -             default
  -          </td>
  -        </tr>
  -        <tr>
  -          <td>maven.genapp.template.dir</td>
  -          <td>No</td>
  -          <td>
  -            Specifies the template directory to use when generating the application.
  -            Usually set based on the maven.genapp.template chosen.  Users can 
override
  -            this property and maven.genapp.template (which will then go unused)
  -            in order to use a custom template directory.  This can be useful for 
other
  -            plugins.
  -          </td>
  -          <td>
  -             Specified by the template.
  -          </td>
  -        </tr>
  -        <tr>
  -          <td>maven.genapp.template.id</td>
  -          <td>Yes</td>
  -          <td>
  -            Specifies the id of the application to be generated
  -            If this property is not defined, the user will be prompted.
  -          </td>
  -          <td>
  -            app
  -          </td>
  -        </tr>
  -        <tr>
  -          <td>maven.genapp.template.name</td>
  -          <td>Yes</td>
  -          <td>
  -            Specifies the name of the application to be generated
  -            If this property is not defined, the user will be prompted.
  -          </td>
  -          <td>
  -            Example Application
  -          </td>
  -        </tr>
  -        <tr>
  -          <td>maven.genapp.template.package</td>
  -          <td>Yes</td>
  -          <td>
  -            Specifies the name of the Java package that code will be
  -            generated for.
  -            If this property is not defined, the user will be prompted.
  -          </td>
  -          <td>
  -            example.app
  -          </td>
  -        </tr>
  -      </table>
  -    </section>
  -  </body>
  -</document>
  +<?xml version="1.0" encoding="ISO-8859-1"?>
  +<document>
  +
  +  <properties>
  +    <title>Properties</title>
  +    <author email="[EMAIL PROTECTED]">dIon Gillard</author>
  +  </properties>
  +
  +  <body>
  +    <section name="General Application Generation Settings">
  +      <p>
  +        In addition to the default property files read while processing a
  +        plugin, genapp uses on top a template specific property file.  This
  +        will be read after the plugin has found the template specified by
  +        the user.  Since all the property files share the same namespace
  +        you can define any of the properties below anywhere. But typically
  +        you will have properties specific for each template.
  +      </p>
  +      <table>
  +        <tr><th>Property</th><th>Description</th><th>Default</th></tr>
  +        <tr>
  +          <td>maven.genapp.filter</td>
  +          <td>
  +            Specifies the files (comma-separated list) that have to be copied
  +            into the new project after they have been filtered.  The filtering
  +            replaces placeholders with properties (see below).
  +          </td>
  +          <td>java,test</td>
  +        </tr>
  +        <tr>
  +          <td>maven.genapp.param</td>
  +          <td>
  +            Specifies the filter parameters (comma-separated list).  See
  +            filtering rules below and a descitpion of the default parameters.
  +          </td>
  +          <td>id,name,package,user</td>
  +        </tr>
  +        <tr>
  +          <td>maven.genapp.repackage</td>
  +          <td>
  +            Specifies the directories (comma-separated list) with files to
  +            build a Java package.  Genapp will copy the files into the new 
  +            project according the path rules for packages.  The package is
  +            defined with the property maven.genapp.template.package. The
  +                     files are not only copied, but also filtered.
  +          </td>
  +          <td>project.xml</td>
  +        </tr>
  +        <tr>
  +          <td>maven.genapp.template</td>
  +          <td>
  +            Specifies the template to use when generating the application.
  +            If this property is not defined, the user will be prompted with
  +            the default value from property maven.genapp.default.template.
  +          </td>
  +          <td>default</td>
  +        </tr>
  +        <tr>
  +          <td>maven.genapp.template.dir</td>
  +          <td>
  +            Specifies the template directory to use when generating the application.
  +            Usually set based on the maven.template.repository and 
maven.genapp.template
  +            chosen.  Users can override this property in order to use a custom 
template
  +            directory.  meven.template.repository and maven.genapp.template will 
then go
  +            unused.  This can be useful for other plugins.
  +          </td>
  +          <td>n/a</td>
  +        </tr>
  +        <tr>
  +          <td>maven.genapp.template.repository</td>
  +          <td>
  +            Specifies a directory that has additional templates. If this property
  +            is not defined, the template will be searched in the local Maven 
directory
  +            or in the resources of the plugin itself.
  +          </td>
  +          <td>
  +            ${maven.home.local}/template
  +          </td>
  +        </tr>
  +      </table>
  +    </section>
  +    <section name="Application Generation Filter Settings">
  +      <p>
  +        Generating a project from a template a lot of parameters can be useful for 
the
  +        template depending on the organisation using them.  Genapp has some 
predefined
  +        parameters described in the table below.  Each parameter makes usage of some
  +        properties following a naming scheme and can be declared interactive i.e. 
the
  +        user generating an application from a template will be asked for the 
parameter's
  +        value.  The property maven.genapp.param declares all available parameters 
for
  +        the filtering.  During the project generation the filter uses the 
properties 
  +        that follow the naming scheme maven.genapp.template.&lt;param&gt;. It is 
always
  +        possible to overwrite these values.  The default value is always defined by 
a
  +        property named maven.genapp.default.&lt;param&gt;.  If the value should be
  +        enetered interactive, you can define the prompt with a property
  +        maven.genapp.prompt.&lt;param&gt;.  The filter itself is used copying the 
files
  +        defined by maven.genapp.repackage and maven.genapp.filter and will replace 
any
  +        occurrence of @&lt;PARAM&gt;@ in the files with the value of
  +        maven.genapp.template.&lt;param&gt;.
  +      </p>
  +      <table>
  +        
<tr><th>Property</th><th>Description</th><th>Default</th><th>Prompted</th></tr>
  +        <tr>
  +          <td>maven.genapp.template.id</td>
  +          <td>
  +            Specifies the id of the application to be generated
  +            If this property is not defined, the user will be prompted.
  +          </td>
  +          <td>app</td>
  +          <td>Yes</td>
  +        </tr>
  +        <tr>
  +          <td>maven.genapp.template.name</td>
  +          <td>
  +            Specifies the name of the application to be generated
  +            If this property is not defined, the user will be prompted.
  +          </td>
  +          <td>Example Application</td>
  +          <td>Yes</td>
  +        </tr>
  +        <tr>
  +          <td>maven.genapp.template.package</td>
  +          <td>
  +            Specifies the name of the Java package that code will be
  +            generated for.
  +            If this property is not defined, the user will be prompted.
  +          </td>
  +          <td>example.app</td>
  +          <td>Yes</td>
  +        </tr>
  +        <tr>
  +          <td>maven.genapp.template.user</td>
  +          <td>
  +            Specifies the user's account name.
  +          </td>
  +          <td>${user.name}</td>
  +          <td>No</td>
  +        </tr>
  +      </table>
  +    </section>
  +  </body>
  +</document>
  
  
  

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

Reply via email to