atoulme-Antwrap 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile ADDED
@@ -0,0 +1,49 @@
1
+ # Copyright 2008 Caleb Powell
2
+ # Licensed under the Apache License, Version 2.0 (the "License");
3
+ # you may not use this file except in compliance with the License.
4
+ # You may obtain a copy of the License at
5
+ #
6
+ # http://www.apache.org/licenses/LICENSE-2.0
7
+ #
8
+ # Unless required by applicable law or agreed to in writing, software
9
+ # distributed under the License is distributed on an "AS IS" BASIS,
10
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ # See the License for the specific language governing permissions and limitations
12
+ # under the License.
13
+
14
+ $LOAD_PATH.push(FileUtils::pwd + '/lib')
15
+ require 'rubygems'
16
+ require 'hoe'
17
+ require './lib/antwrap.rb'
18
+ require 'rake/testtask'
19
+
20
+ def apply_default_hoe_properties(hoe)
21
+ hoe.remote_rdoc_dir = ''
22
+ hoe.rubyforge_name = 'antwrap'
23
+ hoe.author = 'Caleb Powell'
24
+ hoe.email = 'caleb.powell@gmail.com'
25
+ hoe.url = 'http://rubyforge.org/projects/antwrap/'
26
+ hoe.summary = 'A Ruby module that wraps the Apache Ant build tool. Antwrap can be used to invoke Ant Tasks from a Ruby or a JRuby script.'
27
+ hoe.description = hoe.paragraphs_of('README.txt', 2..5).join("\n\n")
28
+ hoe.changes = hoe.paragraphs_of('History.txt', 0..1).join("\n\n")
29
+ puts "Current changes in this release_______________ "
30
+ puts "#{hoe.changes}"
31
+ puts "----------------------------------------------"
32
+ end
33
+
34
+ #builds the MRI Gem
35
+ Hoe.new('atoulme-Antwrap', Antwrap::VERSION) do |hoe|
36
+ apply_default_hoe_properties hoe
37
+ hoe.extra_deps << ["rjb", ">= 1.0.3"]
38
+ end
39
+
40
+ #builds the JRuby Gem
41
+ Hoe.new('atoulme-Antwrap', Antwrap::VERSION) do |hoe|
42
+ apply_default_hoe_properties hoe
43
+ hoe.spec_extras = {:platform => 'java'}
44
+ end
45
+
46
+ Rake::TestTask.new('test') do |t|
47
+ t.ruby_opts = ['-r test/load_devcreek.rb']
48
+ t.test_files = ['test/*test.rb']
49
+ end
data/docs/index.html ADDED
@@ -0,0 +1,148 @@
1
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
2
+ <head>
3
+
4
+ <style>
5
+ BODY, P, DIV, H1, H2, H3, H4, H5, H6, ADDRESS, OL, UL, TITLE, TD, OPTION, SELECT {
6
+ font-family: Verdana;
7
+
8
+ }
9
+
10
+ BODY, P, DIV, ADDRESS, OL, UL, LI, TITLE, TD, OPTION, SELECT {
11
+ font-size: 10.0pt;
12
+ margin-top:0pt;
13
+ margin-bottom:0pt;
14
+ }
15
+
16
+ BODY, P {
17
+ margin-left:0pt;
18
+ margin-right:0pt;
19
+ }
20
+
21
+ BODY {
22
+ line-height: ;
23
+ background: #ffffff;
24
+ margin: 6px;
25
+ padding: 0px;
26
+ }
27
+
28
+ h6 { font-size: 10pt }
29
+ h5 { font-size: 11pt }
30
+ h4 { font-size: 12pt }
31
+ h3 { font-size: 13pt }
32
+ h2 { font-size: 14pt }
33
+ h1 { font-size: 16pt }
34
+
35
+ blockquote {padding: 10px; border: 1px #DDDDDD dashed }
36
+
37
+ a img {border: 0}
38
+
39
+ </style>
40
+
41
+
42
+
43
+
44
+ </head>
45
+
46
+
47
+ <body revision="dfd4dds3_4d59vj6:67">
48
+
49
+ <div style="PADDING:8px; BACKGROUND-COLOR:white">
50
+ <h3>
51
+ <b> Antwrap Introduction</b>
52
+ </h3>
53
+ <br>
54
+ Antwrap is a Ruby library that can be used to invoke Ant tasks. It is being
55
+ used in the <a href=http://buildr.rubyforge.org/ title=Buildr>Buildr</a>
56
+ project to execute Ant tasks in a Java project.<br>
57
+ If you are tired of fighting with Ant or Maven XML files in your Java project,
58
+ take some time to check out Buildr!<br>
59
+ Antwrap runs on both the native Ruby and the JRuby interpreters. Antwrap is
60
+ compatible with Ant versions 1.5.4, 1.6.5 and 1.7.0. For more information,<br>
61
+ see the
62
+ <a href=http://rubyforge.org/projects/antwrap/ title="Project Info">Project
63
+ Info</a> page.<br>
64
+ <h3>
65
+ <b>Installing Antwrap</b>
66
+ </h3>
67
+ Installing Antwrap is done via the RubyGem gem command. In your OS shell type;<br>
68
+ <br>
69
+ <div style=MARGIN-LEFT:40px>
70
+ <span style=BACKGROUND-COLOR:#ffffff>$ gem install antwrap </span><br>
71
+ </div>
72
+ <br>
73
+ You will be prompted with the following options:<br>
74
+ <br style=BACKGROUND-COLOR:#ffffff>
75
+ <div style=MARGIN-LEFT:40px>
76
+ <span style=BACKGROUND-COLOR:#ffffff>$Select which gem to install for your
77
+ platform (powerpc-darwin8.0) </span><br style=BACKGROUND-COLOR:#ffffff>
78
+ <span style=BACKGROUND-COLOR:#ffffff>&nbsp;&nbsp;&nbsp; 1. Antwrap 0.6.0
79
+ (java) </span><br style=BACKGROUND-COLOR:#ffffff>
80
+ <span style=BACKGROUND-COLOR:#ffffff>&nbsp;&nbsp;&nbsp; 2. Antwrap 0.6.0
81
+ (ruby)</span><br style=BACKGROUND-COLOR:#ffffff>
82
+ <span style=BACKGROUND-COLOR:#ffffff>&nbsp;&nbsp;&nbsp; 3. Antwrap 0.5.4
83
+ (java) </span><br style=BACKGROUND-COLOR:#ffffff>
84
+ <span style=BACKGROUND-COLOR:#ffffff>&nbsp;&nbsp;&nbsp; 4. Antwrap 0.5.4
85
+ (ruby) </span><span style=BACKGROUND-COLOR:#ffffff>&nbsp;&nbsp;&nbsp;
86
+ </span><span style=BACKGROUND-COLOR:#ffffff><br>
87
+ <br>
88
+ </span>
89
+ </div>
90
+ If you are using the native Ruby interpreter or running the Buildr project,
91
+ then you want to select the <i>ruby</i> option (in this case, #2).<br>
92
+ If you are using Antwrap on the JRuby interpreter, select the <i>java</i>
93
+ option. The native Ruby version of Antwrap depends on another<br>
94
+ gem called <a href=http://rjb.rubyforge.org/ title="RJB (RubyJavaBridge)">RJB
95
+ (RubyJavaBridge)</a> and you will be prompted to install this as part of the
96
+ Antwrap installation. Do so. The RJB gem makes it possible<br>
97
+ for a Ruby script to instantiate Java classes via the Java Native Interface.
98
+ If you chose the java gem, there are no further dependencies. Check the<br>
99
+ RJB site for how to get RJB running (usually, it's just a matter of setting
100
+ the $JAVA_HOME and the $LD_LIBRARY_PATH environment variables).<br>
101
+ <h3>
102
+ Using Antwrap
103
+ </h3>
104
+ The Antwrap library is pretty simple to use, and should look very familiar to
105
+ anyone who has written Ant tasks using XML.<br>
106
+ You begin by instantiating an AntProject;<br>
107
+ <br>
108
+ <div style=MARGIN-LEFT:40px>
109
+ <span style=BACKGROUND-COLOR:#ffffff> @ant = AntProject.new()</span><br>
110
+ </div>
111
+ <br>
112
+ You can pass in a Hash of project options like so;<br>
113
+ <code>
114
+ </code>
115
+ <div style=MARGIN-LEFT:40px>
116
+ <span style=BACKGROUND-COLOR:#cccccc><br>
117
+ <span style=BACKGROUND-COLOR:#ffffff>options = {</span></span><code lang=ruby style=BACKGROUND-COLOR:#ffffff>:ant_home=&gt;"/Users/fooman/tools/apache-ant-1.7.0", :name=&gt;"FooProject", :basedir=&gt; some_dir, </code><br style=BACKGROUND-COLOR:#ffffff>
118
+ <code lang=ruby style=BACKGROUND-COLOR:#ffffff> :declarative=&gt; true, :logger=&gt; Logger.new(STDOUT), :loglevel=&gt; Logger::DEBUG</code><code lang=ruby style=BACKGROUND-COLOR:#ffffff>}</code><br style=BACKGROUND-COLOR:#ffffff>
119
+ <code lang=ruby style=BACKGROUND-COLOR:#ffffff></code><span style=BACKGROUND-COLOR:#ffffff><br>@ant = AntProject.new(options)</span><br></div><pre><code lang=ruby>The default options for an AntProject are as follow</code><code lang=ruby><br></code></pre>
120
+ <ol>
121
+ <li>
122
+ <font face="Arial Black"><code lang=ruby><span style=FONT-STYLE:italic>:name</span> = The name of your AntProject. The default is <i>''</i>.</code></font><code></code></li><li><code></code><span style=FONT-STYLE:italic>:basedir</span> = The location of your project base directory. The default is <i>File.pwd</i>.</li><li><span style=FONT-STYLE:italic>:declarative</span>
123
+ = If true, the AntProject will execute the task when you invoke it. If false, it
124
+ will return an instance of the task. Default value is <i>true</i>.</li><li><span style=FONT-STYLE:italic>:logger</span> = The Logger to use. The default id <i>Logger.new(STDOUT)</i></li><li><span style=FONT-STYLE:italic>:loglevel</span> = The log level. Default is <i>Logger::Erro</i>r</li><li><span style=FONT-STYLE:italic>:ant_home</span>
125
+ = The location of you Ant installation. If provided, Antwrap will
126
+ locate and load the Ant Jar files into the CLASSPATH. It will only do
127
+ this once per Ruby process, so even if you create multiple AntProject instances,
128
+ it only loads the required files once. If :ant_home is not provided, it is assumed
129
+ that you have added the Ant jar files to your CLASSPATH manually.<code lang=ruby> </code><br></li></ol><pre><code lang=ruby>Once you have an AntProject instance, you can begin invoking tasks. To do so, you simply invoke the desired task on the AntProject. You pass in <br>task attributes via a Hash, and you pass in child tasks inside a block. For example;<br></code></pre><div style=MARGIN-LEFT:40px><code lang=ruby style=BACKGROUND-COLOR:#ffffff>@ant.path(:id =&gt; "other.class.path"){ |ant|&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; </code><br style=BACKGROUND-COLOR:#ffffff><code lang=ruby style=BACKGROUND-COLOR:#ffffff> &nbsp;&nbsp;&nbsp; ant.pathelement(:location =&gt; "classes")&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; </code><br style=BACKGROUND-COLOR:#ffffff><code lang=ruby style=BACKGROUND-COLOR:#ffffff> &nbsp;&nbsp;&nbsp; ant.pathelement(:location =&gt; "config")&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </code><br style=BACKGROUND-COLOR:#ffffff><code lang=ruby style=BACKGROUND-COLOR:#ffffff>}&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; <br></code><code lang=ruby style=BACKGROUND-COLOR:#ffffff></code><code lang=ruby style=BACKGROUND-COLOR:#ffffff>@ant.path(:id =&gt; "common.class.path"){|ant|&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;</code><code lang=ruby style=BACKGROUND-COLOR:#ffffff>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; ant.fileset(:dir =&gt; "${common.dir}/lib"){&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </code><br style=BACKGROUND-COLOR:#ffffff><code lang=ruby style=BACKGROUND-COLOR:#ffffff> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ant.include(:name =&gt; "**/*.jar")&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; </code><br style=BACKGROUND-COLOR:#ffffff><code lang=ruby style=BACKGROUND-COLOR:#ffffff> &nbsp;&nbsp;&nbsp; }&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; </code><br style=BACKGROUND-COLOR:#ffffff><code lang=ruby style=BACKGROUND-COLOR:#ffffff> &nbsp;&nbsp;&nbsp; ant.pathelement(:location =&gt; "${common.classes}")&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <br></code><code lang=ruby style=BACKGROUND-COLOR:#ffffff>}&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; </code><code lang=ruby style=BACKGROUND-COLOR:#ffffff></code><span style=BACKGROUND-COLOR:#ffffff>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; </span><br style=BACKGROUND-COLOR:#ffffff><code lang=ruby style=BACKGROUND-COLOR:#ffffff>@ant.javac(:srcdir =&gt; "test", :destdir =&gt; "classes"){</code><code lang=ruby style=BACKGROUND-COLOR:#ffffff>|ant|</code><code lang=ruby style=BACKGROUND-COLOR:#ffffff> &nbsp; </code><br style=BACKGROUND-COLOR:#ffffff><code lang=ruby style=BACKGROUND-COLOR:#ffffff> &nbsp;&nbsp;&nbsp; ant.classpath(:refid =&gt; "common.class.path")&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </code><br style=BACKGROUND-COLOR:#ffffff><code lang=ruby style=BACKGROUND-COLOR:#ffffff> &nbsp;&nbsp;&nbsp; ant.classpath(:refid =&gt; "foo.class.path")&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </code><br style=BACKGROUND-COLOR:#ffffff><code lang=ruby style=BACKGROUND-COLOR:#ffffff>}&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; </code><br></div><h3><b>Declarative Mode</b></h3>
130
+ <pre>By default, Antwrap runs in <i>declarative</i> mode. This means that the AntProject will execute the tasks as you declare them. Alternatively, you can declare your<br>Ant project to run in non-declarative mode, so that it only executes tasks upon the invocation of the execute() method (this is a more Object Oriented <br>approach, and may be useful in some circumstances). For example;<br></pre><div style=MARGIN-LEFT:40px><code lang=ruby style=BACKGROUND-COLOR:#ffffff>@ant = AntProject.new({:name=&gt;"FooProject", :declarative=&gt; false})&nbsp;&nbsp; &nbsp;&nbsp; <br>&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; </code><br style=BACKGROUND-COLOR:#ffffff><code lang=ruby style=BACKGROUND-COLOR:#ffffff></code> <code lang=ruby style=BACKGROUND-COLOR:#ffffff>javac_task = @ant.javac(:srcdir =&gt; "test", :destdir =&gt; "classes"){</code><code lang=ruby style=BACKGROUND-COLOR:#ffffff>|ant|</code><code lang=ruby style=BACKGROUND-COLOR:#ffffff> </code><code lang=ruby style=BACKGROUND-COLOR:#ffffff>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; ant.classpath(:refid =&gt; "common.class.path")&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; </code><code lang=ruby style=BACKGROUND-COLOR:#ffffff>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; ant.classpath(:refid =&gt; "foo.class.path")&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; </code><br style=BACKGROUND-COLOR:#ffffff><code lang=ruby style=BACKGROUND-COLOR:#ffffff>}&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <br></code><code lang=ruby style=BACKGROUND-COLOR:#ffffff>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <br>javac_task.execute&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; </code><br></div><h3>Reserved Words</h3><pre>If your Ant task conflicts with a Ruby reserved word, you can prep-end an underscore. For example, Ant-Contrib <br>tasks such as 'if' and 'else' conflict with the Ruby reserved words;<br><br></pre><div style=MARGIN-LEFT:40px><code lang=ruby style=BACKGROUND-COLOR:#ffffff>@ant._if(){|ant|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </code><br style=BACKGROUND-COLOR:#ffffff><code lang=ruby style=BACKGROUND-COLOR:#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; ant._equals(:arg1 =&gt; "${bar}", :arg2 =&gt; "bar")&nbsp;&nbsp;&nbsp; </code><br style=BACKGROUND-COLOR:#ffffff><code lang=ruby style=BACKGROUND-COLOR:#ffffff> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; ant._then(){&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; </code><br style=BACKGROUND-COLOR:#ffffff><code lang=ruby style=BACKGROUND-COLOR:#ffffff> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ant.echo(:message =&gt; "if 1 is equal")&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; </code><br style=BACKGROUND-COLOR:#ffffff><code lang=ruby style=BACKGROUND-COLOR:#ffffff> &nbsp;&nbsp;&nbsp; } &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;</code><code lang=ruby style=BACKGROUND-COLOR:#ffffff>&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; ant._else(){&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; </code><br style=BACKGROUND-COLOR:#ffffff><code lang=ruby style=BACKGROUND-COLOR:#ffffff> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ant.echo(:message =&gt; "if 1 is not equal")&nbsp;&nbsp;&nbsp;&nbsp; </code><br style=BACKGROUND-COLOR:#ffffff><code lang=ruby style=BACKGROUND-COLOR:#ffffff> &nbsp;&nbsp;&nbsp; }&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </code><br style=BACKGROUND-COLOR:#ffffff><code lang=ruby style=BACKGROUND-COLOR:#ffffff>}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </code><br><br></div><pre>Under most circumstances, you won't need to use these tasks because the Ruby language (OK... any language) can handle <br>conditionals better than Ant. Indeed, the awkwardness of conditional operations in Ant scripts is likely one of the <br>reasons why you want to move to a build system such as Buildr.<br></pre><h3>Content Data</h3><pre>Content data is added via a 'pcdata' attribute:<br></pre><div style="MARGIN-LEFT:40px; BACKGROUND-COLOR:#ffffff"><code lang=ruby>@ant.echo(:pcdata =&gt; "&lt;foo&amp;bar&gt;")</code></div><h3 style=FONT-STYLE:italic>Changes</h3><ul style=MARGIN-LEFT:40px><li><font size=1 style="FONT-STYLE:italic; FONT-WEIGHT:bold; TEXT-DECORATION:underline"><font size=2>Version 0.6.0</font></font><font size=1><font size=2>: The Antwrap syntax has changed. Prior to version 0.6.0, any blocks passed in with a task were evaluated within the context of the task itself (using :instance_eval), so there was no AntProject instance passed to the block. For example, when the <span style=FONT-STYLE:italic>path</span> task block was evaluated, it was evaluated within the context of the <span style=FONT-STYLE:italic>path</span> task, so the <span style=FONT-STYLE:italic>pathelement</span> children were assumed to be child tasks;</font></font><span style=BACKGROUND-COLOR:#cccccc></span></li></ul><div style="TEXT-ALIGN:left; MARGIN-LEFT:120px"><span style=BACKGROUND-COLOR:#ffffff><br><span style=BACKGROUND-COLOR:#ffffff>@ant.path(:id =&gt; "other.class.path"){&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><code style=BACKGROUND-COLOR:#ffffff></code></span><br style=BACKGROUND-COLOR:#ffffff><span style=BACKGROUND-COLOR:#ffffff><code></code> &nbsp;&nbsp;&nbsp; pathelement(:location =&gt; "classes")&nbsp;&nbsp;&nbsp;&nbsp; </span><code style=BACKGROUND-COLOR:#ffffff></code><br style=BACKGROUND-COLOR:#ffffff><code style=BACKGROUND-COLOR:#ffffff></code><span style=BACKGROUND-COLOR:#ffffff>&nbsp;&nbsp;&nbsp; pathelement(:location =&gt; "config"<code>)&nbsp;&nbsp;&nbsp; </code></span><code lang=ruby style=BACKGROUND-COLOR:#cccccc><br style=BACKGROUND-COLOR:#ffffff><span style=BACKGROUND-COLOR:#ffffff>}<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;</span></code><br></div><div style=MARGIN-LEFT:80px>This approach is pleasing syntactically because it looks like the XML syntax we are accustomed to. Unfortunately, it means that you can't execute arbitrary code in the block. For example, this would fail because the AntTask class does not contain a foobar() method; <br><div style=MARGIN-LEFT:40px><span style=BACKGROUND-COLOR:#ffffff><span style=BACKGROUND-COLOR:#cccccc><br><span style=BACKGROUND-COLOR:#ffffff>def foobar &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; </span><br style=BACKGROUND-COLOR:#ffffff><span style=BACKGROUND-COLOR:#ffffff>&nbsp;&nbsp;&nbsp; return "classes"&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><br style=BACKGROUND-COLOR:#ffffff><span style=BACKGROUND-COLOR:#ffffff>end&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><br style=BACKGROUND-COLOR:#ffffff><span style=BACKGROUND-COLOR:#ffffff>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; </span><br style=BACKGROUND-COLOR:#ffffff><span style=BACKGROUND-COLOR:#ffffff>@ant.path(:id =&gt; "other.class.path"){&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; </span></span><code style=BACKGROUND-COLOR:#ffffff></code></span><br style=BACKGROUND-COLOR:#ffffff><span style=BACKGROUND-COLOR:#ffffff><code></code> &nbsp;&nbsp;&nbsp; foo = foobar() &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; pathelement(:location =&gt; foo)&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; <br></span><code style=BACKGROUND-COLOR:#ffffff></code><span style=BACKGROUND-COLOR:#ffffff>&nbsp;&nbsp;&nbsp; pathelement(:location =&gt; "config"<code>)&nbsp;&nbsp; &nbsp; <br>}&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </code></span><code lang=ruby style=BACKGROUND-COLOR:#ffffff></code><br style=BACKGROUND-COLOR:#ffffff><code lang=ruby style=BACKGROUND-COLOR:#ffffff></code></div>
131
+
132
+ <code lang=ruby style=BACKGROUND-COLOR:#ffffff>
133
+ </code><br>To rectify this, the AntProject now yields to the block and passes itself as a parameter. So calling your foobar() method will work;<br><br style=BACKGROUND-COLOR:#ffffff><div style=MARGIN-LEFT:40px><span style=BACKGROUND-COLOR:#ffffff>def foobar </span><br style=BACKGROUND-COLOR:#ffffff><span style=BACKGROUND-COLOR:#ffffff>
134
+ &nbsp;&nbsp;&nbsp; return "classes"</span><br style=BACKGROUND-COLOR:#ffffff><span style=BACKGROUND-COLOR:#ffffff>
135
+ end</span><br style=BACKGROUND-COLOR:#ffffff><span style=BACKGROUND-COLOR:#ffffff>
136
+ </span><br style=BACKGROUND-COLOR:#ffffff><span style=BACKGROUND-COLOR:#ffffff>
137
+ @ant.path(:id =&gt; "other.class.path"){ |ant|<code></code></span><br style=BACKGROUND-COLOR:#ffffff><span style=BACKGROUND-COLOR:#ffffff><code></code> &nbsp;&nbsp;&nbsp; foo = foobar() &nbsp; </span><br style=BACKGROUND-COLOR:#ffffff><span style=BACKGROUND-COLOR:#ffffff>
138
+ &nbsp;&nbsp;&nbsp; ant.pathelement(:location =&gt; foo)</span><br style=BACKGROUND-COLOR:#ffffff><span style=BACKGROUND-COLOR:#ffffff>
139
+ </span><code style=BACKGROUND-COLOR:#ffffff></code><span style=BACKGROUND-COLOR:#ffffff>&nbsp;&nbsp;&nbsp; ant.pathelement(:location =&gt; "config"<code>)</code></span><br style=BACKGROUND-COLOR:#ffffff><span style=BACKGROUND-COLOR:#ffffff><code>
140
+ }</code></span><code lang=ruby style=BACKGROUND-COLOR:#cccccc></code><br></div>
141
+
142
+ <code lang=ruby style=BACKGROUND-COLOR:#cccccc></code>
143
+
144
+
145
+ <code lang=ruby style=BACKGROUND-COLOR:#cccccc>
146
+ </code><br>While slightly more verbose, this changes make life easier when invoking Ant tasks, and is more typical of a Ruby library.<br></div><pre><span style=FONT-STYLE:italic><br>Comments or Questions? Contact caleb.powell@gmail.com </span><br></pre>
147
+ </div></body>
148
+ </html>