You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@buildr.apache.org by Ingo Schmidt <an...@der-ingo.de> on 2008/02/04 11:27:16 UTC

Merging questions

Hi!

I have yet another problem:
I have a few projects that are most of the time all the same, so they can be built from a template and in the end just a few files will be overwritten with project specific ones.
MY_TEMPLATE is a WAR file installed in local repository and contains:
jsp/screens/de/main.jsp
jsp/screens/de/page1.jsp
jsp/screens/de/page2.jsp
MY_PROJECT contains:
src/main/webapp/jsp/screens/de/page1.jsp

So as final result I want to have main.jsp and page2.jsp from MY_TEMPLATE and page1.jsp from MY_PROJECT. So my first try was sth like this:
----------------------------
desc "My Project"
define "my_project" do
    define "my_war-war" do
        package(:war).merge(artifacts(MY_TEMPLATE))
    end
[...]
end
----------------------
But this doesn't work. All files will be taken from MY_TEMPLATE. And I am not too surprised. So let's change the merge line like so:
        package(:war).merge(artifacts(MY_TEMPLATE)).exclude("jsp/screens/de/page1.jsp")

Now I got what I want. So where is the problem?
The problem is, that my real life project is not that simple. It contains many jsp files that should replace the ones in the template. I was hoping to use something like this:
        jsp = FileList[_("src/main/webapp/**/*.jsp")].map { |fn| fn.gsub(_("src/main/webapp")+"/","")}
        package(:war).merge(artifacts(MY_TEMPLATE)).exclude(jsp)

Very unfortunately, the exclude method doesn't seem to accept arrays. So I tried it like this:
    jsp = FileList[_("src/main/webapp/**/*.jsp")].map { |fn| fn.gsub(_("src/main/webapp")+"/","")}
    zip("temp.zip").merge(artifact(MY_TEMPLATE))
    jsp.each do |file|
      zip("temp.zip").exclude(file)
    end
    package(:war).merge(zip("temp.zip"))

But files cannot be excluded like this form a zip it seems.

I am a bit stuck now. How do I achieve what I want to do?

Again, thanks in advance for any help.


Cheers, Ingo =;->

Re: Merging questions

Posted by Victor Hugo Borja <vi...@gmail.com>.
Ingo,


So as final result I want to have main.jsp and page2.jsp from MY_TEMPLATE
> and page1.jsp from MY_PROJECT. So my first try was sth like this:
> ----------------------------


Could you try the following, downside: creates two wars for my_project, the
normal one and the complete merge with content from MY_TEMPLATE


>
> desc "My Project"
> define "my_project" do
>    define "my_war-war" do

           complete = package(:zip, :id => "#{id}-complete", :type => :war)
           artifacts(MY_TEMPLATE).each { |archive| complete.merge(archive) }
           # merge has the same semantics than Hash#merge, it overwrites old
entries with those on merge' argument
           complete.merge(package(:war)) # Finally, add the jsps, classes
for this project at the end.

>    end
> [...]
> end
>


Greetings!
-- 
vic

Quaerendo invenietis.