anttrap 0.01

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Copyright (c) 2011 Dave Parfitt
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
data/README ADDED
@@ -0,0 +1 @@
1
+ see README.md
data/README.md ADDED
@@ -0,0 +1,94 @@
1
+ The AntTrap Ruby Gem
2
+ ====================
3
+ A tiny Gem that can generate an Apache Ant build file from a Rakefile. This allows for a developer to
4
+ work in Rake, but integrate with any tool that supports Ant. The generated build file simply calls
5
+ exec on the selected Rake task. As of 8/9/2011, the only tool I have tested so far is Eclipse.
6
+
7
+
8
+ Sample rakefile
9
+ ---
10
+ require 'anttrap'
11
+
12
+ AntTrap.antproject="RakeFile #{Time.new}"
13
+ AntTrap.rake = '/usr/bin/rake'
14
+ AntTrap.rakeargs = ["-v"]
15
+
16
+ desc "The Bar task"
17
+ task :Bar do
18
+ puts "Bar!"
19
+ end
20
+
21
+ desc "The Foo Task"
22
+ task :Foo do
23
+ puts "Hello world"
24
+ end
25
+
26
+
27
+ Sample Generated Ant Build File
28
+ ---
29
+ <!-- this file is generated automatically -->
30
+ <?xml version="1.0" encoding="ASCII"?>
31
+ <project name="RakeFile Tue Aug 09 13:35:22 -0400 2011">
32
+ <target name="AntTrap" description="Generate an ant build file from this Rake file">
33
+ <exec executable="/usr/bin/rake">
34
+ <arg value="-v"/>
35
+ <arg value="AntTrap"/>
36
+ </exec>
37
+ </target>
38
+
39
+ <target name="Clean" description="Clean">
40
+ <exec executable="/usr/bin/rake">
41
+ <arg value="-v"/>
42
+ <arg value="Clean"/>
43
+ </exec>
44
+ </target>
45
+ <target name="Compile" description="Compile Java">
46
+ <exec executable="/usr/bin/rake">
47
+ <arg value="-v"/>
48
+ <arg value="Compile"/>
49
+ </exec>
50
+ </target>
51
+ </project>
52
+
53
+
54
+
55
+ Generating an Ant Build File
56
+ ---
57
+ rake AntTrap
58
+
59
+
60
+ Using the Ant Build file in an IDE
61
+ ---
62
+ Simply use the Ant build file in your favorite IDE like you always have. Each time you modify the rakefile, be sure to run "rake AntTrap" (or just run the AntTrap task from your IDE).
63
+
64
+ Whenever you the build.xml file is generated, the Ant file will need to be
65
+ refreshed in your IDE. In Eclipse, right click in the Ant view and select "Refresh Buildfiles".
66
+
67
+
68
+ Compiling Multiple Java Files from Rake
69
+ ---
70
+ see the [sample rakefile](https://github.com/metadave/anttrap/blob/master/samples/rakefile)
71
+
72
+
73
+
74
+ Installation
75
+ ---
76
+ Unix:
77
+ sudo gem install anttrap
78
+
79
+ Windows:
80
+ gem install anttrap
81
+
82
+ Submitting an Issue
83
+ ---
84
+ I use the [GitHub issue tracker](http://github.com/metadave/anttrap/issues) to track bugs and
85
+ features. Before submitting a bug report or feature request, check to make sure it hasn't already
86
+ been submitted. You can indicate support for an existing issuse by voting it up. When submitting a
87
+ bug report, please include a [Gist](http://gist.github.com/) that includes a stack trace and any
88
+ details that may be necessary to reproduce the bug, including your gem version, Ruby version, and
89
+ operating system. Ideally, a bug report should include a pull request with failing specs.
90
+
91
+ Copyright
92
+ ---
93
+ Copyright (c) 2011 Dave Parfitt
94
+ See [LICENSE](https://github.com/metadave/anttrap/blob/LICENSE) for details.
data/anttrap.gemspec ADDED
@@ -0,0 +1,16 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "anttrap"
3
+ s.summary = "Generates an Ant build file from a Rakefile so Rake can be used from a Java IDE"
4
+ s.description = File.read(File.join(File.dirname(__FILE__),'README.md'))
5
+ s.requirements = "Rake, Ant"
6
+ s.author = "Dave Parfitt"
7
+ s.email = "diparfitt@gmail.com"
8
+ s.version = "0.01"
9
+ s.homepage = "http://github.org/metadave/anttrap"
10
+ s.platform = Gem::Platform::RUBY
11
+ s.required_ruby_version = ">=1.8"
12
+ s.files = Dir['**/**']
13
+ s.has_rdoc = false
14
+ s.add_dependency('builder', '>= 3.0.0')
15
+
16
+ end
data/build.xml ADDED
@@ -0,0 +1,21 @@
1
+ <?xml version="1.0" encoding="ASCII"?>
2
+ <project name="RakeFile Tue Aug 09 12:51:10 -0400 2011">
3
+ <target name="AntTrap" description="Generate an ant build file from this Rake file">
4
+ <exec executable="/usr/bin/rake">
5
+ <arg value="-v"/>
6
+ <arg value="AntTrap"/>
7
+ </exec>
8
+ </target>
9
+ <target name="Bar" description="The Bar task">
10
+ <exec executable="/usr/bin/rake">
11
+ <arg value="-v"/>
12
+ <arg value="Bar"/>
13
+ </exec>
14
+ </target>
15
+ <target name="Foo" description="The Foo Task">
16
+ <exec executable="/usr/bin/rake">
17
+ <arg value="-v"/>
18
+ <arg value="Foo"/>
19
+ </exec>
20
+ </target>
21
+ </project>
data/lib/anttrap.rb ADDED
@@ -0,0 +1,84 @@
1
+ # Copyright (c) 2011 Dave Parfitt
2
+
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ require 'builder'
23
+
24
+ module AntTrap
25
+ # these are just the defaults
26
+ @@rake = "rake"
27
+ @@antfile = "build.xml"
28
+ @@antproject = "Rake Project"
29
+ @@rakeargs = []
30
+
31
+ def self.rake
32
+ @@rake
33
+ end
34
+ def self.rake=(v)
35
+ @@rake = v
36
+ end
37
+
38
+ def self.antfile
39
+ @@antfile
40
+ end
41
+ def self.antfile=(v)
42
+ @@antfile = v
43
+ end
44
+
45
+ def self.antproject
46
+ @@antproject
47
+ end
48
+ def self.antproject=(v)
49
+ @@antproject=v
50
+ end
51
+
52
+ def self.rakeargs
53
+ @@rakeargs
54
+ end
55
+
56
+ def self.rakeargs=(v)
57
+ @@rakeargs = v
58
+ end
59
+
60
+ desc "Generate an Ant build file from this Rake file"
61
+ task :AntTrap do |at|
62
+ xml = Builder::XmlMarkup.new( :indent => 2 )
63
+ xml.instruct! :xml, :encoding => "ASCII"
64
+ proj = xml.project("name" => AntTrap.antproject) do |p|
65
+ Rake::Task.tasks().each do |task|
66
+ p.target("name"=>task, "description"=>task.comment) do |t|
67
+ t.exec("executable"=>AntTrap.rake) do |e|
68
+ AntTrap.rakeargs.each do |arg|
69
+ e.arg("value"=>arg)
70
+ end
71
+ e.arg("value"=>task)
72
+ end
73
+ end
74
+ end
75
+ end
76
+ File.open(AntTrap.antfile,"w+") do |f|
77
+ f.puts proj
78
+ end
79
+ end
80
+
81
+ end
82
+
83
+
84
+
data/samples/build.xml ADDED
@@ -0,0 +1,33 @@
1
+ <?xml version="1.0" encoding="ASCII"?>
2
+ <project name="RakeFile Tue Aug 09 13:46:20 -0400 2011">
3
+ <target name="AntTrap" description="Generate an ant build file from this Rake file">
4
+ <exec executable="/usr/bin/rake">
5
+ <arg value="-v"/>
6
+ <arg value="AntTrap"/>
7
+ </exec>
8
+ </target>
9
+ <target name="Clean" description="Clean">
10
+ <exec executable="/usr/bin/rake">
11
+ <arg value="-v"/>
12
+ <arg value="Clean"/>
13
+ </exec>
14
+ </target>
15
+ <target name="Compile" description="Compiles all Java sources files in the project">
16
+ <exec executable="/usr/bin/rake">
17
+ <arg value="-v"/>
18
+ <arg value="Compile"/>
19
+ </exec>
20
+ </target>
21
+ <target name="Deploy" description="Deploy source to server">
22
+ <exec executable="/usr/bin/rake">
23
+ <arg value="-v"/>
24
+ <arg value="Deploy"/>
25
+ </exec>
26
+ </target>
27
+ <target name="default" description="">
28
+ <exec executable="/usr/bin/rake">
29
+ <arg value="-v"/>
30
+ <arg value="default"/>
31
+ </exec>
32
+ </target>
33
+ </project>
File without changes
@@ -0,0 +1,3 @@
1
+ -d rakeout
2
+ -g
3
+ -sourcepath src
data/samples/rakefile ADDED
@@ -0,0 +1,54 @@
1
+ # add support for Ruby Gems:
2
+ #export RUBYOPT=rubygems
3
+ # or
4
+ #require 'rubygems'
5
+ #https://gist.github.com/54177
6
+
7
+ require 'anttrap'
8
+
9
+ # the name of the Ant project.
10
+ # adding a timestamp may be helpful to you
11
+ AntTrap.antproject="RakeFile #{Time.new}"
12
+
13
+ # path to the rake binary
14
+ # the default is rake, but you can use what you like here
15
+ AntTrap.rake = '/usr/bin/rake'
16
+
17
+ # additional arguments to pass to rake
18
+ AntTrap.rakeargs = ["-v"]
19
+
20
+ task :default => [:Compile]
21
+
22
+ sources = FileList['src/**/*.java']
23
+ classes = sources.ext('class')
24
+ jars = FileList['lib/**/*.jar']
25
+
26
+ desc "Compiles all Java sources files in the project"
27
+ task :Compile => classes do
28
+ # see the javac command line docs regarding @ syntax for javac
29
+ File.open("javac.classes","w+") do |f|
30
+ sources.each {|t| f.puts "#{t}" }
31
+ end
32
+
33
+ File.open("javac.options","w+") do |f|
34
+ f.puts "-d rakeout"
35
+ f.puts "-g"
36
+ f.puts '-sourcepath src'
37
+ end
38
+ cp = jars.join(";")
39
+ command =<<EOF
40
+ javac -J-Xms256m -J-Xmx256m -classpath #{cp} @javac.options @javac.classes
41
+ EOF
42
+ sh command
43
+ end
44
+
45
+ desc "Deploy source to server"
46
+ task :Deploy => classes do
47
+ puts "Deploying!!!"
48
+ end
49
+
50
+ desc "Clean"
51
+ task :Clean do
52
+ puts "Clean"
53
+ end
54
+
metadata ADDED
@@ -0,0 +1,186 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: anttrap
3
+ version: !ruby/object:Gem::Version
4
+ hash: 9
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ version: "0.01"
10
+ platform: ruby
11
+ authors:
12
+ - Dave Parfitt
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-08-09 00:00:00 -04:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: builder
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 7
29
+ segments:
30
+ - 3
31
+ - 0
32
+ - 0
33
+ version: 3.0.0
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ description: |
37
+ The AntTrap Ruby Gem
38
+ ====================
39
+ A tiny Gem that can generate an Apache Ant build file from a Rakefile. This allows for a developer to
40
+ work in Rake, but integrate with any tool that supports Ant. The generated build file simply calls
41
+ exec on the selected Rake task. As of 8/9/2011, the only tool I have tested so far is Eclipse.
42
+
43
+
44
+ Sample rakefile
45
+ ---
46
+ require 'anttrap'
47
+
48
+ AntTrap.antproject="RakeFile #{Time.new}"
49
+ AntTrap.rake = '/usr/bin/rake'
50
+ AntTrap.rakeargs = ["-v"]
51
+
52
+ desc "The Bar task"
53
+ task :Bar do
54
+ puts "Bar!"
55
+ end
56
+
57
+ desc "The Foo Task"
58
+ task :Foo do
59
+ puts "Hello world"
60
+ end
61
+
62
+
63
+ Sample Generated Ant Build File
64
+ ---
65
+ <!-- this file is generated automatically -->
66
+ <?xml version="1.0" encoding="ASCII"?>
67
+ <project name="RakeFile Tue Aug 09 13:35:22 -0400 2011">
68
+ <target name="AntTrap" description="Generate an ant build file from this Rake file">
69
+ <exec executable="/usr/bin/rake">
70
+ <arg value="-v"/>
71
+ <arg value="AntTrap"/>
72
+ </exec>
73
+ </target>
74
+
75
+ <target name="Clean" description="Clean">
76
+ <exec executable="/usr/bin/rake">
77
+ <arg value="-v"/>
78
+ <arg value="Clean"/>
79
+ </exec>
80
+ </target>
81
+ <target name="Compile" description="Compile Java">
82
+ <exec executable="/usr/bin/rake">
83
+ <arg value="-v"/>
84
+ <arg value="Compile"/>
85
+ </exec>
86
+ </target>
87
+ </project>
88
+
89
+
90
+
91
+ Generating an Ant Build File
92
+ ---
93
+ rake AntTrap
94
+
95
+
96
+ Using the Ant Build file in an IDE
97
+ ---
98
+ Simply use the Ant build file in your favorite IDE like you always have. Each time you modify the rakefile, be sure to run "rake AntTrap" (or just run the AntTrap task from your IDE).
99
+
100
+ Whenever you the build.xml file is generated, the Ant file will need to be
101
+ refreshed in your IDE. In Eclipse, right click in the Ant view and select "Refresh Buildfiles".
102
+
103
+
104
+ Compiling Multiple Java Files from Rake
105
+ ---
106
+ see the [sample rakefile](https://github.com/metadave/anttrap/blob/master/samples/rakefile)
107
+
108
+
109
+
110
+ Installation
111
+ ---
112
+ Unix:
113
+ sudo gem install anttrap
114
+
115
+ Windows:
116
+ gem install anttrap
117
+
118
+ Submitting an Issue
119
+ ---
120
+ I use the [GitHub issue tracker](http://github.com/metadave/anttrap/issues) to track bugs and
121
+ features. Before submitting a bug report or feature request, check to make sure it hasn't already
122
+ been submitted. You can indicate support for an existing issuse by voting it up. When submitting a
123
+ bug report, please include a [Gist](http://gist.github.com/) that includes a stack trace and any
124
+ details that may be necessary to reproduce the bug, including your gem version, Ruby version, and
125
+ operating system. Ideally, a bug report should include a pull request with failing specs.
126
+
127
+ Copyright
128
+ ---
129
+ Copyright (c) 2011 Dave Parfitt
130
+ See [LICENSE](https://github.com/metadave/anttrap/blob/LICENSE) for details.
131
+
132
+ email: diparfitt@gmail.com
133
+ executables: []
134
+
135
+ extensions: []
136
+
137
+ extra_rdoc_files: []
138
+
139
+ files:
140
+ - README
141
+ - LICENSE
142
+ - build.xml
143
+ - README.md
144
+ - anttrap.gemspec
145
+ - samples/build.xml
146
+ - samples/rakefile
147
+ - samples/javac.options
148
+ - samples/javac.classes
149
+ - lib/anttrap.rb
150
+ has_rdoc: true
151
+ homepage: http://github.org/metadave/anttrap
152
+ licenses: []
153
+
154
+ post_install_message:
155
+ rdoc_options: []
156
+
157
+ require_paths:
158
+ - lib
159
+ required_ruby_version: !ruby/object:Gem::Requirement
160
+ none: false
161
+ requirements:
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ hash: 31
165
+ segments:
166
+ - 1
167
+ - 8
168
+ version: "1.8"
169
+ required_rubygems_version: !ruby/object:Gem::Requirement
170
+ none: false
171
+ requirements:
172
+ - - ">="
173
+ - !ruby/object:Gem::Version
174
+ hash: 3
175
+ segments:
176
+ - 0
177
+ version: "0"
178
+ requirements:
179
+ - Rake, Ant
180
+ rubyforge_project:
181
+ rubygems_version: 1.3.7
182
+ signing_key:
183
+ specification_version: 3
184
+ summary: Generates an Ant build file from a Rakefile so Rake can be used from a Java IDE
185
+ test_files: []
186
+