You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@buildr.apache.org by Rhett Sutphin <r-...@northwestern.edu> on 2009/02/06 22:11:03 UTC
Resources & post-processing project definitions
Hi,
Synopsis: I'm having a problem with a buildfile where, if I define
the resource paths outside of the initial project definition block,
the resource target directories are not included on the classpath when
running tests. The resources are copied to target (during the compile
and test:compile tasks) and packaged correctly (if I do package
test=no), but they are not visible to the tests.
Details: I am converting an existing project to use buildr. It
stores its resources alongside the code, so in each of the subprojects
I have lines like these:
resources.from(_("src/main/java")).exclude("**/*.java")
test.resources.from(_("src/test/java")).exclude("**/*.java")
Hoping to DRY this up a bit, I replaced those repeated blocks with
this code at the end of my buildfile:
projects.each do |p|
if File.exist?(p._("src/main/java"))
# All resources come from source path
p.resources.from(p._("src/main/java")).exclude("**/*.java")
p.test.resources.from(p._("src/test/java")).exclude("**/*.java")
end
end
This introduced the problem I described in the synopsis. Two questions:
- Is this a bug I should report on the issue tracker? Or is it
expected behavior?
- Is there a better way to do what I'm trying to do?
Thanks,
Rhett
Re: Resources & post-processing project definitions
Posted by Shane Witbeck <sh...@digitalsanctum.com>.
Why not move the non-java files to src/main/resources?
Alternatively, use a custom layout to define the non-standard path.
-Shane
On Fri, Feb 6, 2009 at 4:11 PM, Rhett Sutphin <r-...@northwestern.edu>wrote:
> Hi,
>
> Synopsis: I'm having a problem with a buildfile where, if I define the
> resource paths outside of the initial project definition block, the resource
> target directories are not included on the classpath when running tests.
> The resources are copied to target (during the compile and test:compile
> tasks) and packaged correctly (if I do package test=no), but they are not
> visible to the tests.
>
> Details: I am converting an existing project to use buildr. It stores its
> resources alongside the code, so in each of the subprojects I have lines
> like these:
>
> resources.from(_("src/main/java")).exclude("**/*.java")
> test.resources.from(_("src/test/java")).exclude("**/*.java")
>
> Hoping to DRY this up a bit, I replaced those repeated blocks with this
> code at the end of my buildfile:
>
> projects.each do |p|
> if File.exist?(p._("src/main/java"))
> # All resources come from source path
> p.resources.from(p._("src/main/java")).exclude("**/*.java")
> p.test.resources.from(p._("src/test/java")).exclude("**/*.java")
> end
> end
>
> This introduced the problem I described in the synopsis. Two questions:
>
> - Is this a bug I should report on the issue tracker? Or is it expected
> behavior?
>
> - Is there a better way to do what I'm trying to do?
>
> Thanks,
> Rhett
>