Search code examples
ruby-on-railsjrubywarbler

Adding custom files to war file


I'm trying to add additional files to a war file (VERSION and REVISION file) using RoR/warbler. The VERSION file would be similar to what capistrano creates so each file would need to be created during the war creation. Does anyone have any suggestions? I was looking at creating custom warbler FEATURES but can't find any documentation about it. Thanks in advance.


Solution

  • To answer my own question, this is what I did:

    Really most of the magic was done in a rake task:

    require 'warbler'
    Warbler::Task.new
    
    # other tasks
    
    desc "Put the revision that was packaged into RAILS_ROOT/VERSION"
    task :write_revision do
      `cd #{Rails.root} && git rev-parse HEAD > REVISION`
    end
    
    task :war => :write_revision
    

    next I modified the warble.rb config to include the additional files in the war file:

    Warbler::Config.new do |config|
       # ...
       config.includes = FileList["REVISION"]
       # ...
    end
    

    So now whenever I run bundle exec rake war or another task that calls war it will add a REVISION file. The only non-issue is that you can't use the warble command.