Antwrap 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +504 -0
- data/README +13 -0
- data/lib/antwrap.rb +183 -0
- data/lib/convert.rb +84 -0
- data/test/output/META-INF/MANIFEST.MF +3 -0
- data/test/output/parent/FooBarParent.class +0 -0
- data/test/tc_antwrap.rb +208 -0
- data/test/tc_convert.rb +34 -0
- data/test/test-resources/build.xml +310 -0
- data/test/test-resources/foo.txt +0 -0
- data/test/test-resources/foo.zip +0 -0
- data/test/test-resources/parent-src/parent/FooBarParent.java +19 -0
- data/test/test-resources/parent.jar +0 -0
- data/test/test-resources/src/foo/bar/FooBar.java +26 -0
- data/test/test-resources/src/foo/bar/baz/FooBarBaz.java +7 -0
- metadata +64 -0
data/README
ADDED
data/lib/antwrap.rb
ADDED
@@ -0,0 +1,183 @@
|
|
1
|
+
# antwrap
|
2
|
+
#
|
3
|
+
# Copyright Caleb Powell 2007
|
4
|
+
#
|
5
|
+
# Licensed under the LGPL, see the file COPYING in the distribution
|
6
|
+
#
|
7
|
+
require 'fileutils'
|
8
|
+
require 'logger'
|
9
|
+
require 'java'
|
10
|
+
|
11
|
+
module ApacheAnt
|
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
|
+
end
|
17
|
+
|
18
|
+
module JavaLang
|
19
|
+
include_class "java.lang.System"
|
20
|
+
end
|
21
|
+
|
22
|
+
@@log = Logger.new(STDOUT)
|
23
|
+
@@log.level = Logger::DEBUG
|
24
|
+
|
25
|
+
class AntTask
|
26
|
+
private
|
27
|
+
@@task_stack = Array.new
|
28
|
+
attr_reader :unknown_element, :project, :taskname
|
29
|
+
|
30
|
+
public
|
31
|
+
def initialize(taskname, project, attributes, proc)
|
32
|
+
@taskname = taskname
|
33
|
+
@project = project
|
34
|
+
@unknown_element = ApacheAnt::UnknownElement.new(taskname)
|
35
|
+
@unknown_element.project= project
|
36
|
+
@unknown_element.namespace= ''
|
37
|
+
@unknown_element.QName= taskname
|
38
|
+
@unknown_element.taskType= taskname
|
39
|
+
@unknown_element.taskName= taskname
|
40
|
+
|
41
|
+
wrapper = ApacheAnt::RuntimeConfigurable.new(@unknown_element, @unknown_element.getTaskName());
|
42
|
+
attributes.each do |key, val|
|
43
|
+
if(key.to_s != 'pcdata')
|
44
|
+
wrapper.setAttribute(key.to_s, val)
|
45
|
+
else
|
46
|
+
wrapper.addText(val)
|
47
|
+
end
|
48
|
+
end unless attributes == nil
|
49
|
+
|
50
|
+
if proc
|
51
|
+
@@log.debug("task_stack.push #{taskname} >> #{@@task_stack}")
|
52
|
+
@@task_stack.push self
|
53
|
+
|
54
|
+
singleton_class = class << proc; self; end
|
55
|
+
singleton_class.module_eval{
|
56
|
+
def method_missing(m, *a, &proc)
|
57
|
+
@@task_stack.last().send(m, *a, &proc)
|
58
|
+
end
|
59
|
+
}
|
60
|
+
proc.instance_eval &proc
|
61
|
+
@@task_stack.pop
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def method_missing(sym, *args)
|
66
|
+
@@log.debug("AntTask.method_missing sym[#{sym.to_s}]")
|
67
|
+
begin
|
68
|
+
proc = block_given? ? Proc.new : nil
|
69
|
+
self.add(AntTask.new(sym.to_s, project, args[0], proc))
|
70
|
+
rescue StandardError
|
71
|
+
@@log.error("AntTask.method_missing error:" + $!)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def add(child)
|
76
|
+
@@log.debug("adding child[#{child.unknown_element().getTaskName()}] to [#{@unknown_element.getTaskName()}]")
|
77
|
+
@unknown_element.addChild(child.unknown_element())
|
78
|
+
@unknown_element.getRuntimeConfigurableWrapper().addChild(child.unknown_element().getRuntimeConfigurableWrapper())
|
79
|
+
end
|
80
|
+
|
81
|
+
def execute
|
82
|
+
@unknown_element.maybeConfigure
|
83
|
+
@unknown_element.execute
|
84
|
+
@executed = true
|
85
|
+
end
|
86
|
+
|
87
|
+
def was_executed?
|
88
|
+
@executed
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
class AntProject
|
93
|
+
|
94
|
+
attr :project, false
|
95
|
+
attr :declarative, true
|
96
|
+
|
97
|
+
def initialize(name='', default='', basedir='',declarative=true)
|
98
|
+
@project= ApacheAnt::Project.new
|
99
|
+
@project.name= name
|
100
|
+
@project.default= default
|
101
|
+
@project.basedir= basedir
|
102
|
+
@project.init
|
103
|
+
self.declarative= declarative
|
104
|
+
default_logger = ApacheAnt::DefaultLogger.new
|
105
|
+
default_logger.messageOutputLevel= 2
|
106
|
+
default_logger.outputPrintStream= JavaLang::System.out
|
107
|
+
default_logger.errorPrintStream= JavaLang::System.err
|
108
|
+
default_logger.emacsMode= false
|
109
|
+
@project.addBuildListener default_logger
|
110
|
+
end
|
111
|
+
|
112
|
+
def create_task(taskname, attributes, proc)
|
113
|
+
task = AntTask.new(taskname, project(), attributes, proc)
|
114
|
+
task.execute if declarative
|
115
|
+
if taskname == 'macrodef'
|
116
|
+
@@log.debug("Pushing #{attributes[:name]} to tasks")
|
117
|
+
@@tasks.push(attributes[:name])
|
118
|
+
end
|
119
|
+
task
|
120
|
+
end
|
121
|
+
|
122
|
+
def method_missing(sym, *args)
|
123
|
+
if(@@tasks.include?(sym.to_s) || @@types.include?(sym.to_s))
|
124
|
+
begin
|
125
|
+
@@log.info("AntProject.method_missing sym[#{sym.to_s}]")
|
126
|
+
proc = block_given? ? Proc.new : nil
|
127
|
+
return create_task(sym.to_s, args[0], proc)
|
128
|
+
rescue
|
129
|
+
@@log.error("Error instantiating task[#{sym.to_s}]" + $!)
|
130
|
+
end
|
131
|
+
else
|
132
|
+
@@log.error("Not an Ant Task[#{sym.to_s}]")
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
#overridden. 'mkdir' conflicts wth the rake library.
|
137
|
+
def mkdir(attributes)
|
138
|
+
create_task('mkdir', attributes, (block_given? ? Proc.new : nil))
|
139
|
+
end
|
140
|
+
|
141
|
+
#overridden. 'copy' conflicts wth the rake library.
|
142
|
+
def copy(attributes)
|
143
|
+
create_task('copy', attributes, (block_given? ? Proc.new : nil))
|
144
|
+
end
|
145
|
+
|
146
|
+
#overridden. 'java' conflicts wth the JRuby library.
|
147
|
+
def jvm(attributes)
|
148
|
+
create_task('java', attributes, (block_given? ? Proc.new : nil))
|
149
|
+
end
|
150
|
+
|
151
|
+
@@tasks = [
|
152
|
+
# standard ant tasks
|
153
|
+
'mkdir', 'javac', 'chmod', 'delete', 'copy', 'move', 'jar', 'rmic', 'cvs', 'get', 'unzip',
|
154
|
+
'unjar', 'unwar', 'echo', 'javadoc', 'zip', 'gzip', 'gunzip', 'replace', 'java', 'tstamp', 'property',
|
155
|
+
'xmlproperty', 'taskdef', 'ant', 'exec', 'tar', 'untar', 'available', 'filter', 'fixcrlf', 'patch',
|
156
|
+
'style', 'xslt', 'touch', 'signjar', 'genkey', 'antstructure', 'execon', 'antcall', 'sql', 'mail',
|
157
|
+
'fail', 'war', 'uptodate', 'apply', 'record', 'cvspass', 'typedef', 'sleep', 'pathconvert', 'ear',
|
158
|
+
'parallel', 'sequential', 'condition', 'dependset', 'bzip2', 'bunzip2', 'checksum', 'waitfor', 'input',
|
159
|
+
'loadfile', 'manifest', 'loadproperties', 'basename', 'dirname', 'cvschangelog', 'cvsversion', 'buildnumber',
|
160
|
+
'concat', 'cvstagdiff', 'tempfile', 'import', 'whichresource', 'subant', 'sync', 'defaultexcludes', 'presetdef',
|
161
|
+
'macrodef', 'nice', 'length',
|
162
|
+
# optional tasks
|
163
|
+
'image', 'script', 'netrexxc', 'renameext', 'ejbc', 'ddcreator', 'wlrun', 'wlstop', 'vssadd', 'vsscheckin', 'vsscheckout',
|
164
|
+
'vsscp', 'vsscreate', 'vssget', 'vsshistory', 'vsslabel', 'ejbjar', 'mparse', 'mmetrics', 'maudit', 'junit', 'cab',
|
165
|
+
'ftp', 'icontract', 'javacc', 'jjdoc', 'jjtree', 'stcheckout', 'stcheckin', 'stlabel', 'stlist', 'wljspc', 'jlink',
|
166
|
+
'native2ascii', 'propertyfile', 'depend', 'antlr', 'vajload', 'vajexport', 'vajimport', 'telnet', 'csc', 'ilasm',
|
167
|
+
'WsdlToDotnet', 'wsdltodotnet', 'importtypelib', 'stylebook', 'test', 'pvcs', 'p4change', 'p4delete', 'p4label', 'p4labelsync',
|
168
|
+
'p4have', 'p4sync', 'p4edit', 'p4integrate', 'p4resolve', 'p4submit', 'p4counter', 'p4revert', 'p4reopen', 'p4fstat', 'javah',
|
169
|
+
'ccupdate', 'cccheckout', 'cccheckin', 'ccuncheckout', 'ccmklbtype', 'ccmklabel', 'ccrmtype', 'cclock', 'ccunlock', 'ccmkbl',
|
170
|
+
'ccmkattr', 'ccmkelem', 'ccmkdir', 'sound', 'junitreport', 'blgenclient', 'rpm', 'xmlvalidate', 'iplanet-ejbc', 'jdepend',
|
171
|
+
'mimemail', 'ccmcheckin', 'ccmcheckout', 'ccmcheckintask', 'ccmreconfigure', 'ccmcreatetask', 'jpcoverage', 'jpcovmerge',
|
172
|
+
'jpcovreport', 'p4add', 'jspc', 'replaceregexp', 'translate', 'sosget', 'soscheckin','soscheckout','soslabel', 'echoproperties',
|
173
|
+
'splash', 'serverdeploy', 'jarlib-display', 'jarlib-manifest', 'jarlib-available', 'jarlib-resolve', 'setproxy', 'vbc', 'symlink',
|
174
|
+
'chgrp', 'chown', 'attrib', 'scp', 'sshexec', 'jsharpc', 'rexec', 'scriptdef', 'ildasm',
|
175
|
+
# deprecated ant tasks (kept for back compatibility)
|
176
|
+
'starteam', 'javadoc2', 'copydir', 'copyfile', 'deltree', 'rename']
|
177
|
+
|
178
|
+
@@types = [ 'classfileset', 'description', 'dirset', 'filelist', 'fileset', 'filterchain', 'filterreader', 'filterset', 'mapper', 'redirector',
|
179
|
+
'identitymapper', 'flattenmapper', 'globmapper', 'mergemapper', 'regexpmapper', 'packagemapper', 'unpackagemapper', 'compositemapper',
|
180
|
+
'chainedmapper', 'filtermapper', 'path', 'patternset', 'regexp', 'substitution', 'xmlcatalog', 'extensionSet', 'extension', 'libfileset',
|
181
|
+
'selector', 'zipfileset', 'scriptfilter', 'propertyset', 'assertions', 'concatfilter', 'isfileselected' ]
|
182
|
+
|
183
|
+
end
|
data/lib/convert.rb
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# antwrap
|
2
|
+
#
|
3
|
+
# Copyright Caleb Powell 2007
|
4
|
+
#
|
5
|
+
# Licensed under the LGPL, see the file COPYING in the distribution
|
6
|
+
#
|
7
|
+
require 'rexml/document'
|
8
|
+
@outfile = File.new('/Users/caleb/projects/antwrap/test/output/Rakefile.rb', 'w+')
|
9
|
+
xml = REXML::Document.new(File.open('/Users/caleb/projects/antwrap/test/test-resources/build.xml'))
|
10
|
+
|
11
|
+
|
12
|
+
def create_symbol(str)
|
13
|
+
str = rubyize(str)
|
14
|
+
return str.gsub(/(\w*[^,\s])/, ':\1')
|
15
|
+
end
|
16
|
+
def rubyize(str)
|
17
|
+
if (str == nil)
|
18
|
+
str = ''
|
19
|
+
else
|
20
|
+
str = str.gsub(/(\w*)[\-|\.](\w*)/, '\1_\2')
|
21
|
+
end
|
22
|
+
return str
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
@outfile.print "require_gem 'Antwrap'\n"
|
27
|
+
@outfile.print "@ant = AntProject.new()\n"
|
28
|
+
@one_tab= ' '
|
29
|
+
def print_task(task, tab=@one_tab, prefix='')
|
30
|
+
task_name = rubyize(task.name)
|
31
|
+
@outfile.print "#{tab}#{prefix}#{task_name}("
|
32
|
+
|
33
|
+
if(task_name == 'macrodef')
|
34
|
+
task.attributes['name'] = rubyize(task.attributes['name'])
|
35
|
+
end
|
36
|
+
isFirst = true;
|
37
|
+
task.attributes.each do |key, value|
|
38
|
+
if !isFirst
|
39
|
+
@outfile.print(",\n#{tab+@one_tab}")
|
40
|
+
end
|
41
|
+
@outfile.print ":#{key} => \"#{value}\""
|
42
|
+
isFirst = false;
|
43
|
+
end
|
44
|
+
|
45
|
+
if task.has_text?
|
46
|
+
pcdata = task.texts().join
|
47
|
+
if(pcdata.strip() != '')
|
48
|
+
@outfile.print ":pcdata => \"#{pcdata}\""
|
49
|
+
end
|
50
|
+
end
|
51
|
+
@outfile.print ")"
|
52
|
+
|
53
|
+
|
54
|
+
if task.elements.size > 0
|
55
|
+
@outfile.print "{"
|
56
|
+
task.elements.each do |child|
|
57
|
+
@outfile.print "\n"
|
58
|
+
print_task(child, (tab+@one_tab), '')
|
59
|
+
end
|
60
|
+
@outfile.print "\n#{tab}}"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
xml.elements.each("/project/*") do |node|
|
65
|
+
if node.name != 'target'
|
66
|
+
print_task(node, '', '@ant.')
|
67
|
+
@outfile.print "\n\n"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
xml.elements.each("/project/target") do |node|
|
72
|
+
|
73
|
+
task = "\ntask " + create_symbol(node.attributes['name']) +
|
74
|
+
" => [" + create_symbol(node.attributes['depends']) + "] do\n"
|
75
|
+
|
76
|
+
@outfile.print task
|
77
|
+
|
78
|
+
node.elements.each do |child|
|
79
|
+
print_task(child, @one_tab, '@ant.')
|
80
|
+
@outfile.print "\n"
|
81
|
+
end
|
82
|
+
@outfile.print "end\n"
|
83
|
+
end
|
84
|
+
|
Binary file
|
data/test/tc_antwrap.rb
ADDED
@@ -0,0 +1,208 @@
|
|
1
|
+
# antwrap
|
2
|
+
#
|
3
|
+
# Copyright Caleb Powell 2007
|
4
|
+
#
|
5
|
+
# Licensed under the LGPL, see the file COPYING in the distribution
|
6
|
+
#
|
7
|
+
require 'test/unit'
|
8
|
+
require 'fileutils'
|
9
|
+
require '../lib/antwrap.rb'
|
10
|
+
|
11
|
+
class TestAntwrap < Test::Unit::TestCase
|
12
|
+
|
13
|
+
def setup
|
14
|
+
# ENV is broken as of JRuby 0.9.2 but patched in 0.9.3 (see: http://jira.codehaus.org/browse/JRUBY-349)
|
15
|
+
# @output_dir = ENV['PWD'] + '/output'
|
16
|
+
# @resource_dir = ENV['PWD'] + '/test-resources'
|
17
|
+
# The following is a workaround
|
18
|
+
current_dir = Java::java.lang.System.getProperty("user.dir")
|
19
|
+
@ant = AntProject.new("testProject", "", current_dir, true)
|
20
|
+
@output_dir = current_dir + '/test/output'
|
21
|
+
@resource_dir = current_dir + '/test/test-resources'
|
22
|
+
|
23
|
+
if File.exists?(@output_dir)
|
24
|
+
FileUtils.remove_dir(@output_dir)
|
25
|
+
end
|
26
|
+
FileUtils.mkdir(@output_dir, :mode => 0775)
|
27
|
+
end
|
28
|
+
|
29
|
+
def teardown
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_unzip_task
|
34
|
+
assert_absent @output_dir + '/parent/FooBarParent.class'
|
35
|
+
task = @ant.unzip(:src => @resource_dir + '/parent.jar',
|
36
|
+
:dest => @output_dir)
|
37
|
+
|
38
|
+
assert_exists @output_dir + '/parent/FooBarParent.class'
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_copyanddelete_task
|
42
|
+
file = @output_dir + '/foo.txt'
|
43
|
+
assert_absent file
|
44
|
+
@ant.copy(:file => @resource_dir + '/foo.txt',
|
45
|
+
:todir => @output_dir)
|
46
|
+
assert_exists file
|
47
|
+
|
48
|
+
@ant.delete(:file => file)
|
49
|
+
assert_absent file
|
50
|
+
end
|
51
|
+
|
52
|
+
# <javac srcdir='${src}'
|
53
|
+
# destdir='${build}'
|
54
|
+
# classpath='xyz.jar'
|
55
|
+
# debug='on'
|
56
|
+
# source='1.4'/>
|
57
|
+
def test_javac_task
|
58
|
+
FileUtils.mkdir(@output_dir + '/classes', :mode => 0775)
|
59
|
+
|
60
|
+
assert_absent @output_dir + '/classes/foo/bar/FooBar.class'
|
61
|
+
|
62
|
+
@ant.javac(:srcdir => @resource_dir + '/src',
|
63
|
+
:destdir => @output_dir + '/classes',
|
64
|
+
:debug => 'on',
|
65
|
+
:verbose => 'no',
|
66
|
+
:fork => 'no',
|
67
|
+
:failonerror => 'yes',
|
68
|
+
:includes => 'foo/bar/**',
|
69
|
+
:excludes => 'foo/bar/baz/**',
|
70
|
+
:classpath => @resource_dir + '/parent.jar')
|
71
|
+
|
72
|
+
assert_exists @output_dir + '/classes/foo/bar/FooBar.class'
|
73
|
+
assert_absent @output_dir + '/classes/foo/bar/baz/FooBarBaz.class'
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_javac_task_with_property
|
77
|
+
FileUtils.mkdir(@output_dir + '/classes', :mode => 0775)
|
78
|
+
|
79
|
+
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
|
+
@ant.property(:name => 'pattern', :value => '**/*.jar')
|
87
|
+
@ant.property(:name => 'resource_dir', :value => @resource_dir)
|
88
|
+
@ant.path(:id => 'common.class.path'){
|
89
|
+
fileset(:dir => '${resource_dir}'){
|
90
|
+
include(:name => '${pattern}')
|
91
|
+
}
|
92
|
+
}
|
93
|
+
|
94
|
+
@ant.javac(:srcdir => @resource_dir + '/src',
|
95
|
+
:destdir => @output_dir + '/classes',
|
96
|
+
:debug => 'on',
|
97
|
+
:verbose => 'no',
|
98
|
+
:fork => 'no',
|
99
|
+
:failonerror => 'yes',
|
100
|
+
:includes => 'foo/bar/**',
|
101
|
+
:excludes => 'foo/bar/baz/**',
|
102
|
+
:classpathref => 'common.class.path')
|
103
|
+
|
104
|
+
assert_exists @output_dir + '/classes/foo/bar/FooBar.class'
|
105
|
+
assert_absent @output_dir + '/classes/foo/bar/baz/FooBarBaz.class'
|
106
|
+
end
|
107
|
+
|
108
|
+
# <jar destfile='${dist}/lib/app.jar' basedir='${build}/classes'/>
|
109
|
+
def test_jar_task
|
110
|
+
assert_absent @output_dir + '/Foo.jar'
|
111
|
+
@ant.property(:name => 'outputdir', :value => @output_dir)
|
112
|
+
@ant.property(:name => 'destfile', :value => '${outputdir}/Foo.jar')
|
113
|
+
@ant.jar( :destfile => "${destfile}",
|
114
|
+
:basedir => @resource_dir + '/src',
|
115
|
+
:level => '9',
|
116
|
+
:duplicate => 'preserve')
|
117
|
+
|
118
|
+
assert_exists @output_dir + '/Foo.jar'
|
119
|
+
end
|
120
|
+
|
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
|
+
def test_java_task
|
129
|
+
FileUtils.mkdir(@output_dir + '/classes', :mode => 0775)
|
130
|
+
@ant.javac(:srcdir => @resource_dir + '/src',
|
131
|
+
:destdir => @output_dir + '/classes',
|
132
|
+
:debug => 'on',
|
133
|
+
:verbose => 'no',
|
134
|
+
:fork => 'no',
|
135
|
+
:failonerror => 'yes',
|
136
|
+
:includes => 'foo/bar/**',
|
137
|
+
:excludes => 'foo/bar/baz/**',
|
138
|
+
:classpath => @resource_dir + '/parent.jar')
|
139
|
+
|
140
|
+
@ant.property(:name => 'output_dir', :value => @output_dir)
|
141
|
+
@ant.property(:name => 'resource_dir', :value =>@resource_dir)
|
142
|
+
@ant.jvm(:classname => 'foo.bar.FooBar', :fork => 'no') {
|
143
|
+
arg(:value => 'argOne')
|
144
|
+
classpath(){
|
145
|
+
pathelement(:location => '${output_dir}/classes')
|
146
|
+
pathelement(:location => '${resource_dir}/parent.jar')
|
147
|
+
}
|
148
|
+
arg(:value => 'argTwo')
|
149
|
+
jvmarg(:value => 'server')
|
150
|
+
sysproperty(:key=> 'antwrap', :value => 'coolio')
|
151
|
+
}
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_echo_task
|
155
|
+
@ant.echo(:message => "Antwrap is running an Echo task", :level => 'info')
|
156
|
+
end
|
157
|
+
|
158
|
+
def test_mkdir_task
|
159
|
+
dir = @output_dir + '/foo'
|
160
|
+
|
161
|
+
assert_absent dir
|
162
|
+
|
163
|
+
@ant.mkdir(:dir => dir)
|
164
|
+
|
165
|
+
assert_exists dir
|
166
|
+
end
|
167
|
+
|
168
|
+
def test_mkdir_task_with_property
|
169
|
+
dir = @output_dir + '/foo'
|
170
|
+
|
171
|
+
assert_absent dir
|
172
|
+
|
173
|
+
@ant.property(:name => 'outputProperty', :value => dir)
|
174
|
+
@ant.mkdir(:dir => "${outputProperty}")
|
175
|
+
|
176
|
+
assert_exists dir
|
177
|
+
end
|
178
|
+
|
179
|
+
def test_macrodef_task
|
180
|
+
dir = @output_dir + '/foo'
|
181
|
+
|
182
|
+
assert_absent dir
|
183
|
+
|
184
|
+
@ant.macrodef(:name => 'testmacrodef'){
|
185
|
+
attribute(:name => 'destination')
|
186
|
+
sequential(){
|
187
|
+
echo(:message => "Creating @{destination}")
|
188
|
+
mkdir(:dir => "@{destination}")
|
189
|
+
}
|
190
|
+
}
|
191
|
+
@ant.testmacrodef(:destination => dir)
|
192
|
+
assert_exists dir
|
193
|
+
|
194
|
+
end
|
195
|
+
|
196
|
+
def test_cdata
|
197
|
+
@ant.echo(:pcdata => "Foobar & <><><>")
|
198
|
+
end
|
199
|
+
|
200
|
+
private
|
201
|
+
def assert_exists(file_path)
|
202
|
+
assert(File.exists?(file_path), "Does not exist[#{file_path}]")
|
203
|
+
end
|
204
|
+
|
205
|
+
def assert_absent(file_path)
|
206
|
+
assert(!File.exists?(file_path), "Should not exist[#{file_path}]")
|
207
|
+
end
|
208
|
+
end
|