raven, rake, ant and ruby

T

Thufir

I don't really know how to put these together. What I do know is that my
previous experience with ant was that I found it awkward, so I'd rather
use rake. I'm not so sure about raven if only because I'm not convinced
that JRuby is viable and that if I run into a problem there may be no
solution, or that I won't be able to find it in a timely fashion.

I'm inclined to go with rake and ruby, but don't know how to get started
with rake. What would be the first step in creating a rake compile task
from Tasks.compile ?

thufir@arrakis:~/java$
thufir@arrakis:~/java$ cat tasks.rb
#/usr/bin/ruby

require 'fileutils'
module Tasks

JAVA = "/home/thufir/java/"
SRC = "src/"
BUILD = "build/"
COM = "com/"
WEB_TOMORROW = "web_tomorrow/"
PACKAGE = "package/"

def Tasks.clean
puts "\n\nclean...\n"
Dir.chdir("#{JAVA}")
puts "working directory:\t\t" + Dir.getwd + "\n\n"

FileUtils.rm_rf("#{BUILD}")
FileUtils.rm_rf("#{PACKAGE}")

Dir.mkdir("#{BUILD}")
Dir.mkdir(File.join(BUILD, COM))
Dir.mkdir(File.join(BUILD, COM, WEB_TOMORROW))
Dir.mkdir("#{PACKAGE}")

end


def Tasks.compile
puts "\n\ncompile...\n\n"
Dir.chdir(File.join(JAVA,SRC))
puts "working directory:\t\t" + Dir.getwd + "\n\n"
system("javac -cp . -d #{JAVA}#{BUILD} com/web_tomorrow/
CPTest2.java ")
end

def Tasks.create_manifest
puts "\n\ncreate_manifest...\n\n"
Dir.chdir(File.join(JAVA,BUILD))
File.open( 'manifest.txt', 'w' ) {
|f|
f.write("Main-Class:
com.web_tomorrow.CPTest2\n\n")
}
end


def Tasks.package
puts "\n\npackage...\n\n"

create_manifest

Dir.chdir("#{JAVA}")
puts "working directory:\t\t" + Dir.getwd + "\n\n"
# FileUtils.cp("/home/thufir/java/manifest.txt", "/home/
thufir/java/build/manifest.txt")
Dir.chdir("#{BUILD}")
puts "working directory:\t\t" + Dir.getwd + "\n\n"
system("jar -cfmv foo.jar manifest.txt com/web_tomorrow/
*.class")
FileUtils.mv("/home/thufir/java/build/foo.jar", "/home/
thufir/java/package/foo.jar")
end


def Tasks.examine_jar
puts "\n\nexamine_jar...\n\n"
Dir.chdir("#{BUILD}")
puts "working directory:\t\t" + Dir.getwd + "\n\n"
system("jar -tf foo.jar")
system("jar -xf foo.jar META-INF/MANIFEST.MF")
system("cat META-INF/MANIFEST.MF -n")
end


def Tasks.test
puts "\n\ntest...\n\n"
Dir.chdir("#{JAVA}")
Dir.chdir("#{PACKAGE}")
puts "working directory:\t\t" + Dir.getwd + "\n\n"
system("java -jar foo.jar")
end

end
thufir@arrakis:~/java$




thanks,

Thufir
 
D

Daniel Brumbaugh Keeney

Although they seem to have lost their stylesheets for the last while,
rake has fine documentation at
http://docs.rubyrake.org/

but, to start, rake tasks basically look like
desc 'Compile the program from the Java sources'
task :compile do
compile_my_program
end

Daniel Brumbaugh Keeney
 
T

Thufir

Although they seem to have lost their stylesheets for the last while,
rake has fine documentation athttp://docs.rubyrake.org/

but, to start, rake tasks basically look like
desc 'Compile the program from the Java sources'
task :compile do
=A0 compile_my_program
end

Daniel Brumbaugh Keeney


I read the tutorial at http://www.railsenvy.com/2007/6/11/ruby-on-rails-rake=
-tutorial
and came up with:

C:\code>
C:\code>rake all
(in C:/code)
clean
compile
jar
test
all

C:\code>
C:\code>type rakefile.rb
task :clobber do
puts "clobber"
end

task :clean do
puts "clean"
end

task :compile =3D> :clean do #really not a dependancy, but my
programs are small, so shouldn't matter
puts "compile"
end

task :jar =3D> :compile do
puts "jar"
end

task :test =3D> :jar do
puts "test"
end


task :all =3D> :test do
puts "all"
end

C:\code>
C:\code>

which looks promising, I think I can convert my ruby script to a rake
file :)


-Thufir
 
M

Mark Ryall

[Note: parts of this message were removed to make it a legal post.]

I had some difficulty installing buildr too (actually a problem compiling
rjb) but managed to get it working by installing some missing libraries:

sudo apt-get install ruby
sudo apt-get install ruby1.8-dev
sudo apt-get install build-essential
sudo apt-get install libopenssl-ruby

sudo gem install --source http://gems.tron.name/gems.rubyforge.org/ buildr

(from the discussion here
http://groups.google.com/group/buildr-talk/browse_thread/thread/640f9903f0a3f290/437e14f8367be1fc
)
 
T

thufir

I had some difficulty installing buildr too (actually a problem
compiling rjb) but managed to get it working by installing some missing
libraries:

I tried those, and still:

thufir@arrakis:~$
thufir@arrakis:~$ sudo gem install --source http://gems.tron.name/
gems.rubyforge.org/ buildr -y
[sudo] password for thufir:
Bulk updating Gem source index for: http://gems.tron.name/
gems.rubyforge.org/
ERROR: While executing gem ... (Gem::GemNotFoundException)
Could not find buildr (> 0) in any repository
thufir@arrakis:~$
thufir@arrakis:~$
thufir@arrakis:~$ sudo gem install --source http://gems.tron.name/
gems.rubyforge.org/ buildr -y
Bulk updating Gem source index for: http://gems.tron.name/
gems.rubyforge.org/
Select which gem to install for your platform (i486-linux)
1. Antwrap 0.6.0 (ruby)
2. Antwrap 0.6.0 (java)
3. Skip this gem
4. Cancel installation
Select which gem to install for your platform (i486-linux)
1. rjb 1.1.3 (ruby)
2. rjb 1.1.2 (x86-mswin32-60)
3. rjb 1.1.2 (ruby)
4. rjb 1.1.1 (x86-mswin32-60)
5. rjb 1.1.1 (ruby)
6. Skip this gem
7. Cancel installation
Building native extensions. This could take a while...
ERROR: While executing gem ... (Gem::Installer::ExtensionBuildError)
ERROR: Failed to build gem native extension.

ruby extconf.rb install --source http://gems.tron.name/
gems.rubyforge.org/ buildr -y
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/bin/ruby1.8
extconf.rb:44: JAVA_HOME is not setted. (RuntimeError)


Gem files will remain installed in /var/lib/gems/1.8/gems/rjb-1.1.3 for
inspection.
Results logged to /var/lib/gems/1.8/gems/rjb-1.1.3/ext/gem_make.out
thufir@arrakis:~$




any thoughts?


thanks,

Thufir
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top