You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »

How to generate sources before compilation

Sometimes you need to generate sources files before the compilation task runs.

Here is an example that checks for changes in *.yk files and will trigger code generation and recompilation if they change.


define "generate-sources-example" do

  # whatever you use to generate your sources
  sources = FileList[_("src/main/yak/**/*.yk")]

  generate = file(_("target/generated-source") => sources) do |dir|
    mkdir_p dir.to_s # ensure directory is created
    # generate sources
    # e.g.
    # ant('generate') do |ant|
    #  ...
    # end
  end

  compile.from generate 
end

Note: on Buildr 1.4.6 and earlier, you may need to add .to_s for things to work properly,

  compile.from generate.to_s

(tracked by https://issues.apache.org/jira/browse/BUILDR-609)

  • No labels