Skip to content

Commit 0918010

Browse files
committed
Add -Xversion command
1 parent 1ce8c7d commit 0918010

File tree

6 files changed

+51
-20
lines changed

6 files changed

+51
-20
lines changed

Rakefile

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,37 @@ Spec::Rake::SpecTask.new
66

77
task :default => :spec
88

9-
load './lib/jruby-launcher.rb'
9+
file './lib/jruby-launcher.rb' => 'version.h' do |t|
10+
version = nil
11+
IO.readlines(t.prerequisites.first).grep(/LAUNCHER_VERSION\s+"([^"]+)"/) {|l| version = $1 }
12+
ruby = IO.readlines(t.name)
13+
File.open(t.name, "wb") do |f|
14+
ruby.each do |l|
15+
f << l.sub(/VERSION\s*=\s*"([^"]*)"/, "VERSION = \"#{version}\"")
16+
end
17+
end
18+
end
1019

11-
gemspec = Gem::Specification.new do |s|
12-
s.name = %q{jruby-launcher}
13-
s.platform = Gem::Platform.new("java")
14-
s.version = JRubyLauncher::VERSION
15-
s.authors = ["Nick Sieger", "Vladimir Sizikov"]
16-
s.date = Date.today.to_s
17-
s.description = %q{Builds and installs a native launcher for JRuby on your system}
18-
s.summary = %q{Native launcher for JRuby}
19-
20-
s.extensions = ["extconf.rb"]
21-
s.files = FileList["COPYING", "README.txt", "Makefile", "Rakefile", "*.c", "*.cpp", "*.h", "inc/*.*", "**/*.rb", "resources/*.*"]
22-
s.homepage = %q{http://jruby.org}
23-
s.rubyforge_project = %q{jruby-extras}
20+
task :gemspec => './lib/jruby-launcher.rb' do
21+
@gemspec ||= Gem::Specification.new do |s|
22+
load './lib/jruby-launcher.rb'
23+
s.name = %q{jruby-launcher}
24+
s.platform = Gem::Platform.new("java")
25+
s.version = JRubyLauncher::VERSION
26+
s.authors = ["Nick Sieger", "Vladimir Sizikov"]
27+
s.date = Date.today.to_s
28+
s.description = %q{Builds and installs a native launcher for JRuby on your system}
29+
s.summary = %q{Native launcher for JRuby}
30+
31+
s.extensions = ["extconf.rb"]
32+
s.files = FileList["COPYING", "README.txt", "Makefile", "Rakefile", "*.c", "*.cpp", "*.h", "inc/*.*", "**/*.rb", "resources/*.*"]
33+
s.homepage = %q{http://jruby.org}
34+
s.rubyforge_project = %q{jruby-extras}
35+
end
2436
end
2537

26-
Rake::GemPackageTask.new(gemspec) do |pkg|
38+
task :package => :gemspec do
39+
Rake::GemPackageTask.new(@gemspec) do |pkg|
40+
end
41+
Rake::Task['gem'].invoke
2742
end

argnames.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
/*
2-
* File: argnames.h
3-
* Author: Holy
4-
*
5-
* Created on 4. prosinec 2008, 14:13
2+
* Copyright 2009-2010 JRuby Team (www.jruby.org).
63
*/
74

85
#ifndef _ARGNAMES_H

argparser.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "utilsfuncs.h"
99
#include "argparser.h"
1010
#include "argnames.h"
11+
#include "version.h"
1112

1213
#ifndef WIN32
1314
#include <sys/types.h>
@@ -319,6 +320,9 @@ bool ArgParser::parseArgs(int argc, char *argv[]) {
319320
printToConsole(appendHelp.c_str());
320321
}
321322
return false;
323+
} else if (strcmp(it->c_str(), "-Xversion") == 0) {
324+
printToConsole("JRuby Launcher Version " JRUBY_LAUNCHER_VERSION "\n");
325+
return false;
322326
} else {
323327
progArgs.push_back(*it);
324328
}

lib/jruby-launcher.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module JRubyLauncher
2-
VERSION = "1.0"
2+
VERSION = "1.0.1"
33
end

spec/launcher_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,8 @@
160160
it "should include a bare : at the end of the classpath, to include PWD in the path" do
161161
jruby_launcher_args("-Xnobootclasspath -e true").grep(/java\.class\.path/).first.should =~ /:$/
162162
end
163+
164+
it "should print the version" do
165+
jruby_launcher("-Xversion 2>&1").should =~ /Launcher Version [0-9.]+/
166+
end
163167
end

version.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
* Copyright 2009-2010 JRuby Team (www.jruby.org).
3+
*/
4+
5+
6+
#ifndef _VERSION_H_
7+
#define _VERSION_H_
8+
9+
#define JRUBY_LAUNCHER_VERSION "1.0.1"
10+
11+
#endif // ! _VERSION_H_

0 commit comments

Comments
 (0)