Search code examples
wicketembedded-jettybuildr

How to package html files into jar/war with buildr?


I'm working on an embedded Jetty + Wicket app and I'm using buildr. Right now, Buildr isn't including the HTML files (which are in the main source folder, alongside my *.java files) in the jar. How can I tell buildr to include them in the compilation/package step?

Thanks for the suggestions, I think I'm close. Maybe the question I should be asking is how to get the .HTML files into the right place in the target/classes/ subdirectory? I've confirmed that if I can get the .html files in the target/classes folder, package(:jar) archives them. I'm going to start looking at that.


Solution

  • Thanks for the suggestions, I think I'm close. Maybe the question I should be asking is how to get the .HTML files into the right place in the target/classes/ subdirectory? I've confirmed that if I can get the .html files in the target/classes folder, package(:jar) archives them. I'm going to start looking at that.

    It sounds like what you want to do, then, is treat the java source paths as resource paths. Here's how I do that in a project I converted to buildr after it was already pretty large:

    # Uses before_define to default all projects to including their resources from
    # src/main/java instead of src/main/resources (& similar for test) if
    # those source directories exist
    module InlineResources
      include Buildr::Extension
    
      before_define do |p|
        [
          [p.resources, p._("src/main/java")],
          [p.test.resources, p._("src/test/java")]
        ].each do |res, path|
          if File.exist?(path)
            res.from(path).exclude("**/*.java")
          end
        end
      end
    end
    
    class Buildr::Project
      include InlineResources
    end
    

    This will put the *.html files in target/resources and from there they will be added to the package.