Ruby can use instance_eval to do this. Use instance_eval inside a method to which you pass arguments to define projects dynamically.
If you are repackaging jars as OSGi, don't forget to check out Eclipse Orbit! Thanks, Antoine On Fri, Mar 19, 2010 at 16:49, Peter Donald <[email protected]> wrote: > Hi, > > My current usage of buildr has resulted in many subprojects. Some of > these subprojects actually have no files as they simply repackaging > jars as OSGi bundles (i.e. jars + more metadata). So I have decided to > have a central "target" directory under which each project has a dir. > i.e. The following snippet uses target/A and target/B as intermediate > dirs of each project > > class CentralLayout < Layout::Default > def initialize(key, top_level = false) > super() > prefix = top_level ? '' : '../' > self[:target] = "#{prefix}target/#{key}" > self[:target, :main] = "#{prefix}target/#{key}" > end > end > > define 'A', :layout => CentralLayout.new('A', true) do > ... > define 'B', :layout => CentralLayout.new('B') do > ... > end > end > > Unfortunately I have to repeat the name of the project when > constructing the layout. Is there any easy way to avoid this? The only > way that I could think of is to make it an extension which is overkill > atm (However I suspect by the time I reach the 20 or so subprojects it > may be worthwhile). > > So is this the way you should do this sort of thing? Or any other > suggestions? > > -- > Cheers, > > Peter Donald >
