Changing project template or generator

5 views
Skip to first unread message

Devboy

unread,
May 6, 2011, 6:00:36 PM5/6/11
to ProjectSprouts
Hi guys,

I am wondering what would be the best way to change the project
generator to a maven-style directory-structure?
Would other generators, like class-generators, be able to work with
different directory-structures?

Cheers,
Dominic

Simon Bailey

unread,
May 6, 2011, 6:54:04 PM5/6/11
to project...@googlegroups.com
Hi Dominic,

Maybe trial out building a custom generator (I did a post on this http://www.newtriks.com/?p=1084), hopefully the class generators would still be cool?

Cheers,

Simon


--
You received this message because you are subscribed to the Google Groups "ProjectSprouts" group.
To post to this group, send email to project...@googlegroups.com
To unsubscribe from this group, send email to projectsprout...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/projectsprouts?hl=en

For other info you can visit our project at: http://projectsprouts.org, or on Github at: http://github.com/lukebayes/project-sprouts



--
Kind Regards,

Simon Bailey


newtriks.com

Dominic Graefen

unread,
May 7, 2011, 4:53:20 AM5/7/11
to project...@googlegroups.com
Hi Simon,

I came across your post and was not sure if thats what I was looking for.

It looks like the project-generator is baked into the sprout-as3 command.
So i would need to create a new command.

I also saw that options are available, like --src & --test to specify the paths,
but I would have to append them to every generator i want to use.

In buildr we use so called Layouts to define different directory structures for projects:

That might be a nice addon for sprouts.

-- 
Dominic Graefen

Luke Bayes

unread,
May 9, 2011, 2:45:48 AM5/9/11
to project...@googlegroups.com
Hey Dominic,

There isn't a great solution to this problem in Sprouts yet. As you found, you have 2 options today.

  1) Create a custom project generator, and then custom class, test and suite generators.
  2) Pass those same arguments every time you call a generator.

Some additional options that I've considered (and various combinations and permutations) are:

  1) Serialize any parameters that are used on a project generator and use those values as the defaults for any subsequent generator runs within the project. This seemed reasonably simple to implement and understand, but suffers from some potentially surprising behavior as you move from one project to another. Then it gets into where to put the serialized generator data...

  2) Provide an option to 'update defaults' on any generator and share defaults per-project and/or per-system, similarly to the templates themselves.

It looks like your layout files provide a DSL for persisting those template values, maybe there's some way to combine your approach with regular command line usage?

Ideas or thoughts welcomed -


Thanks!

Luke

Dominic Graefen

unread,
Jun 15, 2011, 9:11:57 AM6/15/11
to project...@googlegroups.com
Hi Luke,

sorry that I am coming back to this so late.

I would love to have some system in sprouts to support different directory-layouts for projects.
A possibility to achieve this would be through the use of configuration files in the project directory,
maybe project/.sprouts/config.rb. If that file is not found we could fallback to ~/.sprouts/config.rb.
Or load both and let the project-config overwrite the system-config. 

I've attached the Layout class from buildr so you can have a look at it.

-- 
Dominic Graefen

layout.rb

Luke Bayes

unread,
Jun 15, 2011, 1:33:41 PM6/15/11
to project...@googlegroups.com
Hey Dominic,

Thanks for following up!

The lateness is actually appreciated as now is a better time (for me) to work on this issue. :-)

I like the direction you're taking with project-specific settings falling back to user account settings.

As far as naming goes, I'd prefer to indicate that these settings are associated with 'generators' rather than just 'sprouts'.

Maybe it could be something like:

[PROJECT]/.sprouts/generator_config.rb
 
For user home settings, I found that it's helpful to store this kind of information behind a versioned folder so that new versions of Sprouts can break compatibility without behaving in unexpected ways. I try hard not to change second-tier revisions unless something significant changed.

So I'd rather see a home dir solution that looks more like:

[USER_HOME]/.sprouts/[SPROUT_VERSION].[SPROUT_REVISION]/generator_config.rb
    e.g. /Users/lbayes/.sprouts/1.1/generator_config.rb

As with Executable locations, we could also support environment vars - which I believe would supersede both of the previous options. Maybe somthing like:

SPROUT_GENERATOR_CONFIG=/path/to/your/config

This could be provided on the command line, exported from .bash_profile/.bashrc or set in the system registry if that's how you roll.

I'm open to other names too... Any ideas appreciated.

I considered:

* generators.rb: This seemed too general to me, I like your use of the 'config' term.
* gen_config.rb: This seemed too terse

Other ideas?

Thanks,

Luke

Dominic Graefen

unread,
Jun 15, 2011, 2:09:28 PM6/15/11
to project...@googlegroups.com
Hey,

my naming and path-directories were just quickly made up and can be changed at your will :)
Versioning the directories is a good idea to keep older versions working.

I wouldn't put the configuration on the generators level, as directory layouts would also matter to the rake builds.
When we got layouts like this we could also split up the generators for source files and Rakefiles/buildfiles, so they can be generated seperatedly,
this would open the door to bring support for other build-systems like Ant, Maven or Buildr.

Personally I like having default locations/directories for application-configs because i don't need to set anything up.
And keeping track of ENV vars is a pain in the ass :) but using it to overwrite the default config is a way for users to do something out-of-the-box.

If you want to team up on this I would love to help out.

Cheers,

-- 
Dominic Graefen

Simon Bailey

unread,
Jun 15, 2011, 2:30:56 PM6/15/11
to project...@googlegroups.com
This all sounds cool, if I can muck-in in any way even if its testing etc please holla as I would like to keep updated on progress of this and I think it would help further my understanding of sprouts plus ruby and rake?

-- 
Cheers,

Simon
Sent with Sparrow
Reply all
Reply to author
Forward
0 new messages