Raven, rake, ant and ruby

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

Although they seem to have lost their stylesheets for the last while,
rake has fine documentation at

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 K.

I suggest looking at buildr: buildr — Apache Buildr

-Stephen

On Mar 21, 4:50 pm, “Daniel Brumbaugh K.”
[email protected] wrote:

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
compile_my_program
end

Daniel Brumbaugh K.

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 => :clean do #really not a dependancy, but my
programs are small, so shouldn’t matter
puts “compile”
end

task :jar => :compile do
puts “jar”
end

task :test => :jar do
puts “test”
end

task :all => :test do
puts “all”
end

C:\code>
C:\code>

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

-Thufir

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
)

On Sun, 23 Mar 2008 08:59:31 +0900, Stephen D. Jr wrote:

I suggest looking at buildr: buildr — Apache Buildr

-Stephen

On ubuntu, at least, I can’t get the required gems to install correctly.
So, sticking with rake for the time being.

thank you, though.

-Thufir

On Sat, 29 Mar 2008 16:23:24 +0900, Mark R. wrote:

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

1
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

1
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