[Suggestion] Artifact templates

View: New views
3 Messages — Rating Filter:   Alert me  

[Suggestion] Artifact templates

by mumek2008 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm currently a little bit unhappy with the code generation support for example grails create-domain-class.
For a simple project the current code generation is sufficent, but for more real world projects which will be organized in plugins, the current code generation is not nice.

I need copyright, User name a.s.o. on level grails project/plugin. Some of the projects will be open source, others closed source or different customers. So currently there is a lot of DRY-violation.

br> My suggestions:

  1. Exchange the simple ant replacement in _GrailsCreateArtifact.groovy (ant.replace(... "@artifact.name@", ...)) with a template engine, i.e. Velocity.
  2. Additional values like license, copyright, creational date, creator could be set by something like GRAILS_OPT or set within special grails file (i.e. .options) within the project root included as -D list.
    I would be fancy about three levels:
    1. in the project itself (most specific): extends or overwrite parent directory .options if exists OR $HOME/.grails/.options if exists
    2. in the parent directory above the grails projects (less specific) : extends $HOME/.grails/.options if exists
    3. within the $HOME/.grails directory
  3. If the old templates has been installed ($PRJOJECT_HOME/src/templates/artifacts) , the old one should be taken. But if new templates (extension .vm) has been installed these should be taken.
  4. There is variable point to the template directory, for example:
    -Dgrails.template.dir=$PROJECT_PATH/templates. This give total flexibility which project(s) should use which templates. If this environment variable has been provided grails install-templates uses this environment variable for creating project specific templates or copy the templates from GRAILS_HOME.
  5. It would be nice to add values for replacement like:
    • year of creation. Using for (c) 2009
    • Date format for creational date timestamp.
    • Filename in lower, upper case and the camel case name with and without extension
    • Artifact name in lower, upper case and the camel name


Examples:

1. Content of .options
  GRAILS_OPT="-grails.template.dir=D$HOME/.grails/templates/artifacts -Duser.name='Marko (markol@mymail.com)' -Dcopyright='Mumek Software' $GRAILS_OPT"


2. Directory structure
  /home/mumek/.grails/.options (-Dgrails.template.dir=$HOME/.grails/templates/artifacts)

  /home/mumek2008/projects/custom1/.options (-Dgrails.template.dir='${baseDir}/../templates/artifacts')
  /home/mumek2008/projects/custom1/prj1/.options : uses this options
  /home/mumek2008/projects/custom1/prj2 : uses /home/mumek2008/projects/custom1/.options 
 
  /home/mumek2008/projects/custom2/proj : uses /home/mumek/.grails/.options settings

 /home/mumek2008/projects/custom3/oldgrails/src/templates/artifacts/*.groovy exists: The old templates will be used (even /home/mumek2008/.grails/.options exists)




This kind of template managment are convenient using a version control system (VCS), 'cause the .options files and the templates could be stored within the VCS.

What do you think about it? It's worth the development or are there a different solution already available. Did I miss something important (an unexpected dependency).

I started changing _GrailsCreateArtifact.groovy and grailsStart script.

Regards Marko

Re: [Suggestion] Artifact templates

by Richard Vowles :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Although I agree with you  that the basic template is not hugely useful beyond a demo, I think that is intentional.

Simply typing grails install-templates and then customizing them (as per your rules below) would seem to suffice. I do that on all non-trivial Grails projects I implement.

Making the current template simpler I would agree with, making it more complex I would shy away from.

Richard

On Fri, Jul 3, 2009 at 4:22 AM, mumek2008 <marko.umek@...> wrote:
I'm currently a little bit unhappy with the code generation support for example grails create-domain-class.
For a simple project the current code generation is sufficent, but for more real world projects which will be organized in plugins, the current code generation is not nice.

I need copyright, User name a.s.o. on level grails project/plugin. Some of the projects will be open source, others closed source or different customers. So currently there is a lot of DRY-violation.


--
---
Richard Vowles,
Talk to me about development in Grails, Groovy, Java and for the Blackberry
ph: +64275467747, linkedin, skype:rvowles
get 2Gb shared disk space in the cloud - Dropbox, its incredibly useful! - http://tinyurl.com/cmcceh
podcast: http://www.illegalargument.com

Re: [Suggestion] Artifact templates

by Pablo Iaria :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

In our company we did that (changing the templetes) so that we
generate artifacts for Meteora (http://meteora.astrata.com.mx/) and
Calendula widgets (http://code.google.com/p/calendula-widgets/).

Now when we type the command "grails generate-all domain-class" we get
a full ajax user interface using those widgets.

Saludos,
Pablo.-


On Thu, Jul 2, 2009 at 5:47 PM, Richard
Vowles<richard@...> wrote:

> Although I agree with you  that the basic template is not hugely useful
> beyond a demo, I think that is intentional.
>
> Simply typing grails install-templates and then customizing them (as per
> your rules below) would seem to suffice. I do that on all non-trivial Grails
> projects I implement.
>
> Making the current template simpler I would agree with, making it more
> complex I would shy away from.
>
> Richard
>
> On Fri, Jul 3, 2009 at 4:22 AM, mumek2008 <marko.umek@...> wrote:
>>
>> I'm currently a little bit unhappy with the code generation support for
>> example grails create-domain-class.
>> For a simple project the current code generation is sufficent, but for
>> more real world projects which will be organized in plugins, the current
>> code generation is not nice.
>>
>> I need copyright, User name a.s.o. on level grails project/plugin. Some of
>> the projects will be open source, others closed source or different
>> customers. So currently there is a lot of DRY-violation.
>>
>
> --
> ---
> Richard Vowles,
> Talk to me about development in Grails, Groovy, Java and for the Blackberry
> ph: +64275467747, linkedin, skype:rvowles
> get 2Gb shared disk space in the cloud - Dropbox, its incredibly useful! -
> http://tinyurl.com/cmcceh
> podcast: http://www.illegalargument.com
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email