You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@buildr.apache.org by Will Rogers <wj...@gmail.com> on 2009/12/20 01:24:23 UTC

buildr + XMLBeans documentation?

I have not been able to find any documentation for buildr's XMLBeans
support other than a short comment within addon/buildr/xmlbeans.rb
itself. That comment got it working for me, but I have more questions.
Is there documentation hiding somewhere?

If not, can anyone help me with these two questions?

1. In the few examples I've been able to find so far on the web, I've
seen buildfiles with "require 'tasks/xmlbeans'", but the documentation
in xmlbeans.rb says to use "require 'buildr/xmlbeans'". What's the
difference? Which is preferred?

2. Is there a way to make a task that generates and compiles the
XMLBeans only, without going on to compile the rest of the project?


Thanks

-- Will

include as is lazy?

Posted by Peter Schröder <ps...@blau.de>.
sorry, i replied to a message...

Am 22.12.2009 um 21:22 schrieb Peter Schröder:

> hi,
> 
> i have some problem understanding the documentation of packaging:
> 
> snip---
> 
> You can also use :as=>'.' to include all files from the given directory. For example:
> 
> package(:zip).include 'target/docs/*'
> package(:zip).include 'target/docs', :as=>'.'
> 
> These two are almost identical. They both include all the files from the target/docs directory, but not the directory itself. But they operate differently. The first line expands to include all the files in target/docs. If you don’t already have files in target/docs, well, then it won’t do anything interesting. Your ZIP will come up empty. The second file includes the directory itself, but strips the path during inclusion. You can define it now, create these files later, and then ZIP them all up.
> 
> ---snip
> 
> i couldnt figure out where there is a difference between the two definitions. 
> 
> this is what i thought should create zips with different content:
> 
>  # this selects all files currently available in the include-directory (and sub-directory)
>  package(:file=>_(:target, 'direct_include.zip')).include('target/resources/*')
>  # this selects the same but not at definition-time but at execution-time
>  package(:file=>_(:target, 'lazy_include.zip')).include('target/resources', :as=>'.')
> 
>  # extend the build-task to write some additional file
>  build do
>    write('target/resources/additional.txt', 'content')
>  end
> 
> feel free to bash on my naive approach ;-)
> 
> happy christmas to everyone


AW: buildr + XMLBeans documentation?

Posted by Peter Schröder <ps...@blau.de>.
hi,

i have some problem understanding the documentation of packaging:

snip---

You can also use :as=>'.' to include all files from the given directory. For example:

package(:zip).include 'target/docs/*'
package(:zip).include 'target/docs', :as=>'.'

These two are almost identical. They both include all the files from the target/docs directory, but not the directory itself. But they operate differently. The first line expands to include all the files in target/docs. If you don’t already have files in target/docs, well, then it won’t do anything interesting. Your ZIP will come up empty. The second file includes the directory itself, but strips the path during inclusion. You can define it now, create these files later, and then ZIP them all up.

---snip

i couldnt figure out where there is a difference between the two definitions. 

this is what i thought should create zips with different content:

  # this selects all files currently available in the include-directory (and sub-directory)
  package(:file=>_(:target, 'direct_include.zip')).include('target/resources/*')
  # this selects the same but not at definition-time but at execution-time
  package(:file=>_(:target, 'lazy_include.zip')).include('target/resources', :as=>'.')
  
  # extend the build-task to write some additional file
  build do
    write('target/resources/additional.txt', 'content')
  end

feel free to bash on my naive approach ;-)

happy christmas to everyone

Re: buildr + XMLBeans documentation?

Posted by Alex Boisvert <al...@gmail.com>.
Hi Will,

On Sat, Dec 19, 2009 at 4:24 PM, Will Rogers <wj...@gmail.com> wrote:

> I have not been able to find any documentation for buildr's XMLBeans
> support other than a short comment within addon/buildr/xmlbeans.rb
> itself. That comment got it working for me, but I have more questions.
> Is there documentation hiding somewhere?
>

No, the XMLBeans plugin is all of 100 lines and essentially just wraps the
Ant task and wires it with the project.   I consider it fairly well
commented but I understand it can look like crazy lingo at first if you are
new to Buildr.

If not, can anyone help me with these two questions?
>
> 1. In the few examples I've been able to find so far on the web, I've
> seen buildfiles with "require 'tasks/xmlbeans'", but the documentation
> in xmlbeans.rb says to use "require 'buildr/xmlbeans'". What's the
> difference? Which is preferred?
>

require 'buildr/xmlbeans' will use the Buildr-provided plugin.

require 'tasks/xmlbeans' will use a project-specific plugin (located under
the 'tasks' directory of your project).   It's possible your project has a
specific version that may have been tweaked.



> 2. Is there a way to make a task that generates and compiles the
> XMLBeans only, without going on to compile the rest of the project?
>

The plugin is composed of 2 parts,

1) the class method XMLBeans.compile() which is just a wrapper around the
Ant task and that you can use directly.  It won't do anything else besides
call the Ant task.

2) the instance method compile_xml_beans() which is mixed-in to the
project.  This one wires things up so that the XMLBeans are generated before
the compile task, and after the compile task is done, the generated files
are copied to the target directory.

(I'm just reading the Ruby source and paraphrasing)

It sounds like you want to use the first one.

Feel free to ask more questions.  Like I said, Buildr can be intimidating at
first but the discoveries are definitely rewarding.

alex