malagant-raw 0.4.13
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/History.txt +6 -0
- data/LICENSE +201 -0
- data/Manifest.txt +5 -0
- data/README.txt +28 -0
- data/Rakefile +49 -0
- data/bin/raw +3 -0
- data/lib/ant_libraries.rb +31 -0
- data/lib/ant_project.rb +144 -0
- data/lib/ant_task.rb +125 -0
- data/lib/raw.rb +27 -0
- data/lib/raw_runner.rb +97 -0
- data/lib/raw_utilities.rb +32 -0
- data/lib/rjb_adapter.rb +63 -0
- data/spec/javaadapter_spec.rb +17 -0
- data/spec/raw_antproject_spec.rb +219 -0
- data/spec/spec_helper.rb +5 -0
- metadata +82 -0
data/History.txt
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
data/Manifest.txt
ADDED
data/README.txt
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
= About RAW
|
|
2
|
+
|
|
3
|
+
RAW is a gem that provides a wrapper for ant.
|
|
4
|
+
You can use RAW to write ant scripts in Ruby instead of XML.
|
|
5
|
+
|
|
6
|
+
More information will be provided asap.
|
|
7
|
+
|
|
8
|
+
== REQUIREMENTS
|
|
9
|
+
|
|
10
|
+
To use RAW you need JRuby oder the gem RJB (Ruby Java Bridge)
|
|
11
|
+
|
|
12
|
+
== INSTALL
|
|
13
|
+
|
|
14
|
+
gem install malagant-raw
|
|
15
|
+
|
|
16
|
+
== LICENSE
|
|
17
|
+
|
|
18
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
19
|
+
you may not use this file except in compliance with the License.
|
|
20
|
+
You may obtain a copy of the License at
|
|
21
|
+
|
|
22
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
23
|
+
|
|
24
|
+
Unless required by applicable law or agreed to in writing, software
|
|
25
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
26
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
27
|
+
See the License for the specific language governing permissions and limitations
|
|
28
|
+
under the License.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
2
|
+
# you may not use this file except in compliance with the License.
|
|
3
|
+
# You may obtain a copy of the License at
|
|
4
|
+
#
|
|
5
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
#
|
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
+
# See the License for the specific language governing permissions and limitations
|
|
11
|
+
# under the License.
|
|
12
|
+
|
|
13
|
+
$LOAD_PATH.push(FileUtils::pwd + '/lib')
|
|
14
|
+
require 'rubygems'
|
|
15
|
+
require 'hoe'
|
|
16
|
+
require 'lib/raw'
|
|
17
|
+
require 'rake/testtask'
|
|
18
|
+
|
|
19
|
+
def apply_default_hoe_properties(hoe)
|
|
20
|
+
hoe.remote_rdoc_dir = ''
|
|
21
|
+
hoe.rubyforge_name = 'raw'
|
|
22
|
+
hoe.author = 'Michael Johann'
|
|
23
|
+
hoe.email = 'malagant1969@gmail.com'
|
|
24
|
+
hoe.url = 'http://kenai.com/projects/raw/'
|
|
25
|
+
hoe.summary = 'A Ruby module that wraps the Apache Ant build tool.
|
|
26
|
+
RAW can be used to invoke Ant Tasks from a Ruby or a JRuby script.'
|
|
27
|
+
hoe.description = hoe.paragraphs_of('README', 2..5).join("\n\n")
|
|
28
|
+
# hoe.changes = hoe.paragraphs_of('HISTORY', 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('raw', RAW::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('raw', RAW::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/bin/raw
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
2
|
+
# you may not use this file except in compliance with the License.
|
|
3
|
+
# You may obtain a copy of the License at
|
|
4
|
+
#
|
|
5
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
#
|
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
+
# See the License for the specific language governing permissions and limitations
|
|
11
|
+
# under the License.
|
|
12
|
+
require 'rjb_adapter'
|
|
13
|
+
|
|
14
|
+
module RAW
|
|
15
|
+
module ApacheAnt
|
|
16
|
+
DefaultLogger = RjbAdapter.import_class("org.apache.tools.ant.DefaultLogger")
|
|
17
|
+
Main = RjbAdapter.import_class("org.apache.tools.ant.Main")
|
|
18
|
+
Project = RjbAdapter.import_class("org.apache.tools.ant.Project")
|
|
19
|
+
RuntimeConfigurable = RjbAdapter.import_class("org.apache.tools.ant.RuntimeConfigurable")
|
|
20
|
+
Target = RjbAdapter.import_class("org.apache.tools.ant.Target")
|
|
21
|
+
UnknownElement = RjbAdapter.import_class("org.apache.tools.ant.UnknownElement")
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
module JavaLang
|
|
25
|
+
System = RjbAdapter.import_class("java.lang.System")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
module XmlSax
|
|
29
|
+
AttributeListImpl = RjbAdapter.import_class("org.xml.sax.helpers.AttributeListImpl")
|
|
30
|
+
end
|
|
31
|
+
end
|
data/lib/ant_project.rb
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
2
|
+
# you may not use this file except in compliance with the License.
|
|
3
|
+
# You may obtain a copy of the License at
|
|
4
|
+
#
|
|
5
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
#
|
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
+
# See the License for the specific language governing permissions and limitations
|
|
11
|
+
# under the License.
|
|
12
|
+
|
|
13
|
+
module RAW
|
|
14
|
+
class AntProject
|
|
15
|
+
require 'logger'
|
|
16
|
+
require 'ant_task'
|
|
17
|
+
require 'ant_libraries'
|
|
18
|
+
|
|
19
|
+
private
|
|
20
|
+
@@classes_loaded = false
|
|
21
|
+
|
|
22
|
+
# This is for further initializations inside the constructor
|
|
23
|
+
def init_project(options)
|
|
24
|
+
|
|
25
|
+
@project = RAW::ApacheAnt::Project.new
|
|
26
|
+
@project.name = options[:name] || ''
|
|
27
|
+
@project.default = ''
|
|
28
|
+
@project.basedir = options[:basedir] || FileUtils::pwd
|
|
29
|
+
@project.init
|
|
30
|
+
|
|
31
|
+
if options[:declarative] == nil
|
|
32
|
+
@logger.debug("declarative is nil")
|
|
33
|
+
self.declarative= true
|
|
34
|
+
else
|
|
35
|
+
@logger.debug("declarative is #{options[:declarative]}")
|
|
36
|
+
self.declarative= options[:declarative]
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
default_logger = ApacheAnt::DefaultLogger.new
|
|
40
|
+
default_logger.message_output_level = 2
|
|
41
|
+
default_logger.output_print_stream = options[:outputstr] || JavaLang::System.out
|
|
42
|
+
default_logger.error_print_stream = options[:errorstr] || JavaLang::System.err
|
|
43
|
+
default_logger.emacs_mode = false
|
|
44
|
+
|
|
45
|
+
@project.add_build_listener(default_logger)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
public
|
|
49
|
+
attr :project
|
|
50
|
+
attr :ant_version
|
|
51
|
+
attr_accessor(:declarative, :logger)
|
|
52
|
+
|
|
53
|
+
# Create an AntProject. Parameters are specified via a hash:
|
|
54
|
+
# :ant_home=><em>Ant basedir</em>
|
|
55
|
+
# -A String indicating the location of the ANT_HOME directory. If provided, RAW will
|
|
56
|
+
# load the classes from the ANT_HOME/lib dir. If ant_home is not provided, the Ant jar files
|
|
57
|
+
# must be available in the CLASSPATH.
|
|
58
|
+
# :name=><em>project_name</em>
|
|
59
|
+
# -A String indicating the name of this project.
|
|
60
|
+
# :basedir=><em>project_basedir</em>
|
|
61
|
+
# -A String indicating the basedir of this project. Corresponds to the 'basedir' attribute
|
|
62
|
+
# on an Ant project.
|
|
63
|
+
# :declarative=><em>declarative_mode</em>
|
|
64
|
+
# -A boolean value indicating wether Ant tasks created by this project instance should
|
|
65
|
+
# have their execute() method invoked during their creation. For example, with
|
|
66
|
+
# the option :declarative=>true the following task would execute;
|
|
67
|
+
# @antProject.echo(:message => "An Echo Task")
|
|
68
|
+
# However, with the option :declarative=>false, the programmer is required to execute the
|
|
69
|
+
# task explicitly;
|
|
70
|
+
# echoTask = @antProject.echo(:message => "An Echo Task")
|
|
71
|
+
# echoTask.execute()
|
|
72
|
+
# Default value is <em>true</em>.
|
|
73
|
+
# :logger=><em>Logger</em>
|
|
74
|
+
# -A Logger instance. Defaults to Logger.new(STDOUT)
|
|
75
|
+
# :loglevel=><em>The level to set the logger to</em>
|
|
76
|
+
# -Defaults to Logger::ERROR
|
|
77
|
+
def initialize(options = Hash.new)
|
|
78
|
+
|
|
79
|
+
@logger = options[:logger] || Logger.new(STDOUT)
|
|
80
|
+
@logger.level = options[:loglevel] || Logger::ERROR
|
|
81
|
+
|
|
82
|
+
if (!@@classes_loaded && options[:ant_home])
|
|
83
|
+
@logger.debug("loading ant jar files. ANT_HOME: #{options[:ant_home]}")
|
|
84
|
+
# Load all the jar files from ant
|
|
85
|
+
RAWClassLoader.load_ant_libs(options[:ant_home])
|
|
86
|
+
@@classes_loaded = true
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
@logger.debug(RAW::ApacheAnt::Main.ant_version)
|
|
90
|
+
@ant_version = RAW::ApacheAnt::Main.ant_version[/\d\.\d\.\d/].to_f
|
|
91
|
+
|
|
92
|
+
init_project(options)
|
|
93
|
+
|
|
94
|
+
@task_stack = Array.new
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def method_missing(sym, *args)
|
|
98
|
+
begin
|
|
99
|
+
task = AntTask.new(sym.to_s, self, args[0])
|
|
100
|
+
|
|
101
|
+
parent_task = @task_stack.last
|
|
102
|
+
@task_stack << task
|
|
103
|
+
|
|
104
|
+
yield self if block_given?
|
|
105
|
+
|
|
106
|
+
parent_task.add(task) if parent_task
|
|
107
|
+
|
|
108
|
+
if @task_stack.nitems == 1
|
|
109
|
+
if declarative == true
|
|
110
|
+
@logger.debug("Executing #{task}")
|
|
111
|
+
task.execute
|
|
112
|
+
else
|
|
113
|
+
@logger.debug("Returning #{task}")
|
|
114
|
+
return task
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
rescue
|
|
119
|
+
@logger.error("Error instantiating '#{sym.to_s}' task: " + $!)
|
|
120
|
+
raise
|
|
121
|
+
ensure
|
|
122
|
+
@task_stack.pop
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
#The Ant AntProject's name. Default is ''
|
|
128
|
+
def name
|
|
129
|
+
return @project.getName
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
#The Ant AntProject's basedir. Default is '.'
|
|
133
|
+
def basedir
|
|
134
|
+
return @project.base_dir.absolute_path;
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
#Displays the Class name followed by the AntProject name
|
|
138
|
+
# -e.g. AntProject[BigCoProject]
|
|
139
|
+
def to_s
|
|
140
|
+
return self.class.name + "[#{name}]"
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
end
|
|
144
|
+
end
|
data/lib/ant_task.rb
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
2
|
+
# you may not use this file except in compliance with the License.
|
|
3
|
+
# You may obtain a copy of the License at
|
|
4
|
+
#
|
|
5
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
#
|
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
+
# See the License for the specific language governing permissions and limitations
|
|
11
|
+
# under the License.
|
|
12
|
+
|
|
13
|
+
module RAW
|
|
14
|
+
class AntTask
|
|
15
|
+
attr_accessor :unknown_element, :project, :taskname, :logger, :executed
|
|
16
|
+
|
|
17
|
+
public
|
|
18
|
+
# Creates an AntTask
|
|
19
|
+
# taskname
|
|
20
|
+
# -A String representing the name of an Ant Task. This name should correspond to
|
|
21
|
+
# the element name of the Ant xml task (e.g. javac, jar, war, etc).
|
|
22
|
+
# antProject
|
|
23
|
+
# -An instance of an AntProject
|
|
24
|
+
# attributes
|
|
25
|
+
# -A Hash of task name/values to be applied to the task.
|
|
26
|
+
#
|
|
27
|
+
# For example:
|
|
28
|
+
# antProject = AntProject.new()
|
|
29
|
+
# antTask = AntTask.new('javac', antProject, {:debug => 'on', :verbose => 'no', :fork => 'no'})
|
|
30
|
+
def initialize(taskname, antProject, attributes)
|
|
31
|
+
|
|
32
|
+
taskname = taskname[1, taskname.length-1] if taskname[0,1] == "_"
|
|
33
|
+
@logger = antProject.logger
|
|
34
|
+
@taskname = taskname
|
|
35
|
+
@project_wrapper = antProject
|
|
36
|
+
@project = antProject.project
|
|
37
|
+
@logger.debug(antProject.to_s)
|
|
38
|
+
@unknown_element = create_unknown_element(@project, taskname)
|
|
39
|
+
@logger.debug(to_s)
|
|
40
|
+
|
|
41
|
+
add_attributes(attributes)
|
|
42
|
+
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Displays the Class name followed by the Task name
|
|
46
|
+
# -e.g. AntTask[javac]
|
|
47
|
+
def to_s
|
|
48
|
+
return self.class.name + "[#{@taskname}]"
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def create_unknown_element(project, taskname)
|
|
52
|
+
|
|
53
|
+
element = ApacheAnt::UnknownElement.new(taskname)
|
|
54
|
+
element.project = project
|
|
55
|
+
element.owning_target = ApacheAnt::Target.new
|
|
56
|
+
element.task_name = taskname
|
|
57
|
+
|
|
58
|
+
#DNR. This initializes the Task's Wrapper object and prevents NullPointerExeption upon execution of the task
|
|
59
|
+
element.runtime_configurable_wrapper
|
|
60
|
+
|
|
61
|
+
if(@project_wrapper.ant_version >= 1.6)
|
|
62
|
+
element.task_type = taskname
|
|
63
|
+
element.namespace = ''
|
|
64
|
+
element.qname = taskname
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
return element
|
|
68
|
+
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Sets each attribute on the AntTask instance.
|
|
72
|
+
# :attributes - is a Hash.
|
|
73
|
+
def add_attributes(attributes)
|
|
74
|
+
|
|
75
|
+
return if attributes == nil
|
|
76
|
+
|
|
77
|
+
wrapper = ApacheAnt::RuntimeConfigurable.new(@unknown_element, @unknown_element.task_name)
|
|
78
|
+
|
|
79
|
+
if(@project_wrapper.ant_version >= 1.6)
|
|
80
|
+
attributes.each do |key, val|
|
|
81
|
+
apply_to_wrapper(wrapper, key.to_s, val){ |k,v| wrapper.set_attribute(k, v)}
|
|
82
|
+
end
|
|
83
|
+
else
|
|
84
|
+
@unknown_element.runtime_configurable_wrapper = wrapper
|
|
85
|
+
attribute_list = XmlSax::AttributeListImpl.new()
|
|
86
|
+
attributes.each do |key, val|
|
|
87
|
+
apply_to_wrapper(wrapper, key.to_s, val){ |k,v| attribute_list.add_attribute(k, 'CDATA', v)}
|
|
88
|
+
end
|
|
89
|
+
wrapper.set_attributes(attribute_list)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def apply_to_wrapper(wrapper, key, value)
|
|
95
|
+
|
|
96
|
+
raise ArgumentError, "ArgumentError: You cannot use an Array as an argument. Use the :join method instead; i.e ['file1', 'file2'].join(File::PATH_SEPARATOR)." if value.is_a?(Array)
|
|
97
|
+
|
|
98
|
+
begin
|
|
99
|
+
if(key == 'pcdata')
|
|
100
|
+
wrapper.add_text(value.to_s)
|
|
101
|
+
else
|
|
102
|
+
yield key, value.to_s
|
|
103
|
+
end
|
|
104
|
+
rescue StandardError
|
|
105
|
+
raise ArgumentError, "ArgumentError: Unable to set :#{key} attribute with value => '#{value}'"
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# Add <em>child</em> as a child of this task.
|
|
111
|
+
def add(child)
|
|
112
|
+
@unknown_element.add_child(child.unknown_element())
|
|
113
|
+
@unknown_element.runtime_configurable_wrapper.add_child(child.unknown_element().runtime_configurable_wrapper)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# Invokes the AntTask.
|
|
117
|
+
def execute
|
|
118
|
+
@unknown_element.maybe_configure
|
|
119
|
+
@unknown_element.execute
|
|
120
|
+
@executed = true
|
|
121
|
+
return nil
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
end
|
|
125
|
+
end
|
data/lib/raw.rb
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
2
|
+
# you may not use this file except in compliance with the License.
|
|
3
|
+
# You may obtain a copy of the License at
|
|
4
|
+
#
|
|
5
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
#
|
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
+
# See the License for the specific language governing permissions and limitations
|
|
11
|
+
# under the License.
|
|
12
|
+
require 'raw_utilities'
|
|
13
|
+
require 'ant_project'
|
|
14
|
+
require 'ant_task'
|
|
15
|
+
require 'raw_runner'
|
|
16
|
+
require 'fileutils'
|
|
17
|
+
|
|
18
|
+
module RAW
|
|
19
|
+
# Loading modules of apache ant
|
|
20
|
+
autoload :ApacheAnt, 'ant_libraries.rb'
|
|
21
|
+
# Loads the class java.lang.System
|
|
22
|
+
autoload :JavaLang, 'ant_libraries.rb'
|
|
23
|
+
# loads the XML-Sax parser
|
|
24
|
+
autoload :XmlSax, 'ant_libraries.rb'
|
|
25
|
+
# version of our gem
|
|
26
|
+
VERSION = "0.8.0"
|
|
27
|
+
end
|
data/lib/raw_runner.rb
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
$LOAD_PATH.push(File.dirname(__FILE__) + '/../lib')
|
|
2
|
+
|
|
3
|
+
require 'open-uri'
|
|
4
|
+
require 'fileutils'
|
|
5
|
+
require 'raw'
|
|
6
|
+
|
|
7
|
+
module RAW
|
|
8
|
+
class RawRunner < RAW::AntProject
|
|
9
|
+
attr_reader :root
|
|
10
|
+
attr_writer :logger
|
|
11
|
+
|
|
12
|
+
def initialize(template, root = '', options = {})
|
|
13
|
+
super(options)
|
|
14
|
+
@targets = Hash.new
|
|
15
|
+
logger = options[:logger] || Logger.new(STDOUT)
|
|
16
|
+
@logger.level = options[:loglevel] || Logger::INFO
|
|
17
|
+
@root = File.expand_path(File.directory?(root) ? root : File.join(Dir.pwd, root))
|
|
18
|
+
|
|
19
|
+
if template
|
|
20
|
+
logger.info("applying script #{template}")
|
|
21
|
+
|
|
22
|
+
load_script(template)
|
|
23
|
+
|
|
24
|
+
logger.info"applied script #{template}"
|
|
25
|
+
else
|
|
26
|
+
logger.info"no script applied#{template}"
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# defines a property in ant and also an instance variable
|
|
31
|
+
def property(options)
|
|
32
|
+
name = options[:name]
|
|
33
|
+
file = options[:file]
|
|
34
|
+
environment = options[:environment]
|
|
35
|
+
|
|
36
|
+
method_missing(:property, options)
|
|
37
|
+
|
|
38
|
+
if name
|
|
39
|
+
build_instance_variable([name, options[:location] || options[:value]])
|
|
40
|
+
elsif file || environment
|
|
41
|
+
build_properties
|
|
42
|
+
else
|
|
43
|
+
logger.debug options.inspect
|
|
44
|
+
raise "No name or file attribute given for property!"
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def property_value(name)
|
|
49
|
+
project.get_property(name)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def build_instance_variable(prop)
|
|
53
|
+
instance_variable = "@#{instvar(prop[0])} = '#{prop[1]}'"
|
|
54
|
+
self.instance_eval instance_variable
|
|
55
|
+
logger.debug instance_variable
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def build_properties
|
|
59
|
+
project.properties.each do |prop|
|
|
60
|
+
build_instance_variable(prop)
|
|
61
|
+
end
|
|
62
|
+
logger.debug instance_variables
|
|
63
|
+
# TODO: Hack
|
|
64
|
+
@ant_version = RAW::ApacheAnt::Main.ant_version[/\d\.\d\.\d/].to_f
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def instvar(name)
|
|
68
|
+
name.gsub('.', '_')
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def self.parse!(args=ARGV)
|
|
72
|
+
RawRunner.new(args[0], args[1], args[2])
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def load_script(template)
|
|
77
|
+
begin
|
|
78
|
+
code = open(template).read
|
|
79
|
+
|
|
80
|
+
self.instance_eval(code)
|
|
81
|
+
rescue LoadError, Errno::ENOENT => e
|
|
82
|
+
raise "The script #{template} could not be loaded. Error: #{e}"
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def target(name, depends = [], &block)
|
|
87
|
+
@targets[name] = block
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def build(task)
|
|
91
|
+
block = @targets[task]
|
|
92
|
+
block.call
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
RAW::RawRunner.parse!
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
2
|
+
# you may not use this file except in compliance with the License.
|
|
3
|
+
# You may obtain a copy of the License at
|
|
4
|
+
#
|
|
5
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
#
|
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
+
# See the License for the specific language governing permissions and limitations
|
|
11
|
+
# under the License.
|
|
12
|
+
require 'rjb_adapter'
|
|
13
|
+
|
|
14
|
+
module RAW
|
|
15
|
+
module RAWClassLoader
|
|
16
|
+
require 'find'
|
|
17
|
+
|
|
18
|
+
def match(*paths)
|
|
19
|
+
matched = Array.new
|
|
20
|
+
Find.find(*paths){ |path| matched << path if yield path }
|
|
21
|
+
return matched
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def load_ant_libs(ant_home)
|
|
25
|
+
jars = match(ant_home + File::SEPARATOR + 'lib') {|p| ext = p[-4...p.size]; ext && ext.downcase == '.jar'}
|
|
26
|
+
RAW::RjbAdapter.load(jars)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
module_function :match, :load_ant_libs
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
end
|
data/lib/rjb_adapter.rb
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
2
|
+
# you may not use this file except in compliance with the License.
|
|
3
|
+
# You may obtain a copy of the License at
|
|
4
|
+
#
|
|
5
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
#
|
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
+
# See the License for the specific language governing permissions and limitations
|
|
11
|
+
# under the License.
|
|
12
|
+
|
|
13
|
+
module RAW
|
|
14
|
+
module RjbAdapter
|
|
15
|
+
# We test if the RUBY_PLATFORM is 'java'
|
|
16
|
+
# If true we will use JRuby
|
|
17
|
+
# If false we will use Rjb gem
|
|
18
|
+
def is_jruby?
|
|
19
|
+
return RUBY_PLATFORM == 'java'
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Wrapper for import_class from JRuby
|
|
23
|
+
# If we're on JRuby we use normal import_class
|
|
24
|
+
# Otherwise we use Rjb::import
|
|
25
|
+
def import_class(name)
|
|
26
|
+
if is_jruby?
|
|
27
|
+
return import_using_jruby(name)
|
|
28
|
+
else
|
|
29
|
+
return Rjb::import(name)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
# Here we extract the class name from a given String
|
|
33
|
+
# e.g. str = "java.lang.String" -> class_name = "String"
|
|
34
|
+
def extract_class_name(str)
|
|
35
|
+
class_name = str.split(".").last
|
|
36
|
+
end
|
|
37
|
+
# Here we load the files we need
|
|
38
|
+
# When in JRuby, we do a require for each jar in files argument
|
|
39
|
+
# Otherwise we use Rjb::load to load all jars from a path build from files parameter
|
|
40
|
+
def load(files=[], args=[])
|
|
41
|
+
if is_jruby?
|
|
42
|
+
files.each {|jar| require jar }
|
|
43
|
+
else
|
|
44
|
+
Rjb::load(files.join(File::PATH_SEPARATOR), [])
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
module_function :import_class, :load, :is_jruby?, :extract_class_name
|
|
49
|
+
|
|
50
|
+
if is_jruby?
|
|
51
|
+
require 'java'
|
|
52
|
+
else
|
|
53
|
+
require 'rubygems'
|
|
54
|
+
require 'rjb'
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
private
|
|
58
|
+
def RjbAdapter.import_using_jruby(name)
|
|
59
|
+
include_class(name)
|
|
60
|
+
return remove_const(name.scan(/[_a-zA-Z0-9$]+/).last)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
|
2
|
+
|
|
3
|
+
describe RAW::RjbAdapter do
|
|
4
|
+
|
|
5
|
+
it "should extract the Java class name from a string" do
|
|
6
|
+
RAW::RjbAdapter.extract_class_name("java.lang.String").should eql("String")
|
|
7
|
+
RAW::RjbAdapter.extract_class_name("Foo").should eql("Foo")
|
|
8
|
+
RAW::RjbAdapter.extract_class_name("java.lang.__String").should eql("__String")
|
|
9
|
+
RAW::RjbAdapter.extract_class_name("java.lang.Outer$Inner").should eql("Outer$Inner")
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "should import a class" do
|
|
13
|
+
result = RAW::RjbAdapter.import_class("java.lang.String")
|
|
14
|
+
result.should_not be_nil
|
|
15
|
+
result.should respond_to(:new)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
|
2
|
+
|
|
3
|
+
describe RAW::RawRunner, 'initialized' do
|
|
4
|
+
before(:each) do
|
|
5
|
+
# Defining the output directory for our specs
|
|
6
|
+
@output_dir = File.join(FileUtils::pwd, 'tmp', 'output')
|
|
7
|
+
|
|
8
|
+
# the resource directory with the sources we like to build
|
|
9
|
+
@resource_dir = File.join(FileUtils::pwd, 'resources')
|
|
10
|
+
|
|
11
|
+
# The current ant_home of this project
|
|
12
|
+
@ant_home = File.join(@resource_dir, 'apache-ant-1.7.1')
|
|
13
|
+
|
|
14
|
+
# The properties for the new AntProject instance
|
|
15
|
+
@ant_proj_props = {
|
|
16
|
+
:name => "rawTest",
|
|
17
|
+
:basedir => FileUtils::pwd,
|
|
18
|
+
:declarative => true,
|
|
19
|
+
:logger => Logger.new(STDOUT),
|
|
20
|
+
:loglevel => Logger::DEBUG,
|
|
21
|
+
:ant_home => @ant_home
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
# Creating the new instance of RAW::AntProject
|
|
25
|
+
@ant = RAW::RawRunner.new(nil, '.', @ant_proj_props)
|
|
26
|
+
|
|
27
|
+
if File.exists?(@output_dir)
|
|
28
|
+
FileUtils.remove_dir(@output_dir)
|
|
29
|
+
end
|
|
30
|
+
FileUtils.mkdir_p(@output_dir, :mode => 0775)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "should be proper initialized" do
|
|
34
|
+
@ant_proj_props[:name].should eql @ant.name
|
|
35
|
+
FileUtils::pwd.should eql @ant.basedir
|
|
36
|
+
@ant_proj_props[:declarative].should eql @ant.declarative
|
|
37
|
+
@ant_proj_props[:logger].should eql @ant.logger
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "should be declarative" do
|
|
41
|
+
@ant = RAW::RawRunner.new({ :declarative => false,
|
|
42
|
+
:loglevel => Logger::DEBUG,
|
|
43
|
+
:ant_home => @ant_home })
|
|
44
|
+
echo = @ant.echo :message => "RAW is really cool"
|
|
45
|
+
echo.should_not be_nil
|
|
46
|
+
|
|
47
|
+
@ant = RAW::RawRunner.new({ :declarative => true,
|
|
48
|
+
:loglevel => Logger::DEBUG,
|
|
49
|
+
:ant_home => @ant_home })
|
|
50
|
+
|
|
51
|
+
echo = @ant.echo :message => "RAW is really cool"
|
|
52
|
+
echo.should be_nil
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it "should not accept arrays as argument to echo target" do
|
|
56
|
+
begin
|
|
57
|
+
@ant.echo( :message => ['This', 'should', 'fail', 'because', 'Arrays', 'are', 'not', 'supported'] )
|
|
58
|
+
add_failure "Arrays not permitted"
|
|
59
|
+
rescue ArgumentError
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it "should return a valid timestamp" do
|
|
64
|
+
tstamp = @ant.tstamp#.create_format({ :property => "TSTAMP_DE", :pattern => "dd.MM.yyyy hh:mm:ss"})
|
|
65
|
+
puts "*** #{tstamp}"
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it "should copy and remove files" do
|
|
69
|
+
file = @output_dir + '/build.xml'
|
|
70
|
+
File.exists?(file).should be_false
|
|
71
|
+
|
|
72
|
+
@ant.copy( :file => @resource_dir + '/build.xml',
|
|
73
|
+
:todir => @output_dir)
|
|
74
|
+
File.exists?(file).should be_true
|
|
75
|
+
|
|
76
|
+
@ant.delete( :file => file )
|
|
77
|
+
File.exists?(file).should be_false
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it "should unzip antlr" do
|
|
81
|
+
File.directory?(@output_dir + '/ant-antlr').should be_false
|
|
82
|
+
@ant.unzip(:src => @resource_dir + '/apache-ant-1.7.1/lib/ant-antlr.jar', :dest => @output_dir + '/ant-antlr')
|
|
83
|
+
File.exists?(@output_dir + '/ant-antlr/META-INF/MANIFEST.MF').should be_true
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
it "should create as jar" do
|
|
87
|
+
File.exists?(@output_dir + '/archive.jar').should be_false
|
|
88
|
+
@ant.property(:name => 'outputdir', :value => @output_dir)
|
|
89
|
+
@ant.property(:name => 'destfile', :value => '${outputdir}/archive.jar')
|
|
90
|
+
@ant.jar( :destfile => "${destfile}",
|
|
91
|
+
:basedir => @resource_dir + '/src',
|
|
92
|
+
:duplicate => 'preserve')
|
|
93
|
+
|
|
94
|
+
File.exists?(@output_dir + '/archive.jar').should be_true
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
it "should handle pcdata" do
|
|
98
|
+
@ant.echo(:pcdata => "Foobar & <><><>")
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
it "should work with makrodef tasks" do
|
|
102
|
+
|
|
103
|
+
return if @ant.ant_version < 1.6
|
|
104
|
+
|
|
105
|
+
dir = @output_dir + '/foo'
|
|
106
|
+
|
|
107
|
+
File.directory?(dir).should be_false
|
|
108
|
+
|
|
109
|
+
@ant.macrodef(:name => 'testmacrodef') do |ant|
|
|
110
|
+
ant.attribute(:name => 'destination')
|
|
111
|
+
ant.sequential do
|
|
112
|
+
ant.echo(:message => "Creating @{destination}")
|
|
113
|
+
ant._mkdir(:dir => "@{destination}")
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
@ant.testmacrodef(:destination => dir)
|
|
117
|
+
File.directory?(dir).should be_true
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
it "should make dir with property" do
|
|
121
|
+
dir = @output_dir + '/foo'
|
|
122
|
+
|
|
123
|
+
File.directory?(dir).should be_false
|
|
124
|
+
|
|
125
|
+
@ant.property(:name => 'outputProperty', :value => dir)
|
|
126
|
+
@ant.mkdir(:dir => "${outputProperty}")
|
|
127
|
+
|
|
128
|
+
File.directory?(dir).should be_true
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
it "should make dir with mkdir task" do
|
|
132
|
+
dir = @output_dir + '/foo'
|
|
133
|
+
|
|
134
|
+
File.directory?(dir).should be_false
|
|
135
|
+
|
|
136
|
+
@ant.mkdir(:dir => dir)
|
|
137
|
+
|
|
138
|
+
File.directory?(dir).should be_true
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
it "should echo properly" do
|
|
142
|
+
msg = "RAW is running an echo task"
|
|
143
|
+
@ant.echo(:message => msg, :level => 'info')
|
|
144
|
+
@ant.echo(:message => 100000, :level => 'info')
|
|
145
|
+
@ant.echo(:pcdata => 1000)
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
it "should run sucessfully a javac task" do
|
|
149
|
+
FileUtils.mkdir(@output_dir + '/classes', :mode => 0775)
|
|
150
|
+
|
|
151
|
+
File.exists?(@output_dir + '/classes/foo/bar/FooBar.class').should be_false
|
|
152
|
+
|
|
153
|
+
@ant.javac(:srcdir => @resource_dir + '/src',
|
|
154
|
+
:destdir => @output_dir + '/classes',
|
|
155
|
+
:debug => 'on',
|
|
156
|
+
:verbose => 'no',
|
|
157
|
+
:fork => 'no',
|
|
158
|
+
:failonerror => 'yes',
|
|
159
|
+
:includes => 'foo/bar/**',
|
|
160
|
+
:excludes => 'foo/bar/baz/**',
|
|
161
|
+
:classpath => @resource_dir + '/parent.jar')
|
|
162
|
+
|
|
163
|
+
File.exists?(@output_dir + '/classes/foo/bar/FooBar.class').should be_true
|
|
164
|
+
File.exists?(@output_dir + '/classes/foo/bar/baz/FooBarBaz.class').should be_false
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
it "should run successfully a javac task with property" do
|
|
168
|
+
FileUtils.mkdir(@output_dir + '/classes', :mode => 0775)
|
|
169
|
+
|
|
170
|
+
File.exists?(@output_dir + '/classes/foo/bar/FooBar.class').should be_false
|
|
171
|
+
@ant.property(:name => 'pattern', :value => '**/*.jar')
|
|
172
|
+
@ant.property(:name => 'resource_dir', :value => @resource_dir)
|
|
173
|
+
@ant.path(:id => 'common.class.path') do
|
|
174
|
+
@ant.fileset(:dir => '${resource_dir}') do
|
|
175
|
+
@ant.include(:name => '${pattern}')
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
puts "Resource dir: #{@resource_dir}"
|
|
179
|
+
@ant.javac(:srcdir => @resource_dir + '/src',
|
|
180
|
+
:destdir => @output_dir + '/classes',
|
|
181
|
+
:debug => true,
|
|
182
|
+
:verbose => true,
|
|
183
|
+
:fork => 'no',
|
|
184
|
+
:failonerror => 'blahblahblah',
|
|
185
|
+
:includes => 'foo/bar/**',
|
|
186
|
+
:excludes => 'foo/bar/baz/**',
|
|
187
|
+
:classpathref => 'common.class.path')
|
|
188
|
+
|
|
189
|
+
File.exists?(@output_dir + '/classes/foo/bar/FooBar.class').should be_true
|
|
190
|
+
File.exists?(@output_dir + '/classes/foo/bar/baz/FooBarBaz.class').should be_false
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
it "should define a tasdef with custom classpath" do
|
|
194
|
+
@ant.taskdef(:name => 'retro', :classname => 'foo.bar.Parent', :classpath => @resource_dir)
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
it "should define property basedir" do
|
|
198
|
+
@ant.property(:name => 'bla', :value => "Hallo")
|
|
199
|
+
project.getProperty('bla').should == "Hallo"
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
it "should read and handle build.properties correctly" do
|
|
203
|
+
@ant.property(:file => '../default.build.properties')
|
|
204
|
+
project.get_property("jruby.classes.dir").should == '512M'
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
it "should have proper instance variables available" do
|
|
208
|
+
@ant.property(:file => '../default.build.properties')
|
|
209
|
+
@ant.instance_variable_defined?(:@jruby_classes_dir).should be_true
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
# private methods
|
|
213
|
+
private
|
|
214
|
+
|
|
215
|
+
def project
|
|
216
|
+
@ant.project
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: malagant-raw
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.4.13
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Michael Johann
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
|
|
12
|
+
date: 2009-06-10 00:00:00 -07:00
|
|
13
|
+
default_executable: raw
|
|
14
|
+
dependencies:
|
|
15
|
+
- !ruby/object:Gem::Dependency
|
|
16
|
+
name: rake
|
|
17
|
+
type: :runtime
|
|
18
|
+
version_requirement:
|
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
20
|
+
requirements:
|
|
21
|
+
- - ">="
|
|
22
|
+
- !ruby/object:Gem::Version
|
|
23
|
+
version: 0.7.3
|
|
24
|
+
version:
|
|
25
|
+
description: RAW is a Ruby ANT Wrapper for describing Apache ANT tasks in ruby instead of XML.
|
|
26
|
+
email: mjohann@rails-experts.com
|
|
27
|
+
executables:
|
|
28
|
+
- raw
|
|
29
|
+
extensions: []
|
|
30
|
+
|
|
31
|
+
extra_rdoc_files:
|
|
32
|
+
- History.txt
|
|
33
|
+
- Manifest.txt
|
|
34
|
+
- README.txt
|
|
35
|
+
- LICENSE
|
|
36
|
+
files:
|
|
37
|
+
- History.txt
|
|
38
|
+
- Manifest.txt
|
|
39
|
+
- README.txt
|
|
40
|
+
- LICENSE
|
|
41
|
+
- Rakefile
|
|
42
|
+
- bin/raw
|
|
43
|
+
- lib/ant_libraries.rb
|
|
44
|
+
- lib/ant_project.rb
|
|
45
|
+
- lib/ant_task.rb
|
|
46
|
+
- lib/raw.rb
|
|
47
|
+
- lib/raw_runner.rb
|
|
48
|
+
- lib/rjb_adapter.rb
|
|
49
|
+
- lib/raw_utilities.rb
|
|
50
|
+
- spec/javaadapter_spec.rb
|
|
51
|
+
- spec/raw_antproject_spec.rb
|
|
52
|
+
- spec/spec_helper.rb
|
|
53
|
+
has_rdoc: true
|
|
54
|
+
homepage: http://kenai.com/projects/raw
|
|
55
|
+
post_install_message:
|
|
56
|
+
rdoc_options:
|
|
57
|
+
- --main
|
|
58
|
+
- README.txt
|
|
59
|
+
require_paths:
|
|
60
|
+
- lib
|
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
62
|
+
requirements:
|
|
63
|
+
- - ">="
|
|
64
|
+
- !ruby/object:Gem::Version
|
|
65
|
+
version: "0"
|
|
66
|
+
version:
|
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
|
+
requirements:
|
|
69
|
+
- - ">="
|
|
70
|
+
- !ruby/object:Gem::Version
|
|
71
|
+
version: "0"
|
|
72
|
+
version:
|
|
73
|
+
requirements: []
|
|
74
|
+
|
|
75
|
+
rubyforge_project:
|
|
76
|
+
rubygems_version: 1.2.0
|
|
77
|
+
signing_key:
|
|
78
|
+
specification_version: 2
|
|
79
|
+
summary: RAW is a Ruby ANT Wrapper for describing Apache ANT tasks in ruby instead of XML.
|
|
80
|
+
test_files:
|
|
81
|
+
- spec/javaadapter_spec.rb
|
|
82
|
+
- spec/raw_antproject_spec.rb
|