Antwrap 0.2 → 0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1 -2
- data/docs/index.html +119 -0
- data/lib/antwrap.rb +157 -46
- data/lib/convert.rb +5 -2
- data/test/tc_antwrap.rb +35 -52
- metadata +7 -7
- data/test/output/classes/foo/bar/FooBar.class +0 -0
data/README
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# antwrap
|
2
2
|
#
|
3
3
|
# Copyright Caleb Powell 2007
|
4
|
-
#
|
5
4
|
# Licensed under the LGPL, see the file COPYING in the distribution
|
6
5
|
#
|
7
6
|
|
@@ -10,4 +9,4 @@ https://rubyforge.org/projects/antwrap/
|
|
10
9
|
Questions?
|
11
10
|
Contact: caleb.powell@gmail.com
|
12
11
|
|
13
|
-
More documentation to come.
|
12
|
+
More documentation to come.
|
data/docs/index.html
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
<html><head><title>Antwrap - Invoke Ant tasks from your JRuby script!</title></head><body><ul>
|
2
|
+
<pre><li>Sample code of the Antwrap library looks like this;
|
3
|
+
|
4
|
+
<code lang="ruby">
|
5
|
+
#All options are optional. The defaults are as follows;
|
6
|
+
#{:name=>'', :basedir=>'.', :declarative=> true, :logger=> Logger.new(STDOUT), :loglevel=> Logger::DEBUG}
|
7
|
+
#so you can call AntProject.new() if you like.
|
8
|
+
|
9
|
+
@ant = AntProject.new({:name=>"FooProject",
|
10
|
+
:basedir=> current_dir,
|
11
|
+
:declarative=> true,
|
12
|
+
:logger=> Logger.new(STDOUT),
|
13
|
+
:loglevel=> Logger::DEBUG})
|
14
|
+
|
15
|
+
@ant.path(:id => "other.class.path"){
|
16
|
+
pathelement(:location => "classes")
|
17
|
+
pathelement(:location => "config")
|
18
|
+
}
|
19
|
+
|
20
|
+
|
21
|
+
@ant.path(:id => "common.class.path"){
|
22
|
+
fileset(:dir => "${common.dir}/lib"){
|
23
|
+
include(:name => "**/*.jar")
|
24
|
+
}
|
25
|
+
pathelement(:location => "${common.classes}")
|
26
|
+
}
|
27
|
+
|
28
|
+
@ant.javac(:srcdir => "test", :destdir => "classes"){
|
29
|
+
classpath(:refid => "common.class.path")
|
30
|
+
classpath(:refid => "foo.class.path")
|
31
|
+
}
|
32
|
+
</code>
|
33
|
+
</li>
|
34
|
+
</pre>
|
35
|
+
|
36
|
+
<pre><li>Alternatively, you can declare your Ant project to run in non-declarative mode, so that it only executes tasks
|
37
|
+
upon the invocation of the execute() method (this is a more Object Oriented approach, and may be useful in some
|
38
|
+
circumstances):
|
39
|
+
|
40
|
+
<code lang="ruby">
|
41
|
+
@ant = AntProject.new({:name=>"FooProject", :declarative=>true})
|
42
|
+
|
43
|
+
javac_task = @ant.javac(:srcdir => "test", :destdir => "classes"){
|
44
|
+
classpath(:refid => "common.class.path")
|
45
|
+
classpath(:refid => "foo.class.path")
|
46
|
+
}
|
47
|
+
|
48
|
+
javac_task.execute
|
49
|
+
</code>
|
50
|
+
</li>
|
51
|
+
</pre>
|
52
|
+
|
53
|
+
<pre><li>There are some reserved words that we have to work around. For example, Ant-Contrib tasks such as 'if' and 'else'
|
54
|
+
conflict with the Ruby reserved words. Under most circumstances, you won't need to use these tasks (indeed, the
|
55
|
+
awkwardness of conditional operations in Ant scripts is likely one of the reasons why you want to move to a build system
|
56
|
+
such as Rake).
|
57
|
+
|
58
|
+
Nevertheless, there are that occasions demands it. One such situation is the <java> Ant task. The 'java'
|
59
|
+
symbol conflicts with a symbol in the JRuby library.
|
60
|
+
|
61
|
+
Reserved words like this can be worked around by simply prepending an underscore character ('_') to the task:
|
62
|
+
|
63
|
+
<code lang="ruby">
|
64
|
+
@ant._java(:classname => 'foo.bar.FooBar', :fork => 'false') {
|
65
|
+
arg(:value => 'argOne')
|
66
|
+
classpath(){
|
67
|
+
pathelement(:location => '${output_dir}/classes')
|
68
|
+
pathelement(:location => '${resource_dir}/parent.jar')
|
69
|
+
}
|
70
|
+
arg(:value => 'argTwo')
|
71
|
+
jvmarg(:value => 'client')
|
72
|
+
sysproperty(:key=> 'antwrap', :value => 'coolio')
|
73
|
+
}
|
74
|
+
|
75
|
+
#Because the 'java' Ant task is likely to be very popular, there is an alias you can use called 'jvm'.
|
76
|
+
#The above task could be rewritten as:
|
77
|
+
@ant.jvm(:classname => 'foo.bar.FooBar', :fork => 'false') {...
|
78
|
+
|
79
|
+
#This is an example of the Ant-Contrib tasks.
|
80
|
+
#note: I added an underscore to 'equals' even though it isn't a reserved word.
|
81
|
+
#This makes the code block more symmetrical (it's not required though). It also
|
82
|
+
#illustrates that you can apply an underscore to any task and it will be stripped by Antwrap.
|
83
|
+
@ant._if(){
|
84
|
+
_equals(:arg1 => "${bar}", :arg2 => "bar")
|
85
|
+
_then(){
|
86
|
+
echo(:message => "if 1 is equal")
|
87
|
+
}
|
88
|
+
_else(){
|
89
|
+
echo(:message => "if 1 is not equal")
|
90
|
+
}
|
91
|
+
}
|
92
|
+
</code>
|
93
|
+
</li>
|
94
|
+
</pre>
|
95
|
+
|
96
|
+
<pre><li>Content data is added via a 'pcdata' attribute:
|
97
|
+
|
98
|
+
<code lang="ruby">
|
99
|
+
@ant.echo(:pcdata => "<foo&bar>")
|
100
|
+
</code>
|
101
|
+
</li>
|
102
|
+
|
103
|
+
<li>Antwrap includes a conversion script to take an existing Ant build file and convert it to a rake file. It will
|
104
|
+
convert each Ant Target into a JRake task. It will also convert each and every Any Task into an Antwrap method call.
|
105
|
+
Ant tasks that conflict with Ruby keywords are prepended with an
|
106
|
+
underscore (see above).
|
107
|
+
|
108
|
+
</li>
|
109
|
+
<li>Antwrap is a Beta release. I'd love any feedback you can provide on your experence with it.
|
110
|
+
There are no 3rd party jars required other than the Ant jar files in your JRuby Classpath.
|
111
|
+
</li></pre>
|
112
|
+
|
113
|
+
</ul>
|
114
|
+
Comments or Questions? <br>
|
115
|
+
|
116
|
+
Caleb Powell <br>
|
117
|
+
caleb.powell@gmail.com <br>
|
118
|
+
|
119
|
+
</body></html>
|
data/lib/antwrap.rb
CHANGED
@@ -9,49 +9,41 @@ require 'logger'
|
|
9
9
|
require 'java'
|
10
10
|
|
11
11
|
module ApacheAnt
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
include_class "org.apache.tools.ant.UnknownElement"
|
13
|
+
include_class "org.apache.tools.ant.RuntimeConfigurable"
|
14
|
+
include_class "org.apache.tools.ant.Project"
|
15
|
+
include_class "org.apache.tools.ant.DefaultLogger"
|
16
|
+
include_class "org.apache.tools.ant.Target"
|
17
|
+
include_class "org.apache.tools.ant.Main"
|
16
18
|
end
|
17
19
|
|
18
20
|
module JavaLang
|
19
|
-
|
21
|
+
include_class "java.lang.System"
|
20
22
|
end
|
21
23
|
|
22
|
-
@@log = Logger.new(STDOUT)
|
23
|
-
@@log.level = Logger::ERROR
|
24
|
-
|
25
24
|
class AntTask
|
26
25
|
private
|
27
26
|
@@task_stack = Array.new
|
28
|
-
attr_reader :unknown_element, :project, :taskname
|
27
|
+
attr_reader :unknown_element, :project, :taskname, :logger
|
29
28
|
|
30
29
|
public
|
31
|
-
def initialize(taskname,
|
30
|
+
def initialize(taskname, antProject, attributes, proc)
|
32
31
|
if(taskname[0,1] == "_")
|
33
32
|
taskname = taskname[1, taskname.length-1]
|
34
33
|
end
|
34
|
+
@logger = antProject.logger
|
35
|
+
@logger.debug("AntTask.taskname: #{taskname}, antProject:#{antProject}, atts:#{attributes.to_s}, proc:#{proc.to_s}")
|
35
36
|
@taskname = taskname
|
36
|
-
@
|
37
|
-
@
|
38
|
-
@
|
39
|
-
@unknown_element
|
40
|
-
@
|
41
|
-
|
42
|
-
@
|
43
|
-
|
44
|
-
wrapper = ApacheAnt::RuntimeConfigurable.new(@unknown_element, @unknown_element.getTaskName());
|
45
|
-
attributes.each do |key, val|
|
46
|
-
if(key.to_s != 'pcdata')
|
47
|
-
wrapper.setAttribute(key.to_s, val)
|
48
|
-
else
|
49
|
-
wrapper.addText(val)
|
50
|
-
end
|
51
|
-
end unless attributes == nil
|
37
|
+
@project_wrapper = antProject
|
38
|
+
@project = antProject.project()
|
39
|
+
@logger.debug(@project)
|
40
|
+
@unknown_element = create_unknown_element(@project, taskname)
|
41
|
+
@logger.debug("1")
|
42
|
+
addAttributes(attributes)
|
43
|
+
@logger.debug("2")
|
52
44
|
|
53
45
|
if proc
|
54
|
-
|
46
|
+
@logger.debug("task_stack.push #{taskname} >> #{@@task_stack}")
|
55
47
|
@@task_stack.push self
|
56
48
|
|
57
49
|
singleton_class = class << proc; self; end
|
@@ -63,20 +55,51 @@ class AntTask
|
|
63
55
|
proc.instance_eval &proc
|
64
56
|
@@task_stack.pop
|
65
57
|
end
|
58
|
+
@logger.debug("3")
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
def create_unknown_element(project, taskname)
|
63
|
+
unknown_element = ApacheAnt::UnknownElement.new(taskname)
|
64
|
+
unknown_element.project= project
|
65
|
+
unknown_element.owningTarget= ApacheAnt::Target.new()
|
66
|
+
unknown_element.namespace= ''
|
67
|
+
unknown_element.QName= taskname
|
68
|
+
unknown_element.taskType= taskname
|
69
|
+
unknown_element.taskName= taskname
|
70
|
+
return unknown_element
|
71
|
+
end
|
72
|
+
|
73
|
+
def addAttributes(attributes)
|
74
|
+
wrapper = ApacheAnt::RuntimeConfigurable.new(@unknown_element, @unknown_element.getTaskName());
|
75
|
+
attributes.each do |key, val|
|
76
|
+
if(key.to_s != 'pcdata')
|
77
|
+
wrapper.setAttribute(key.to_s, val)
|
78
|
+
else
|
79
|
+
wrapper.addText(val)
|
80
|
+
end
|
81
|
+
end unless attributes == nil
|
66
82
|
end
|
67
83
|
|
68
84
|
def method_missing(sym, *args)
|
69
|
-
|
85
|
+
@logger.debug("AntTask.method_missing sym[#{sym.to_s}]")
|
70
86
|
begin
|
71
87
|
proc = block_given? ? Proc.new : nil
|
72
|
-
|
88
|
+
if(@project_wrapper.ant_version < 1.6)
|
89
|
+
@logger.debug("Creating a 1.5. task")
|
90
|
+
task = Ant15Task.new(sym.to_s, @project_wrapper, args[0], proc)
|
91
|
+
else
|
92
|
+
task = AntTask.new(sym.to_s, @project_wrapper, args[0], proc)
|
93
|
+
end
|
94
|
+
|
95
|
+
self.add(task)
|
73
96
|
rescue StandardError
|
74
|
-
|
97
|
+
@logger.error("AntTask.method_missing error:" + $!)
|
75
98
|
end
|
76
99
|
end
|
77
100
|
|
78
101
|
def add(child)
|
79
|
-
|
102
|
+
@logger.debug("adding child[#{child.unknown_element().getTaskName()}] to [#{@unknown_element.getTaskName()}]")
|
80
103
|
@unknown_element.addChild(child.unknown_element())
|
81
104
|
@unknown_element.getRuntimeConfigurableWrapper().addChild(child.unknown_element().getRuntimeConfigurableWrapper())
|
82
105
|
end
|
@@ -91,47 +114,135 @@ class AntTask
|
|
91
114
|
@executed
|
92
115
|
end
|
93
116
|
|
117
|
+
#overridden. 'mkdir' conflicts wth the rake library.
|
118
|
+
def mkdir(attributes)
|
119
|
+
create_task('mkdir', attributes, (block_given? ? Proc.new : nil))
|
120
|
+
end
|
121
|
+
|
122
|
+
#overridden. 'copy' conflicts wth the rake library.
|
123
|
+
def copy(attributes)
|
124
|
+
create_task('copy', attributes, (block_given? ? Proc.new : nil))
|
125
|
+
end
|
126
|
+
|
127
|
+
#overridden. 'java' conflicts wth the JRuby library.
|
128
|
+
def jvm(attributes=Hash.new)
|
129
|
+
create_task('java', attributes, (block_given? ? Proc.new : nil))
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
|
134
|
+
class Ant15Task < AntTask
|
135
|
+
|
136
|
+
def create_unknown_element(project, taskname)
|
137
|
+
unknown_element = ApacheAnt::UnknownElement.new(taskname)
|
138
|
+
unknown_element.project= project
|
139
|
+
unknown_element.owningTarget= ApacheAnt::Target.new()
|
140
|
+
unknown_element.taskName= taskname
|
141
|
+
return unknown_element
|
142
|
+
end
|
143
|
+
|
144
|
+
def addAttributes(attributes)
|
145
|
+
wrapper = ApacheAnt::RuntimeConfigurable.new(@unknown_element, @unknown_element.getTaskName());
|
146
|
+
@unknown_element.setRuntimeConfigurableWrapper(wrapper)
|
147
|
+
attribute_list = org.xml.sax.helpers.AttributeListImpl.new
|
148
|
+
|
149
|
+
attributes.each do |key, val|
|
150
|
+
if(key.to_s != 'pcdata')
|
151
|
+
attribute_list.addAttribute(key.to_s, 'CDATA', val)
|
152
|
+
else
|
153
|
+
wrapper.addText(val)
|
154
|
+
end
|
155
|
+
end unless attributes == nil
|
156
|
+
wrapper.setAttributes(attribute_list)
|
157
|
+
end
|
158
|
+
|
94
159
|
end
|
95
160
|
|
96
161
|
class AntProject
|
97
162
|
|
98
163
|
attr :project, false
|
164
|
+
attr :version, false
|
165
|
+
attr :ant_version, true
|
99
166
|
attr :declarative, true
|
167
|
+
attr :logger, true
|
100
168
|
|
101
|
-
|
169
|
+
# Create an AntProject. Parameters are specified via a hash:
|
170
|
+
# :name=><em>project_name</em>
|
171
|
+
# -A String indicating the name of this project. Corresponds to the
|
172
|
+
# 'name' attrbute on an Ant project.
|
173
|
+
# :basedir=><em>project_basedir</em>
|
174
|
+
# -A String indicating the basedir of this project. Corresponds to the 'basedir' attribute
|
175
|
+
# on an Ant project.
|
176
|
+
# :declarative=><em>declarative_mode</em>
|
177
|
+
# -A boolean value indicating wether Ant tasks created by this project instance should
|
178
|
+
# have their execute() method invoked during their creation. For example, with
|
179
|
+
# the option :declarative=>true the following task would execute;
|
180
|
+
# @antProject.echo(:message => "An Echo Task")
|
181
|
+
# However, with the option :declarative=>false, the programmer is required to execute the
|
182
|
+
# task explicitly;
|
183
|
+
# echoTask = @antProject.echo(:message => "An Echo Task")
|
184
|
+
# echoTask.execute()
|
185
|
+
# Default value is <em>true</em>.
|
186
|
+
# :logger=><em>Logger</em>
|
187
|
+
# -A Logger instance. Defaults to Logger.new(STDOUT)
|
188
|
+
# :loglevel=><em>The level to set the logger to</em>
|
189
|
+
# -Defaults to Logger::ERROR
|
190
|
+
def initialize(options=Hash.new)
|
102
191
|
@project= ApacheAnt::Project.new
|
103
|
-
@project.name= name
|
104
|
-
@project.default=
|
105
|
-
@project.basedir= basedir
|
192
|
+
@project.name= options[:name] || ''
|
193
|
+
@project.default= ''
|
194
|
+
@project.basedir= options[:basedir] || '.'
|
106
195
|
@project.init
|
107
|
-
self.declarative= declarative
|
196
|
+
self.declarative= options[:declarative] || true
|
108
197
|
default_logger = ApacheAnt::DefaultLogger.new
|
109
198
|
default_logger.messageOutputLevel= 2
|
110
199
|
default_logger.outputPrintStream= JavaLang::System.out
|
111
200
|
default_logger.errorPrintStream= JavaLang::System.err
|
112
201
|
default_logger.emacsMode= false
|
113
202
|
@project.addBuildListener default_logger
|
203
|
+
@version = ApacheAnt::Main.getAntVersion
|
204
|
+
@ant_version = @version[/\d\.\d\.\d/].to_f
|
205
|
+
@logger = options[:logger] || Logger.new(STDOUT)
|
206
|
+
@logger.level = options[:loglevel] || Logger::ERROR
|
207
|
+
@logger.debug(@version)
|
114
208
|
end
|
115
209
|
|
116
210
|
def create_task(taskname, attributes, proc)
|
117
|
-
|
211
|
+
@logger.debug("Antproject.create_task.taskname = " + taskname)
|
212
|
+
@logger.debug("Antproject.create_task.attributes = " + attributes.to_s)
|
213
|
+
|
214
|
+
task = nil;
|
215
|
+
if(ant_version < 1.6)
|
216
|
+
task = Ant15Task.new(taskname, self, attributes, proc)
|
217
|
+
else
|
218
|
+
task = AntTask.new(taskname, self, attributes, proc)
|
219
|
+
end
|
220
|
+
|
118
221
|
task.execute if declarative
|
119
222
|
if taskname == 'macrodef'
|
120
|
-
|
223
|
+
@logger.debug("Pushing #{attributes[:name]} to tasks")
|
121
224
|
end
|
122
225
|
task
|
123
226
|
end
|
124
227
|
|
125
228
|
def method_missing(sym, *args)
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
229
|
+
begin
|
230
|
+
@logger.info("AntProject.method_missing sym[#{sym.to_s}]")
|
231
|
+
proc = block_given? ? Proc.new : nil
|
232
|
+
return create_task(sym.to_s, args[0], proc)
|
233
|
+
rescue
|
234
|
+
@logger.error("Error instantiating task[#{sym.to_s}]" + $!)
|
235
|
+
end
|
133
236
|
end
|
134
|
-
|
237
|
+
|
238
|
+
def name()
|
239
|
+
return @project.name
|
240
|
+
end
|
241
|
+
|
242
|
+
def basedir()
|
243
|
+
return @project.getBaseDir().getAbsolutePath();
|
244
|
+
end
|
245
|
+
|
135
246
|
#overridden. 'mkdir' conflicts wth the rake library.
|
136
247
|
def mkdir(attributes)
|
137
248
|
create_task('mkdir', attributes, (block_given? ? Proc.new : nil))
|
data/lib/convert.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
# Licensed under the LGPL, see the file COPYING in the distribution
|
6
6
|
#
|
7
7
|
require 'rexml/document'
|
8
|
-
|
8
|
+
|
9
9
|
if ARGV.empty?
|
10
10
|
puts "Usage: #{$0} [antfile] [rakefile]"
|
11
11
|
exit! 1
|
@@ -17,7 +17,7 @@ end
|
|
17
17
|
'def', 'defined', 'do', 'else', 'elsif', 'END', 'end', 'ensure',
|
18
18
|
'false', 'for', 'if', 'in', 'module', 'next', 'nil', 'not', 'or',
|
19
19
|
'redo', 'rescue', 'retry', 'return', 'self', 'super', 'then', 'true',
|
20
|
-
'undef', 'unless', 'until', 'when', 'while', 'yield']
|
20
|
+
'undef', 'unless', 'until', 'when', 'while', 'yield', 'java']
|
21
21
|
|
22
22
|
xml = REXML::Document.new(@antfile)
|
23
23
|
|
@@ -49,7 +49,10 @@ def print_task(task, tab=@one_tab, prefix='')
|
|
49
49
|
|
50
50
|
if(task_name == 'macrodef')
|
51
51
|
task.attributes['name'] = rubyize(task.attributes['name'])
|
52
|
+
elsif(task_name == 'java')
|
53
|
+
task_name = 'jvm'
|
52
54
|
end
|
55
|
+
|
53
56
|
isFirst = true;
|
54
57
|
task.attributes.each do |key, value|
|
55
58
|
if !isFirst
|
data/test/tc_antwrap.rb
CHANGED
@@ -15,10 +15,16 @@ class TestAntwrap < Test::Unit::TestCase
|
|
15
15
|
# @output_dir = ENV['PWD'] + '/output'
|
16
16
|
# @resource_dir = ENV['PWD'] + '/test-resources'
|
17
17
|
# The following is a workaround
|
18
|
-
current_dir = Java::java.lang.System.getProperty("user.dir")
|
19
|
-
@
|
20
|
-
|
21
|
-
@
|
18
|
+
@current_dir = Java::java.lang.System.getProperty("user.dir")
|
19
|
+
@ant_proj_props = {:name=>"testProject", :basedir=>@current_dir, :declarative=>true,
|
20
|
+
:logger=>Logger.new(STDOUT), :loglevel=>Logger::DEBUG}
|
21
|
+
@ant = AntProject.new(@ant_proj_props)
|
22
|
+
assert(@ant_proj_props[:name] == @ant.name())
|
23
|
+
assert(@ant_proj_props[:basedir] == @ant.basedir())
|
24
|
+
assert(@ant_proj_props[:declarative] == @ant.declarative())
|
25
|
+
|
26
|
+
@output_dir = @current_dir + '/test/output'
|
27
|
+
@resource_dir = @current_dir + '/test/test-resources'
|
22
28
|
|
23
29
|
if File.exists?(@output_dir)
|
24
30
|
FileUtils.remove_dir(@output_dir)
|
@@ -26,10 +32,16 @@ class TestAntwrap < Test::Unit::TestCase
|
|
26
32
|
FileUtils.mkdir(@output_dir, :mode => 0775)
|
27
33
|
end
|
28
34
|
|
29
|
-
def
|
30
|
-
|
35
|
+
def test_antproject_init
|
36
|
+
@ant_proj_props = {:name=>"testProject", :declarative=>true,
|
37
|
+
:logger=>Logger.new(STDOUT), :loglevel=>Logger::ERROR}
|
38
|
+
ant_proj = AntProject.new(@ant_proj_props)
|
39
|
+
assert(@ant_proj_props[:name] == ant_proj.name())
|
40
|
+
assert(@current_dir == ant_proj.basedir())
|
41
|
+
assert(@ant_proj_props[:declarative] == ant_proj.declarative())
|
42
|
+
assert(@ant_proj_props[:logger] == ant_proj.logger())
|
31
43
|
end
|
32
|
-
|
44
|
+
|
33
45
|
def test_unzip_task
|
34
46
|
assert_absent @output_dir + '/parent/FooBarParent.class'
|
35
47
|
task = @ant.unzip(:src => @resource_dir + '/parent.jar',
|
@@ -49,11 +61,6 @@ class TestAntwrap < Test::Unit::TestCase
|
|
49
61
|
assert_absent file
|
50
62
|
end
|
51
63
|
|
52
|
-
# <javac srcdir='${src}'
|
53
|
-
# destdir='${build}'
|
54
|
-
# classpath='xyz.jar'
|
55
|
-
# debug='on'
|
56
|
-
# source='1.4'/>
|
57
64
|
def test_javac_task
|
58
65
|
FileUtils.mkdir(@output_dir + '/classes', :mode => 0775)
|
59
66
|
|
@@ -77,12 +84,6 @@ class TestAntwrap < Test::Unit::TestCase
|
|
77
84
|
FileUtils.mkdir(@output_dir + '/classes', :mode => 0775)
|
78
85
|
|
79
86
|
assert_absent @output_dir + '/classes/foo/bar/FooBar.class'
|
80
|
-
# <path id="common.class.path">
|
81
|
-
# <fileset dir="${common.dir}/lib">
|
82
|
-
# <include name="**/*.jar"/>
|
83
|
-
# </fileset>
|
84
|
-
# <pathelement location="${common.classes}"/>
|
85
|
-
# </path>
|
86
87
|
@ant.property(:name => 'pattern', :value => '**/*.jar')
|
87
88
|
@ant.property(:name => 'resource_dir', :value => @resource_dir)
|
88
89
|
@ant.path(:id => 'common.class.path'){
|
@@ -94,7 +95,7 @@ class TestAntwrap < Test::Unit::TestCase
|
|
94
95
|
@ant.javac(:srcdir => @resource_dir + '/src',
|
95
96
|
:destdir => @output_dir + '/classes',
|
96
97
|
:debug => 'on',
|
97
|
-
:verbose => '
|
98
|
+
:verbose => 'yes',
|
98
99
|
:fork => 'no',
|
99
100
|
:failonerror => 'yes',
|
100
101
|
:includes => 'foo/bar/**',
|
@@ -105,27 +106,21 @@ class TestAntwrap < Test::Unit::TestCase
|
|
105
106
|
assert_absent @output_dir + '/classes/foo/bar/baz/FooBarBaz.class'
|
106
107
|
end
|
107
108
|
|
108
|
-
# <jar destfile='${dist}/lib/app.jar' basedir='${build}/classes'/>
|
109
109
|
def test_jar_task
|
110
110
|
assert_absent @output_dir + '/Foo.jar'
|
111
111
|
@ant.property(:name => 'outputdir', :value => @output_dir)
|
112
112
|
@ant.property(:name => 'destfile', :value => '${outputdir}/Foo.jar')
|
113
113
|
@ant.jar( :destfile => "${destfile}",
|
114
114
|
:basedir => @resource_dir + '/src',
|
115
|
-
:level => '9',
|
116
115
|
:duplicate => 'preserve')
|
117
116
|
|
118
117
|
assert_exists @output_dir + '/Foo.jar'
|
119
118
|
end
|
120
119
|
|
121
|
-
# <java classname="test.Main">
|
122
|
-
# <arg value="-h"/>
|
123
|
-
# <classpath>
|
124
|
-
# <pathelement location="dist/test.jar"/>
|
125
|
-
# <pathelement path="${java.class.path}"/>
|
126
|
-
# </classpath>
|
127
|
-
# </java>
|
128
120
|
def test_java_task
|
121
|
+
|
122
|
+
return if @ant.ant_version < 1.7
|
123
|
+
|
129
124
|
FileUtils.mkdir(@output_dir + '/classes', :mode => 0775)
|
130
125
|
@ant.javac(:srcdir => @resource_dir + '/src',
|
131
126
|
:destdir => @output_dir + '/classes',
|
@@ -139,20 +134,21 @@ class TestAntwrap < Test::Unit::TestCase
|
|
139
134
|
|
140
135
|
@ant.property(:name => 'output_dir', :value => @output_dir)
|
141
136
|
@ant.property(:name => 'resource_dir', :value =>@resource_dir)
|
142
|
-
@ant.
|
137
|
+
@ant._java(:classname => 'foo.bar.FooBar', :fork => 'false') {
|
143
138
|
arg(:value => 'argOne')
|
144
139
|
classpath(){
|
145
140
|
pathelement(:location => '${output_dir}/classes')
|
146
141
|
pathelement(:location => '${resource_dir}/parent.jar')
|
147
142
|
}
|
148
143
|
arg(:value => 'argTwo')
|
149
|
-
jvmarg(:value => '
|
144
|
+
jvmarg(:value => 'client')
|
150
145
|
sysproperty(:key=> 'antwrap', :value => 'coolio')
|
151
146
|
}
|
152
147
|
end
|
153
148
|
|
154
149
|
def test_echo_task
|
155
150
|
@ant.echo(:message => "Antwrap is running an Echo task", :level => 'info')
|
151
|
+
@ant.echo(:pcdata => "<foo&bar>")
|
156
152
|
end
|
157
153
|
|
158
154
|
def test_mkdir_task
|
@@ -177,6 +173,9 @@ class TestAntwrap < Test::Unit::TestCase
|
|
177
173
|
end
|
178
174
|
|
179
175
|
def test_macrodef_task
|
176
|
+
|
177
|
+
return if @ant.ant_version < 1.6
|
178
|
+
|
180
179
|
dir = @output_dir + '/foo'
|
181
180
|
|
182
181
|
assert_absent dir
|
@@ -185,12 +184,11 @@ class TestAntwrap < Test::Unit::TestCase
|
|
185
184
|
attribute(:name => 'destination')
|
186
185
|
sequential(){
|
187
186
|
echo(:message => "Creating @{destination}")
|
188
|
-
|
187
|
+
_mkdir(:dir => "@{destination}")
|
189
188
|
}
|
190
|
-
}
|
189
|
+
}
|
191
190
|
@ant.testmacrodef(:destination => dir)
|
192
191
|
assert_exists dir
|
193
|
-
|
194
192
|
end
|
195
193
|
|
196
194
|
def test_cdata
|
@@ -198,25 +196,9 @@ class TestAntwrap < Test::Unit::TestCase
|
|
198
196
|
end
|
199
197
|
|
200
198
|
def test_ant_contrib
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
# <echo message="The value of property foo is 'bar'" />
|
205
|
-
# </then>
|
206
|
-
#
|
207
|
-
# <elseif>
|
208
|
-
# <equals arg1="${foo}" arg2="foo" />
|
209
|
-
# <then>
|
210
|
-
# <echo message="The value of property foo is 'foo'" />
|
211
|
-
# </then>
|
212
|
-
# </elseif>
|
213
|
-
#
|
214
|
-
#
|
215
|
-
# <else>
|
216
|
-
# <echo message="The value of property foo is not 'foo' or 'bar'" />
|
217
|
-
# </else>
|
218
|
-
#</if>
|
219
|
-
#
|
199
|
+
|
200
|
+
return if @ant.ant_version < 1.6
|
201
|
+
|
220
202
|
@ant.taskdef(:resource => "net/sf/antcontrib/antlib.xml")
|
221
203
|
|
222
204
|
@ant.property(:name => "bar", :value => "bar")
|
@@ -242,6 +224,7 @@ class TestAntwrap < Test::Unit::TestCase
|
|
242
224
|
}
|
243
225
|
|
244
226
|
end
|
227
|
+
|
245
228
|
private
|
246
229
|
def assert_exists(file_path)
|
247
230
|
assert(File.exists?(file_path), "Does not exist[#{file_path}]")
|
metadata
CHANGED
@@ -3,9 +3,10 @@ rubygems_version: 0.8.10
|
|
3
3
|
specification_version: 1
|
4
4
|
name: Antwrap
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: "0.
|
7
|
-
date: 2007-
|
8
|
-
summary: A JRuby module that wraps the Apache Ant build tool
|
6
|
+
version: "0.3"
|
7
|
+
date: 2007-02-19
|
8
|
+
summary: "A JRuby module that wraps the Apache Ant build tool, enabling Ant Tasks to be
|
9
|
+
invoked from a JRuby script."
|
9
10
|
require_paths:
|
10
11
|
- lib
|
11
12
|
email: caleb.powell@gmail.com
|
@@ -32,11 +33,9 @@ files:
|
|
32
33
|
- test/output
|
33
34
|
- test/tc_antwrap.rb
|
34
35
|
- test/tc_convert.rb
|
36
|
+
- test/test
|
35
37
|
- test/test-resources
|
36
|
-
- test/output
|
37
|
-
- test/output/classes/foo
|
38
|
-
- test/output/classes/foo/bar
|
39
|
-
- test/output/classes/foo/bar/FooBar.class
|
38
|
+
- test/test/output
|
40
39
|
- test/test-resources/build.xml
|
41
40
|
- test/test-resources/foo.txt
|
42
41
|
- test/test-resources/foo.zip
|
@@ -50,6 +49,7 @@ files:
|
|
50
49
|
- test/test-resources/src/foo/bar/baz
|
51
50
|
- test/test-resources/src/foo/bar/FooBar.java
|
52
51
|
- test/test-resources/src/foo/bar/baz/FooBarBaz.java
|
52
|
+
- docs/index.html
|
53
53
|
- README
|
54
54
|
- COPYING
|
55
55
|
test_files:
|
Binary file
|