If you're curious about making a plugin for JAXB, you could take a look at the XMLBeans plugin -- similar pattern. http://github.com/apache/buildr/blob/trunk/addon/buildr/xmlbeans.rb
<http://github.com/apache/buildr/blob/trunk/addon/buildr/xmlbeans.rb>alex On Sat, Aug 28, 2010 at 5:53 AM, Mark Petrovic <[email protected]> wrote: > Thanks. > > That's a goodly chunk of information. I understand the concept of changing > the layout, and why you might want to do it to add source code paths to the > defaults for compile. But for the JAXB XJC operation specifically, I need > some processing to happen before compile happens, namely the XSD file has to > be processed to produce JAXB Java classes. Where does that happen in the > scheme below? Maybe you are speaking to a more general point, where the > question doesn't actually operate. > > One thing that could be generalized with respect to the inline JAXB task is > to parametrize the task with respect to the location of the XSD file so > other projects can use it. Hmm. > > On Aug 27, 2010, at 9:15 AM, Ed Smiley wrote: > > > 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 = Layout.new > > 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 > > package(:jar) > > end > > > > 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 > > prints") > > That might be an easier way fo running JAXB. > > > > > > On Thu, Aug 26, 2010 at 6:53 PM, Mark Petrovic <[email protected]> > 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=>"com.sun.tools.xjc.XJCTask", :classpath=>"#{t}" > >> ant.xjc :schema=>"src/main/resources/c.xsd", > >> :destdir=>"#{xjcOutput}", :package=>"org.foo.api" > >> 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 > >> http://www.mail-archive.com/[email protected]/msg01115.html 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 > >> > >> > >> > > > -- > Mark Petrovic > > >
