I'm trying to use a code generator inside a buildr-based java project. I would like to...
I've spend lots of time googling around for a complete example, but to no avail. the example here: https://cwiki.apache.org/confluence/display/BUILDR/How+to+generate+sources+before+compilation
gives be plenty of errors. this is what I've tried:
define 'generator' do
compile.with ALL_COMMON_MODULES
end
define 'extras' do
p 'calling generator..'
Java.classpath << ALL_COMMON_MODULES
Java.classpath << projects('generator')
Java.org.foo.generator.Main.main(['../modules/daos', 'target/generated-sources'])
sources = FileList[_("src/main/jeannie/*.*")]
generate = file(_("target/generated-sources") => sources).to_s do |dir|
puts 'generating...'
mkdir_p dir.to_s # ensure directory is created
end
compile.from generate
end
gives me an error like this:
RuntimeError: Circular dependency detected: TOP ...
so I'm obviously doing something very very wrong. I'd be very glad to see a working example or project that uses code generation.
I finally got it working with help from the buildr mailinglist. for anyone interested: The example mentioned here contains a problem. this:
compile.from generate
should be:
compile.from generate.to_s
Now it works beautifully! buildr also automatically extends the .classpath for eclipse (and idea, in case you use that) if 'compile.from' points to another location.