buildr-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Boisvert <>
Subject Re: Circular dependency with custom layout
Date Tue, 07 Dec 2010 17:48:57 GMT
On Tue, Dec 7, 2010 at 8:30 AM, Sebastiano Pilla <> wrote:

> I'm trying to use buildr in a multi-module ATG project, and the unit
> testing tool we use requires the test resources to end in the same directory
> as the test classes. I have defined a custom layout such as:
> # define the layout for our projects
> # src/main/java -> classes, src/test/java -> target/test-classes
> # src/test/resources -> target/test-classes
> StandardLayout =
> StandardLayout[:source, :main, :java] = 'src/main/java'
> StandardLayout[:target, :main, :classes] = 'classes'
> StandardLayout[:source, :main, :resources] = 'resources'
> StandardLayout[:source, :test, :java] = 'src/test/java'
> StandardLayout[:source, :test, :resources] = 'src/test/resources'
> StandardLayout[:target, :test, :classes] = 'target/test-classes'
> StandardLayout[:target, :test, :resources] = 'target/test-classes'
> and I have assigned this layout to the project and subproject.
> The problem is that when I run buildr I get the following circular
> dependency error:
> D:\dev\progicommerce\src>%JRUBY_HOME%\bin\jruby -S buildr
> (in D:/dev/progicommerce/src, development)
> D:/dev/progicommerce/src/buildfile:4 warning: already initialized constant
> D:/dev/progicommerce/src/buildfile:7 warning: already initialized constant
> Building ProgiCommerce
> Buildr aborted!
> ←[31mRuntimeError : Circular dependency detected: TOP => default => build
> => ProgiCommerce:build => ProgiCommerce:ATGDUST:build =>
> ProgiCommerce:ATGDUST:test => ProgiCommerce:ATGDUST:test:compile =>
> ProgiCommerce:ATGDUST:test:resources =>
> D:/dev/progicommerce/src/ATGDUST/target/test-classes =>
> ProgiCommerce:ATGDUST:test:compile←[0m
> (See full trace by running task with --trace)
> Is there a way to have my test resources end in target/test-classes along
> with the test classes?

Hi Sebastiano,

It's not currently possible to map both (:target, :test, :resources) and
(:target, :test, :classes) to the same physical directory due to the way
resource copying/filtering is implemented.  Resource dependencies end up
being wired to the destination directory rather than the abstract task (e.g.
project:test:resources).  I think that's a minor design flaw.

You can work around this problem by adding the following to your project,

  task :copy_resources do
    Dir[_('target/test/resources/*')].each { |f| cp_r f,
_('target/test-classes') }
  test.enhance [:copy_resources]

which copies over all test resources (after filtering) into
target/test-classes before tests run.

If you don't want to put this boilerplate in each of your project, you can
turn it into an

module ResourcesInTestClasses
  include Extension

  after_define do |project|
    task :copy_resources do
      Dir[project.path_to('target/test/resources/*')].each do |f|
        cp_r f, project.path_to('target/test-classes')
    project.test.enhance [:copy_resources]

  class Buildr::Project
    include ResourcesInTestClasses

and require this file at the top of your buildfile.

Hope this helps,

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message