You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildr.apache.org by to...@apache.org on 2017/07/31 03:39:24 UTC

[2/3] buildr git commit: Documentation to packaging doc to document the new concatenate and transform methods

Documentation to packaging doc to document the new concatenate and transform methods


Project: http://git-wip-us.apache.org/repos/asf/buildr/repo
Commit: http://git-wip-us.apache.org/repos/asf/buildr/commit/dbdcaa1b
Tree: http://git-wip-us.apache.org/repos/asf/buildr/tree/dbdcaa1b
Diff: http://git-wip-us.apache.org/repos/asf/buildr/diff/dbdcaa1b

Branch: refs/heads/master
Commit: dbdcaa1bfc08d2c80ccb6eb61d9b13759c66f3e3
Parents: d08c7bc
Author: Antoine Toulme <an...@lunar-ocean.com>
Authored: Sun Jul 30 15:04:43 2017 -0700
Committer: Antoine Toulme <an...@lunar-ocean.com>
Committed: Sun Jul 30 15:04:43 2017 -0700

----------------------------------------------------------------------
 doc/packaging.textile | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/buildr/blob/dbdcaa1b/doc/packaging.textile
----------------------------------------------------------------------
diff --git a/doc/packaging.textile b/doc/packaging.textile
index 318a8c8..6ea599a 100644
--- a/doc/packaging.textile
+++ b/doc/packaging.textile
@@ -142,6 +142,8 @@ For example, when you use @package :jar@, under the hood it specifies to include
 
 If you need to get rid of all the included files, call the @clean@ method. Some packaging types default to adding various files and directories, for example, JAR packaging will include all the compiled classes and resources.
 
+h2(#merging). Merging archives
+
 You can also merge two ZIP files together, expanding the content of one ZIP into the other.  For example:
 
 {% highlight ruby %}
@@ -155,6 +157,25 @@ If you need to be more selective, you can apply the include/exclude pattern to t
 package(:zip).merge(_('bigbad.war')).exclude('libs/**/*')
 {% endhighlight %}
 
+h3(#transforming). Transforming files while merging them
+
+You may need to have special treatment for files that you are merging from multiple locations.
+
+If you wish to concatenate the file contents, you can perform the following:
+
+{% highlight ruby %}
+package(:zip).merge(_('part1.zip'), _('part2.zip')).concatenate('META-INF/services/spring.providers')
+{% endhighlight %}
+
+If you need to transform the file contents to assemble the final output, you can work with the @transform@ method.
+The transform method takes a block to process the contents of all the matching paths, as the zip file is assembled.
+
+{% highlight ruby %}
+package(:zip).merge(_('part1.zip'), _('part2.zip')).transform('plugin.xml') do |plugin_xml_files|
+  return "<plugin>#{plugin_xml_files.map {|xml| xml.match('<plugin>(.*)</plugin>')[1]}}</plugin>"
+end
+{% endhighlight %}
+
 
 h2(#jar). Packaging JARs