Debian Codegraph @

pmaven-gem/src/main/resources/bin/rmvn

raw
1 #!/usr/bin/env jruby
2 begin
3 require 'java'
4 rescue LoadError => e
5 raise "this executable need jruby. quit."
6 end
7
8 bin = File.dirname(__FILE__)
9 boot = File.join(bin, "..", "boot")
10 ext = File.join(bin, "..", "ext")
11
12 classpath = (Dir.glob(boot + "/*jar") + Dir.glob(ext + "/ruby-tools*jar")).join(":")
13
14 java.lang.System.setProperty("classworlds.conf", File.join(bin, "m2.conf"))
15
16 java.lang.System.setProperty("maven.home", File.join(bin, ".."))
17
18 classpath.split(":").each do |path|
19 require path
20 end
21
22 # make the command line for the goals of the jruby-maven-plugins nicer
23 plugins = {
24 :rake => [:rake],
25 :ruby => [:jruby, :compile],
26 :gem => [:package, :install, :push, :exec, :pom, :initialize, :irb],
27 :gemify => [:gemify, :versions],
28 :rails2 => [:new, :generate, :rake, :server, :console],
29 :rails3 => [:new, :generate, :rake, :server, :console, :dbconsole, :pom],
30 :cucumber => [:test],
31 :rspec => [:test],
32 :runit => [:test],
33 :bundler => [:install]
34 }
35 aliases = {:jruby => :ruby, :spec => :rspec, :rails => :rails3, :bundle => :bundler}
36
37 if ARGV.size > 0
38 name = ARGV[0].to_sym
39 name = aliases[name] || name
40 if plugins.member?(name)
41 start = 1
42 if ARGV.size > 1
43 if plugins[name].member? ARGV[1].to_sym
44 goal = ARGV[1].to_sym
45 start = 2
46 else
47 goal = plugins[name][0]
48 end
49 else
50 goal = plugins[name][0]
51 end
52 args = if index = ARGV.index("--")
53 ARGV[index + 1, 1000]
54 else
55 []
56 end
57 ruby_args = (ARGV[start, (index || 1000) - start] || []).join(' ')
58
59 # determine the version and delete from ARGV if given
60 version = ARGV.detect do |a|
61 a =~ /^-Dplugin.version=/
62 end
63 if version
64 args.delete(version)
65 version.sub!(/^-Dplugin.version=/, ':')
66 end
67 args << "de.saumya.mojo:#{name}-maven-plugin#{version}:#{goal}"
68 args << "-Dargs=#{ruby_args}" if ruby_args.size > 0
69 ARGV.replace(args)
70 else
71 ARGV.delete("--")
72 end
73 end
74 if ARGV.size == 0 || ARGV[0] == "--help"
75 puts "usage: rmvn [<plugin name>|<plugin alias> [<args>] [-- <maven options>] | [<maven goal>|<maven phase> <maven options>] | --help"
76 ARGV.replace(["--help"])
77 plugins.each do |name, goals|
78 puts
79 print "plugin #{name}"
80 print " - alias: #{aliases[name]}" if aliases[name]
81 puts
82 if goals.size > 1
83 print "\tgoals : #{goals.join(',')}"
84 puts
85 end
86 print "\tdefault goal: #{goals[0]}"
87 puts
88 end
89 puts
90 end
91
92 print "maven commandline: "
93 args = ARGV.dup
94 ARGV.clear # clean up in case another script gets executed with clean ARGV
95 puts args.join ' '
96
97 org.codehaus.plexus.classworlds.launcher.Launcher.main(args)