atoulme-Antwrap 0.7.2 → 0.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gemtest ADDED
File without changes
data/Rakefile CHANGED
@@ -22,23 +22,24 @@ def apply_default_hoe_properties(hoe)
22
22
  hoe.rubyforge_name = 'antwrap'
23
23
  hoe.author = 'Caleb Powell'
24
24
  hoe.email = 'caleb.powell@gmail.com'
25
- hoe.url = 'http://rubyforge.org/projects/antwrap/'
25
+ hoe.urls = ['http://rubyforge.org/projects/antwrap/']
26
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
27
  hoe.description = hoe.paragraphs_of('README.txt', 2..5).join("\n\n")
28
28
  hoe.changes = hoe.paragraphs_of('History.txt', 0..1).join("\n\n")
29
+ hoe.version = Antwrap::VERSION
29
30
  puts "Current changes in this release_______________ "
30
31
  puts "#{hoe.changes}"
31
32
  puts "----------------------------------------------"
32
33
  end
33
34
 
34
35
  #builds the MRI Gem
35
- Hoe.new('atoulme-Antwrap', Antwrap::VERSION) do |hoe|
36
+ Hoe.spec('atoulme-Antwrap') do |hoe|
36
37
  apply_default_hoe_properties hoe
37
38
  hoe.extra_deps << ["rjb", ">= 1.0.3"]
38
39
  end
39
40
 
40
41
  #builds the JRuby Gem
41
- Hoe.new('atoulme-Antwrap', Antwrap::VERSION) do |hoe|
42
+ Hoe.spec('atoulme-Antwrap') do |hoe|
42
43
  apply_default_hoe_properties hoe
43
44
  hoe.spec_extras = {:platform => 'java'}
44
45
  end
@@ -46,4 +47,4 @@ end
46
47
  Rake::TestTask.new('test') do |t|
47
48
  t.ruby_opts = ['-r test/load_devcreek.rb']
48
49
  t.test_files = ['test/*test.rb']
49
- end
50
+ end
data/lib/ant_project.rb CHANGED
@@ -117,7 +117,7 @@ module Antwrap
117
117
  end
118
118
 
119
119
  rescue
120
- @logger.error("Error instantiating '#{sym.to_s}' task: " + $!)
120
+ @logger.error("Error instantiating '#{sym.to_s}' task: " + $!.to_s)
121
121
  raise
122
122
  ensure
123
123
  @task_stack.pop
data/lib/antwrap.rb CHANGED
@@ -18,5 +18,5 @@ module Antwrap
18
18
  autoload :ApacheAnt, 'ant_libraries.rb'
19
19
  autoload :JavaLang, 'ant_libraries.rb'
20
20
  autoload :XmlOrg, 'ant_libraries.rb'
21
- VERSION = "0.7.2"
21
+ VERSION = "0.7.3"
22
22
  end
@@ -0,0 +1,262 @@
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
+ require 'test/unit'
15
+ require 'fileutils'
16
+ $LOAD_PATH.push(FileUtils::pwd + '/lib')
17
+ require 'antwrap'
18
+ require 'logger'
19
+
20
+ class AntwrapTest < Test::Unit::TestCase
21
+
22
+ def setup
23
+ @output_dir = FileUtils::pwd + File::SEPARATOR + 'test' + File::SEPARATOR + 'output'
24
+ @resource_dir = FileUtils::pwd + File::SEPARATOR + 'test' + File::SEPARATOR + 'test-resources'
25
+
26
+ @ant_home = @resource_dir + File::SEPARATOR + "apache-ant-1.7.0"
27
+ # @ant_home = "/Users/caleb/tools/apache-ant-1.6.5"
28
+ # @ant_home = "/Users/caleb/tools/apache-ant-1.5.4"
29
+ @ant_proj_props = {:name=>"testProject", :basedir=>FileUtils::pwd, :declarative=>true,
30
+ :logger=>Logger.new(STDOUT), :loglevel=>Logger::DEBUG, :ant_home => @ant_home}
31
+ @ant = Antwrap::AntProject.new(@ant_proj_props)
32
+
33
+ if File.exists?(@output_dir)
34
+ FileUtils.remove_dir(@output_dir)
35
+ end
36
+ FileUtils.mkdir(@output_dir, :mode => 0775)
37
+ end
38
+
39
+ def test_antproject_init
40
+ @ant_proj_props = {:name=>"testProject", :declarative=>true,
41
+ :logger=>Logger.new(STDOUT), :loglevel=>Logger::ERROR}
42
+ ant_proj = Antwrap::AntProject.new(@ant_proj_props)
43
+ assert(@ant_proj_props[:name] == ant_proj.name())
44
+ # assert(FileUtils::pwd == ant_proj.basedir())
45
+ assert(@ant_proj_props[:declarative] == ant_proj.declarative())
46
+ assert(@ant_proj_props[:logger] == ant_proj.logger())
47
+ end
48
+
49
+ def test_unzip_task
50
+ assert_absent @output_dir + '/parent/FooBarParent.class'
51
+ @ant.unzip(:src => @resource_dir + '/parent.jar', :dest => @output_dir)
52
+ assert_exists @output_dir + '/parent/FooBarParent.class'
53
+ end
54
+
55
+ def test_copyanddelete_task
56
+ file = @output_dir + '/foo.txt'
57
+ assert_absent file
58
+ @ant.copy(:file => @resource_dir + '/foo.txt',
59
+ :todir => @output_dir)
60
+ assert_exists file
61
+
62
+ @ant.delete(:file => file)
63
+ assert_absent file
64
+ end
65
+
66
+ def test_javac_task
67
+ FileUtils.mkdir(@output_dir + '/classes', :mode => 0775)
68
+
69
+ assert_absent @output_dir + '/classes/foo/bar/FooBar.class'
70
+
71
+ @ant.javac(:srcdir => @resource_dir + '/src',
72
+ :destdir => @output_dir + '/classes',
73
+ :debug => 'on',
74
+ :verbose => 'no',
75
+ :fork => 'no',
76
+ :failonerror => 'yes',
77
+ :includes => 'foo/bar/**',
78
+ :excludes => 'foo/bar/baz/**',
79
+ :classpath => @resource_dir + '/parent.jar')
80
+
81
+ assert_exists @output_dir + '/classes/foo/bar/FooBar.class'
82
+ assert_absent @output_dir + '/classes/foo/bar/baz/FooBarBaz.class'
83
+ end
84
+
85
+ def test_javac_task_with_property
86
+ FileUtils.mkdir(@output_dir + '/classes', :mode => 0775)
87
+
88
+ assert_absent @output_dir + '/classes/foo/bar/FooBar.class'
89
+ @ant.property(:name => 'pattern', :value => '**/*.jar')
90
+ @ant.property(:name => 'resource_dir', :value => @resource_dir)
91
+ @ant.path(:id => 'common.class.path'){
92
+ @ant.fileset(:dir => '${resource_dir}'){
93
+ @ant.include(:name => '${pattern}')
94
+ }
95
+ }
96
+ puts "Resource dir: #{@resource_dir}"
97
+ @ant.javac(:srcdir => @resource_dir + '/src',
98
+ :destdir => @output_dir + '/classes',
99
+ :debug => true,
100
+ :verbose => true,
101
+ :fork => 'no',
102
+ :failonerror => 'blahblahblah',
103
+ :includes => 'foo/bar/**',
104
+ :excludes => 'foo/bar/baz/**',
105
+ :classpathref => 'common.class.path')
106
+
107
+ assert_exists @output_dir + '/classes/foo/bar/FooBar.class'
108
+ assert_absent @output_dir + '/classes/foo/bar/baz/FooBarBaz.class'
109
+ end
110
+
111
+ def test_jar_task
112
+ assert_absent @output_dir + '/Foo.jar'
113
+ @ant.property(:name => 'outputdir', :value => @output_dir)
114
+ @ant.property(:name => 'destfile', :value => '${outputdir}/Foo.jar')
115
+ @ant.jar( :destfile => "${destfile}",
116
+ :basedir => @resource_dir + '/src',
117
+ :duplicate => 'preserve')
118
+
119
+ assert_exists @output_dir + '/Foo.jar'
120
+ end
121
+
122
+ def test_java_task
123
+
124
+ return if @ant.ant_version < 1.7
125
+ puts "executing java task"
126
+ FileUtils.mkdir(@output_dir + '/classes', :mode => 0775)
127
+ @ant.javac(:srcdir => @resource_dir + '/src',
128
+ :destdir => @output_dir + '/classes',
129
+ :debug => 'on',
130
+ :verbose => 'no',
131
+ :fork => 'no',
132
+ :failonerror => 'yes',
133
+ :includes => 'foo/bar/**',
134
+ :excludes => 'foo/bar/baz/**',
135
+ :classpath => @resource_dir + '/parent.jar')
136
+
137
+ @ant.property(:name => 'output_dir', :value => @output_dir)
138
+ @ant.property(:name => 'resource_dir', :value =>@resource_dir)
139
+ @ant.java(:classname => 'foo.bar.FooBar', :fork => 'false') {|ant|
140
+ ant.arg(:value => 'argOne')
141
+ ant.classpath(){
142
+ ant.pathelement(:location => '${output_dir}/classes')
143
+ ant.pathelement(:location => '${resource_dir}/parent.jar')
144
+ }
145
+ ant.arg(:value => 'argTwo')
146
+ ant.jvmarg(:value => 'client')
147
+ ant.sysproperty(:key=> 'antwrap', :value => 'coolio')
148
+ }
149
+ end
150
+
151
+ def test_echo_task
152
+ msg = "Antwrap is running an Echo task"
153
+ @ant.echo(:message => msg, :level => 'info')
154
+ @ant.echo(:message => 100000, :level => 'info')
155
+ @ant.echo(:pcdata => 1000)
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
+
181
+ return if @ant.ant_version < 1.6
182
+
183
+ dir = @output_dir + '/foo'
184
+
185
+ assert_absent dir
186
+
187
+ @ant.macrodef(:name => 'testmacrodef'){|ant|
188
+ ant.attribute(:name => 'destination')
189
+ ant.sequential(){
190
+ ant.echo(:message => "Creating @{destination}")
191
+ ant._mkdir(:dir => "@{destination}")
192
+ }
193
+ }
194
+ @ant.testmacrodef(:destination => dir)
195
+ assert_exists dir
196
+ end
197
+
198
+ def test_cdata
199
+ @ant.echo(:pcdata => "Foobar &amp; <><><>")
200
+ end
201
+
202
+ def test_ant_contrib
203
+
204
+ return if @ant.ant_version() < 1.6
205
+
206
+ @ant.taskdef(:resource => "net/sf/antcontrib/antlib.xml")
207
+
208
+ @ant.property(:name => "bar", :value => "bar")
209
+ @ant._if(){|ant|
210
+ ant._equals(:arg1 => "${bar}", :arg2 => "bar")
211
+ ant._then(){
212
+ ant.echo(:message => "if 1 is equal")
213
+ }
214
+ ant._else(){
215
+ ant.echo(:message => "if 1 is not equal")
216
+ }
217
+ }
218
+
219
+ @ant.property(:name => "baz", :value => "foo")
220
+ @ant._if(){|ant|
221
+ ant._equals(:arg1 => "${baz}", :arg2 => "bar")
222
+ ant._then(){
223
+ ant.echo(:message => "if 2 is equal")
224
+ }
225
+ ant._else(){
226
+ ant.echo(:message => "if 2 is not equal")
227
+ }
228
+ }
229
+
230
+ end
231
+
232
+ def test_tstamp
233
+ @ant.tstamp
234
+ end
235
+
236
+ def test_array_argument
237
+ begin
238
+ @ant.echo(:message => ['This', 'should', 'fail', 'because', 'Arrays', 'are', 'not', 'supported'])
239
+ add_failure "Arrays not permitted"
240
+ rescue ArgumentError
241
+ end
242
+ end
243
+
244
+ def test_declarative
245
+ @ant = Antwrap::AntProject.new({:declarative=>false,:loglevel=>Logger::DEBUG, :ant_home => @ant_home})
246
+ echo = @ant.echo(:message => "Echo")
247
+ assert_not_nil(echo)
248
+
249
+ @ant = Antwrap::AntProject.new({:declarative=>true,:loglevel=>Logger::DEBUG, :ant_home => @ant_home})
250
+ echo = @ant.echo(:message => "Echo")
251
+ assert_nil(echo)
252
+ end
253
+
254
+ private
255
+ def assert_exists(file_path)
256
+ assert(File.exists?(file_path), "Does not exist[#{file_path}]")
257
+ end
258
+
259
+ def assert_absent(file_path)
260
+ assert(!File.exists?(file_path), "Should not exist[#{file_path}]")
261
+ end
262
+ end
@@ -0,0 +1,24 @@
1
+ # testresult_spec.rb
2
+ #
3
+ # Copyright Caleb Powell 2007
4
+ #
5
+ # Licensed under the LGPL, see the file README.txt in the distribution
6
+ require 'fileutils'
7
+ $LOAD_PATH.push(FileUtils::pwd + '/lib')
8
+ require 'java_adapter.rb'
9
+
10
+ describe Antwrap::JavaAdapter do
11
+
12
+ it "should extract the Java class name from a string" do
13
+ Antwrap::JavaAdapter.extract_class_name("java.lang.String").should eql("String")
14
+ Antwrap::JavaAdapter.extract_class_name("Foo").should eql("Foo")
15
+ Antwrap::JavaAdapter.extract_class_name("java.lang.__String").should eql("__String")
16
+ Antwrap::JavaAdapter.extract_class_name("java.lang.Outer$Inner").should eql("Outer$Inner")
17
+ end
18
+
19
+ it "should import a class" do
20
+ result = Antwrap::JavaAdapter.import_class("java.lang.String")
21
+ result.should_not be_nil
22
+ result.should respond_to(:new)
23
+ end
24
+ end
metadata CHANGED
@@ -1,58 +1,82 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: atoulme-Antwrap
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.7.3
4
5
  prerelease:
5
- version: 0.7.2
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Caleb Powell
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-07-06 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2012-11-12 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: rjb
17
- prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
19
17
  none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
23
21
  version: 1.0.3
24
22
  type: :runtime
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
27
- name: hoe
28
23
  prerelease: false
29
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 1.0.3
30
+ - !ruby/object:Gem::Dependency
31
+ name: rdoc
32
+ requirement: !ruby/object:Gem::Requirement
30
33
  none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: 2.3.3
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '3.10'
35
38
  type: :development
36
- version_requirements: *id002
37
- description: "\tA Ruby module that wraps the Apache Ant build tool. Antwrap can be used to invoke Ant Tasks from a Ruby or a JRuby script.\n\n\
38
- == FEATURES/PROBLEMS:\n\n\
39
- \tAntwrap runs on the native Ruby interpreter via the RJB (Ruby Java Bridge gem) and on the JRuby interpreter. Antwrap is compatible with Ant versions 1.5.4, \n\
40
- \t1.6.5 and 1.7.0. For more information, \tsee the Project Info (http://rubyforge.org/projects/antwrap/) page. \n\
41
- \t \n\
42
- == SYNOPSIS:\n\n\
43
- \tAntwrap is a Ruby library that can be used to invoke Ant tasks. It is being used in the Buildr (http://incubator.apache.org/buildr/) project to execute \n\
44
- \tAnt (http://ant.apache.org/) tasks in a Java project. If you are tired of fighting with Ant or Maven XML files in your Java project, take some time to \n\
45
- \tcheck out Buildr!"
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '3.10'
46
+ - !ruby/object:Gem::Dependency
47
+ name: hoe
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '3.2'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '3.2'
62
+ description: ! "\tA Ruby module that wraps the Apache Ant build tool. Antwrap can
63
+ be used to invoke Ant Tasks from a Ruby or a JRuby script.\n\n== FEATURES/PROBLEMS:\n\n\tAntwrap
64
+ runs on the native Ruby interpreter via the RJB (Ruby Java Bridge gem) and on the
65
+ JRuby interpreter. Antwrap is compatible with Ant versions 1.5.4, \n\t1.6.5 and
66
+ 1.7.0. For more information, \tsee the Project Info (http://rubyforge.org/projects/antwrap/)
67
+ page. \n\t \n== SYNOPSIS:\n\n\tAntwrap is a Ruby library that can be used to invoke
68
+ Ant tasks. It is being used in the Buildr (http://incubator.apache.org/buildr/)
69
+ project to execute \n\tAnt (http://ant.apache.org/) tasks in a Java project. If
70
+ you are tired of fighting with Ant or Maven XML files in your Java project, take
71
+ some time to \n\tcheck out Buildr!"
46
72
  email: caleb.powell@gmail.com
47
73
  executables: []
48
-
49
74
  extensions: []
50
-
51
- extra_rdoc_files:
75
+ extra_rdoc_files:
52
76
  - History.txt
53
77
  - Manifest.txt
54
78
  - README.txt
55
- files:
79
+ files:
56
80
  - History.txt
57
81
  - LICENSE
58
82
  - Manifest.txt
@@ -69,33 +93,36 @@ files:
69
93
  - lib/antwrap_utilities.rb
70
94
  - lib/ant_libraries.rb
71
95
  - lib/java_adapter.rb
96
+ - test/antwrap_test.rb
97
+ - test/javaadapter_spec.rb
98
+ - .gemtest
72
99
  homepage: http://rubyforge.org/projects/antwrap/
73
100
  licenses: []
74
-
75
101
  post_install_message:
76
- rdoc_options:
102
+ rdoc_options:
77
103
  - --main
78
104
  - README.txt
79
- require_paths:
105
+ require_paths:
80
106
  - lib
81
- required_ruby_version: !ruby/object:Gem::Requirement
107
+ required_ruby_version: !ruby/object:Gem::Requirement
82
108
  none: false
83
- requirements:
84
- - - ">="
85
- - !ruby/object:Gem::Version
86
- version: "0"
87
- required_rubygems_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ! '>='
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
114
  none: false
89
- requirements:
90
- - - ">="
91
- - !ruby/object:Gem::Version
92
- version: "0"
115
+ requirements:
116
+ - - ! '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
93
119
  requirements: []
94
-
95
120
  rubyforge_project: antwrap
96
- rubygems_version: 1.8.5
121
+ rubygems_version: 1.8.24
97
122
  signing_key:
98
123
  specification_version: 3
99
- 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.
100
- test_files: []
101
-
124
+ summary: A Ruby module that wraps the Apache Ant build tool. Antwrap can be used to
125
+ invoke Ant Tasks from a Ruby or a JRuby script.
126
+ test_files:
127
+ - test/antwrap_test.rb
128
+ - test/javaadapter_spec.rb