On Mon, Aug 1, 2011 at 4:58 PM, Matteo Vaccari <[email protected]> wrote:
>
> Hi,
> I'm new to Buildr; I'd really want to use it for my project, but I'm running 
> into a couple of problems with dependent projects, and I would be very 
> grateful if you could lend me a hand.
> It boils down to this: if you have a simple setup like
> define 'problematic', :version => '0.0' do
>   define 'foo' do
>     package :jar
>   end
>
>   define 'bar' do
>     compile.with project('foo')
>   end
> end
> where both projects are Java project.
> Problem one: it will only work if project 'foo' is packaged as a jar.  Is 
> there a way to make it work when 'foo' is packaged as a war?  Because when 
> you package 'foo' as a war, the compile task for 'bar' fails.
> Problem two: suppose project 'bar's test classes need to be compiled with 
> project 'foo's test classes.  I see in the wiki there's a suggested workaround
> define "A" do
>   package(:jar)
> end
> define "B" do
>   compile.with project("A")
>   test.with project("A").test.compile.target  # <---- HERE
>   package(:jar)
> end
> This works for the compile task, but it breaks the eclipse task.  It turns 
> out that the generated .classpath contains an entry like
>   <classpathentry 
> path="/Users/matteo/work/problematic/foo/target/test/classes" kind="src" 
> excluding="**/.svn/|**/CVS/"/>
> that does not work in Eclipse.
> What can I do?

OK, I found a sort-of solution for both problems:

define 'problematic' do
  define 'foo' do
    package :war
  end

  define 'bar' do
    foo_src = project('foo').compile.target
    foo_test = project('foo').test.compile.target
    compile.with project('foo'), foo_src, foo_test
    eclipse.exclude_libs += [foo_src, foo_test]
  end
end

The first entry in compile.with is used by the eclipse task, to set up
the correct dependency on 'foo'.  The other two are used by the
compile task.  The eclipse.exclude_libs fixes the incorrect entries in
.classpath.

What do you think?

Matteo

Reply via email to