buildr-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ed Smiley <>
Subject Re: Newbie classpath question
Date Fri, 27 Aug 2010 16:15:56 GMT
As you intuitively know, you don't really need to use ant to do much of
anything inside Buildr.

By changing the settings for the target and source you can take care of the
file management automatically.  Cleaning, rebuilding, dependencies etc. By
setting compile with, you can add all your dependencies.

Here's an example:

To set the target and source, you define a "layout" which reassigns the
defaults, for example, to change your Java source to src/, and to use a
custom built_dir/ target directory,

  my_layout =
  my_layout[:source, :main, :java] = 'src'
  my_layout[:target, :main] = 'build_dir'
Then make your project use it:

define "myproject" , *:layout=>my_layout *do

to add dependencies,

define an array of libraries and paths, for example
AXIS2 = 'org.apache.axis2:axis2:jar:1.2'
LIB = ["jars/*.jar", AXIS2]

and change the compile directive to use with:


compile.with LIB# Added classpath dependencies

So this will compile and jar using both an external dependency, which will
be automatically downloaded, and your local libraries.  You can pretty much
run Java directly from inside Buildr too: Java.System.out.println("this
That might be an easier way fo running JAXB.

On Thu, Aug 26, 2010 at 6:53 PM, Mark Petrovic <> wrote:

> Hi.  I'm new to Buildr, coming from Ant and Maven.  I've read the black
> Buildr book, and now I'm attempting to do some simple stuff with the JAXB
> XJC task.  Here's what I have so far:
> ...
>    compile :xjc
>    package :jar, :id => 'vzapi'
>    task :xjc do
>          begin
>          ant('xjc') do |ant|
>            xjcOutput='target/generated-sources/xjc'
>            rm_rf "#{xjcOutput}"
>            mkdir_p "#{xjcOutput}"
>  t=Dir.entries("#{ENV['HOME']}/tools/jaxb-ri/lib").join(File::PATH_SEPARATOR)
>            puts t
>            ant.taskdef :name=>"xjc",
> :classname=>"", :classpath=>"#{t}"
>            ant.xjc :schema=>"src/main/resources/c.xsd",
> :destdir=>"#{xjcOutput}", :package=>""
>          end
>        end
>    end
> where you can see my horribly clumsy, two-left-foot attempts to put
> together a classpath for the Ant taskdef.  The JAXB jars are in
> ENV['HOME']}/tools/jaxb-ri/lib/*.jar.
> Can someone suggest the "Buildr way" to build this classpath?  I've studied
> the examples referred to here
> but I'm
> still not quite getting it.  I'm learning Ruby as I go, having read the
> Pickaxe book, but where not a lot of it has sunk in yet.
> Thanks!
> --
> Mark Petrovic

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