ruby-maven 3.0.4.1 → 3.0.4.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,5 @@
1
1
  require 'maven/ruby/maven'
2
+ require 'maven/ruby/pom_magic'
2
3
  module Maven
3
4
  module Ruby
4
5
  class Cli
@@ -58,7 +59,7 @@ module Maven
58
59
  ruby_args = (args[start, (index || 1000) - start] || []).join(' ')
59
60
 
60
61
  aa << "de.saumya.mojo:#{name}-maven-plugin#{version}:#{goal}"
61
- aa << "-Dargs=\"#{ruby_args}\"" if ruby_args.size > 0
62
+ aa << "\"-Dargs=#{ruby_args}\"" if ruby_args.size > 0
62
63
  args.replace(aa)
63
64
  else
64
65
  args.delete("--")
@@ -104,30 +105,37 @@ module Maven
104
105
  args
105
106
  end
106
107
 
107
- def setup(*args)
108
- args = magic_pom(args)
108
+ def setup(dir = '.', *args)
109
109
  log(args)
110
- command_line(args.dup.flatten)
110
+ args = command_line(args.dup.flatten)
111
+ args = magic_pom(dir, *args) unless options.delete('--no-pom')
112
+ args
113
+ end
114
+
115
+ def mvn
116
+ @mvn ||= Maven.new
111
117
  end
112
118
 
113
119
  protected
114
120
 
115
- def magic_pom(*args)
116
- file = PomMagic.new.generate_pom(args)
117
- args += ['-f', file] if file && !(args.member?("-f") || args.member?("--file"))
118
- args
121
+ def magic_pom(dir = '.', *args)
122
+ file = PomMagic.new.generate_pom(File.expand_path(dir), *args)
123
+ args += ['-f', file] if file && !(args.member?("-f") || args.member?("--file"))
124
+ args.flatten
119
125
  end
120
126
 
121
127
  public
122
128
 
129
+ def options
130
+ mvn.options
131
+ end
132
+
123
133
  def exec(*args)
124
- mvn = Maven.new
125
- mvn.exec(setup(args))
134
+ mvn.exec(setup('.', *args))
126
135
  end
127
136
 
128
137
  def exec_in(launchdirectory, *args)
129
- mvn = Maven.new
130
- mvn.exec_in(launchdirectory, setup(args))
138
+ mvn.exec_in(launchdirectory, setup(launchdirectory, *args))
131
139
  end
132
140
  end
133
141
  end
@@ -1,127 +1,146 @@
1
+ require 'maven/ruby/maven'
2
+ require 'maven/ruby/pom_magic'
1
3
  module Maven
2
- class RubyCli
4
+ module Ruby
5
+ class Cli
3
6
 
4
- private
7
+ private
5
8
 
6
- # make the command line for the goals of the jruby-maven-plugins nicer
7
- PLUGINS = {
8
- :rake => [:rake],
9
- :jruby => [:jruby, :compile],
10
- :gem => [:package, :install, :push, :exec, :pom, :initialize, :irb],
11
- :rails3 => [:new, :generate, :rake, :server, :console, :dbconsole, :pom, :initialize],
12
- :cucumber => [:test],
13
- :rspec => [:test],
14
- :runit => [:test],
15
- :mini => [:test,:spec],
16
- :bundler => [:install, :update]
17
- }
18
- ALIASES = {
19
- :ruby => :jruby,
20
- :spec => :rspec,
21
- :rails => :rails3,
22
- :bundle => :bundler
23
- }
9
+ # make the command line for the goals of the jruby-maven-plugins nicer
10
+ PLUGINS = {
11
+ :rake => [:rake],
12
+ :jruby => [:jruby, :compile],
13
+ :gem => [:package, :install, :push, :exec, :pom, :initialize, :irb],
14
+ :rails3 => [:new, :generate, :rake, :server, :console, :dbconsole, :pom, :initialize],
15
+ :cucumber => [:test],
16
+ :rspec => [:test],
17
+ :runit => [:test],
18
+ :mini => [:test,:spec],
19
+ :bundler => [:install, :update]
20
+ }
21
+ ALIASES = {
22
+ :ruby => :jruby,
23
+ :spec => :rspec,
24
+ :rails => :rails3,
25
+ :bundle => :bundler
26
+ }
24
27
 
25
- def prepare(args)
26
- if args.size > 0
27
- name = args[0].to_sym
28
- name = ALIASES[name] || name
29
- if PLUGINS.member?(name)
30
- start = 1
31
- if args.size > 1
32
- if PLUGINS[name].member? args[1].to_sym
33
- goal = args[1].to_sym
34
- start = 2
28
+ def prepare(args)
29
+ if args.size > 0
30
+ name = args[0].to_sym
31
+ name = ALIASES[name] || name
32
+ if PLUGINS.member?(name)
33
+ start = 1
34
+ if args.size > 1
35
+ if PLUGINS[name].member? args[1].to_sym
36
+ goal = args[1].to_sym
37
+ start = 2
38
+ else
39
+ goal = PLUGINS[name][0]
40
+ end
35
41
  else
36
42
  goal = PLUGINS[name][0]
37
43
  end
38
- else
39
- goal = PLUGINS[name][0]
40
- end
41
- # determine the version and delete from args if given
42
- version = args.detect do |a|
43
- a =~ /^-Dplugin.version=/
44
- end
45
- version ||= options['-Dplugin.version']
44
+ # determine the version and delete from args if given
45
+ version = args.detect do |a|
46
+ a =~ /^-Dplugin.version=/
47
+ end
48
+ version ||= options['-Dplugin.version']
46
49
 
47
- if version
48
- args.delete(version)
49
- version = ":" + version.sub(/^-Dplugin.version=/, '')
50
- end
51
- aa = if index = args.index("--")
52
- args[(index + 1)..-1]
53
- else
54
- []
55
- end
56
- ruby_args = (args[start, (index || 1000) - start] || []).join(' ')
50
+ if version
51
+ args.delete(version)
52
+ version = ":" + version.sub(/^-Dplugin.version=/, '')
53
+ end
54
+ aa = if index = args.index("--")
55
+ args[(index + 1)..-1]
56
+ else
57
+ []
58
+ end
59
+ ruby_args = (args[start, (index || 1000) - start] || []).join(' ')
57
60
 
58
- aa << "de.saumya.mojo:#{name}-maven-plugin#{version}:#{goal}"
59
- aa << "-Dargs=\"#{ruby_args}\"" if ruby_args.size > 0
60
- args.replace(aa)
61
- else
62
- args.delete("--")
61
+ aa << "de.saumya.mojo:#{name}-maven-plugin#{version}:#{goal}"
62
+ aa << "-Dargs=\"#{ruby_args}\"" if ruby_args.size > 0
63
+ args.replace(aa)
64
+ else
65
+ args.delete("--")
66
+ end
63
67
  end
68
+ args
64
69
  end
65
- args
66
- end
67
70
 
68
- def log(args)
69
- log = File.join('log', 'rmvn.log')
70
- if File.exists? File.dirname(log)
71
- File.open(log, 'a') do |f|
72
- f.puts "#{$0.sub(/.*\//, '')} #{args.join ' '}"
71
+ def log(args)
72
+ log = File.join('log', 'rmvn.log')
73
+ if File.exists? File.dirname(log)
74
+ File.open(log, 'a') do |f|
75
+ f.puts "#{$0.sub(/.*\//, '')} #{args.join ' '}"
76
+ end
73
77
  end
74
78
  end
75
- end
76
79
 
77
- def maybe_print_help(args)
78
- if args.size == 0 || args[0] == "--help"
79
- puts "usage: rmvn [<plugin-name> [<args>] [-- <maven-options>]] | [<maven-goal>|<maven-phase> <maven-options>] | --help"
80
- PLUGINS.each do |name, goals|
81
- puts
82
- print "plugin #{name}"
83
- print " - alias: #{ALIASES.invert[name]}" if ALIASES.invert[name]
84
- puts
85
- if goals.size > 1
86
- print "\tgoals : #{goals.join(',')}"
80
+ def maybe_print_help(args)
81
+ if args.size == 0 || args[0] == "--help"
82
+ puts "usage: rmvn [<plugin-name> [<args>] [-- <maven-options>]] | [<maven-goal>|<maven-phase> <maven-options>] | --help"
83
+ PLUGINS.each do |name, goals|
84
+ puts
85
+ print "plugin #{name}"
86
+ print " - alias: #{ALIASES.invert[name]}" if ALIASES.invert[name]
87
+ puts
88
+ if goals.size > 1
89
+ print "\tgoals : #{goals.join(',')}"
90
+ puts
91
+ end
92
+ print "\tdefault goal: #{goals[0]}"
87
93
  puts
88
94
  end
89
- print "\tdefault goal: #{goals[0]}"
90
95
  puts
96
+ ["--help"]
97
+ else
98
+ args
91
99
  end
92
- puts
93
- ["--help"]
94
- else
100
+ end
101
+
102
+ def command_line(args)
103
+ args = prepare(args)
104
+ args = maybe_print_help(args)
105
+ p args
95
106
  args
96
107
  end
97
- end
98
108
 
99
- def command_line(args)
100
- args = prepare(args)
101
- args = maybe_print_help(args)
102
- args
103
- end
109
+ def setup(dir = '.', *args)
110
+ args = magic_pom(dir, *args)
111
+ log(args)
112
+ command_line(args.dup.flatten)
113
+ end
104
114
 
105
- def setup(*args)
106
- log(args)
107
- command_line(args.dup.flatten)
108
- end
115
+ def mvn
116
+ @mvn ||= Maven.new
117
+ end
109
118
 
110
- public
119
+ protected
120
+
121
+ def magic_pom(dir = '.', *args)
122
+ p args
123
+ file = PomMagic.new.generate_pom(File.expand_path(dir), *args)
124
+ p file
125
+ args += ['-f', file] if file && !(args.member?("-f") || args.member?("--file"))
126
+ p args.flatten
127
+ args.flatten
128
+ end
111
129
 
112
- attr_accessors :verbose
130
+ public
113
131
 
114
- def exec(*args)
115
- mvn = RubyMaven.new
116
- mvn.verbose = verbose
117
- mvn.exec(setup(args))
118
- end
132
+ def options
133
+ mvn.options
134
+ end
119
135
 
120
- def exec_in(launchdirectory, *args)
121
- mvn = RubyMaven.new
122
- mvn.verbose = verbose
123
- mvn.exec(launchdirectory, setup(args))
124
- end
136
+ def exec(*args)
137
+ mvn.exec(setup('.', *args))
138
+ end
125
139
 
140
+ def exec_in(launchdirectory, *args)
141
+ p launchdirectory
142
+ mvn.exec_in(launchdirectory, setup(launchdirectory, *args))
143
+ end
144
+ end
126
145
  end
127
146
  end
@@ -2,6 +2,15 @@ require 'fileutils'
2
2
  require 'java' if defined? JRUBY_VERSION
3
3
 
4
4
  module Maven
5
+
6
+ class RubyMaven
7
+
8
+ def self.new(*args)
9
+ warn "deprecated: use Maven::Ruby::Cli or Maven::Ruby::Maven instead"
10
+ ::Maven::Ruby::Cli.new(*args)
11
+ end
12
+ end
13
+
5
14
  module Ruby
6
15
  class Maven
7
16
 
@@ -12,7 +21,6 @@ module Maven
12
21
  File.join(self.class.maven_home, 'bin', "m2.conf"))
13
22
 
14
23
  java.lang.System.setProperty("maven.home", self.class.maven_home)
15
-
16
24
  cw = self.class.class_world
17
25
  org.apache.maven.cli.MavenCli.doMain( args, cw ) == 0
18
26
  end
@@ -44,11 +52,15 @@ module Maven
44
52
  options.collect do |k,v|
45
53
  if k =~ /^-D/
46
54
  v = "=#{v}" unless v.nil?
55
+ "#{k}#{v}"
47
56
  else
48
- v = " #{v}" unless v.nil?
57
+ if v.nil?
58
+ "#{k}"
59
+ else
60
+ ["#{k}", "#{v}"]
61
+ end
49
62
  end
50
- "#{k}#{v}"
51
- end
63
+ end.flatten
52
64
  end
53
65
 
54
66
  public
@@ -79,30 +91,34 @@ module Maven
79
91
 
80
92
  def verbose
81
93
  if @verbose.nil?
82
- options.delete('-Dverbose').to_s == 'true'
94
+ @verbose = options.delete('-Dverbose').to_s == 'true'
83
95
  else
84
96
  @verbose
85
97
  end
86
98
  end
87
99
 
88
100
  def exec(*args)
101
+ puts "PWD: #{File.expand_path('.')}" if verbose
89
102
  a = args.dup + options_array
90
103
  a.flatten!
91
104
  puts "mvn #{a.join(' ')}" if verbose
92
105
  if defined? JRUBY_VERSION
106
+ puts "using jruby #{JRUBY_VERSION}" if verbose
93
107
  launch_jruby(a)
94
108
  else
109
+ puts "using java" if verbose
95
110
  launch_java(a)
96
111
  end
97
112
  end
98
113
 
99
114
  def exec_in(launchdirectory, *args)
100
115
  succeeded = nil
101
- FileUtils.cd(launchdirectory) do
116
+ Dir.chdir(launchdirectory) do
102
117
  succeeded = exec(args)
103
118
  end
104
119
  succeeded
105
120
  end
106
121
  end
107
122
  end
123
+
108
124
  end
@@ -2,92 +2,131 @@ require 'fileutils'
2
2
  require 'java' if defined? JRUBY_VERSION
3
3
 
4
4
  module Maven
5
+
5
6
  class RubyMaven
7
+
8
+ def self.new(*args)
9
+ warn "deprecated: use Maven::Ruby::Cli or Maven::Ruby::Maven instead"
10
+ ::Maven::Ruby::Cli.new(*args)
11
+ end
12
+ end
6
13
 
7
- private
14
+ module Ruby
15
+ class Maven
8
16
 
9
- def launch_jruby(args)
10
- classpath_array.each do |path|
11
- require path
12
- end
17
+ private
13
18
 
14
- java.lang.System.setProperty("classworlds.conf",
15
- File.join(@maven_home, 'bin', "m2.conf"))
19
+ def launch_jruby(args)
20
+ java.lang.System.setProperty("classworlds.conf",
21
+ File.join(self.class.maven_home, 'bin', "m2.conf"))
16
22
 
17
- java.lang.System.setProperty("maven.home", @maven_home)
23
+ java.lang.System.setProperty("maven.home", self.class.maven_home)
24
+ # java.lang.System.setProperty("user.dir", Dir.pwd)
25
+ p "Asd"
26
+ p Dir.pwd
27
+ p java.lang.System.getProperty("user.dir")
28
+ cw = self.class.class_world
29
+ Dir.chdir(Dir.pwd) do
30
+ org.apache.maven.cli.MavenCli.doMain( args, cw ) == 0
31
+ end
32
+ end
18
33
 
19
- org.codehaus.plexus.classworlds.launcher.Launcher.main(args)
20
- end
34
+ def self.class_world
35
+ @class_world ||= class_world!
36
+ end
21
37
 
22
- def classpath_array
23
- Dir.glob(File.join(@maven_home, "boot", "*jar"))
24
- end
25
-
26
- def launch_java(*args)
27
- system "java -cp #{classpath_array.join(':')} -Dmaven.home=#{File.expand_path(@maven_home)} -Dclassworlds.conf=#{File.expand_path(File.join(@maven_home, 'bin', 'm2.conf'))} org.codehaus.plexus.classworlds.launcher.Launcher #{args.join ' '}"
28
- end
29
-
30
- def options_string
31
- options_array.join ' '
32
- end
33
-
34
- def options_array
35
- options.collect do |k,v|
36
- if k =~ /^-D/
37
- v = "=#{v}" unless v.nil?
38
- else
39
- v = " #{v}" unless v.nil?
38
+ def self.class_world!
39
+ (classpath_array + classpath_array('lib')).each do |path|
40
+ require path
40
41
  end
41
- "#{k}#{v}"
42
+ org.codehaus.plexus.classworlds.ClassWorld.new("plexus.core", java.lang.Thread.currentThread().getContextClassLoader())
43
+ end
44
+
45
+ def self.classpath_array(dir = 'boot')
46
+ Dir.glob(File.join(maven_home, dir, "*jar"))
47
+ end
48
+
49
+ def launch_java(*args)
50
+ system "java -cp #{self.class.classpath_array.join(':')} -Dmaven.home=#{File.expand_path(self.class.maven_home)} -Dclassworlds.conf=#{File.expand_path(File.join(self.class.maven_home, 'bin', 'm2.conf'))} org.codehaus.plexus.classworlds.launcher.Launcher #{args.join ' '}"
51
+ end
52
+
53
+ def options_string
54
+ options_array.join ' '
55
+ end
56
+
57
+ def options_array
58
+ options.collect do |k,v|
59
+ if k =~ /^-D/
60
+ v = "=#{v}" unless v.nil?
61
+ "#{k}#{v}"
62
+ else
63
+ if v.nil?
64
+ "#{k}"
65
+ else
66
+ ["#{k}", "#{v}"]
67
+ end
68
+ end
69
+ end.flatten
42
70
  end
43
- end
44
71
 
45
- public
72
+ public
46
73
 
47
- def maven_home
48
- @maven_home = File.expand_path(File.join(File.dirname(__FILE__),
49
- '..',
50
- '..',
51
- '..'))
52
- end
74
+ def self.class_world
75
+ @class_world ||= class_world!
76
+ end
53
77
 
54
- def options
55
- @options ||= {}
56
- end
78
+ def self.maven_home
79
+ @maven_home = File.expand_path(File.join(File.dirname(__FILE__),
80
+ '..',
81
+ '..',
82
+ '..',
83
+ '..'))
84
+ end
57
85
 
58
- def verbose= v
59
- @verbose = v
60
- end
86
+ def options
87
+ @options ||= {}
88
+ end
61
89
 
62
- def property(key, value = nil)
63
- options["-D#{key}"] = value
64
- end
90
+ def verbose= v
91
+ @verbose = v
92
+ end
65
93
 
66
- def verbose
67
- if @verbose.nil?
68
- options.delete('--verbose').to_s == 'true'
69
- else
70
- @verbose
94
+ def property(key, value = nil)
95
+ options["-D#{key}"] = value
71
96
  end
72
- end
73
97
 
74
- def exec(*args)
75
- a = args.dup + options_array
76
- a.flatten!
77
- puts "mvn #{a.join(' ')}" if verbose
78
- if defined? JRUBY_VERSION
79
- launch_jruby(a)
80
- else
81
- launch_java(a)
98
+ def verbose
99
+ if @verbose.nil?
100
+ @verbose = options.delete('-Dverbose').to_s == 'true'
101
+ else
102
+ @verbose
103
+ end
82
104
  end
83
- end
84
105
 
85
- def exec_in(launchdirectory, *args)
86
- succeeded = nil
87
- FileUtils.cd(launchdirectory) do
88
- succeeded = exec(args)
106
+ def exec(*args)
107
+ a = args.dup + options_array
108
+ a.flatten!
109
+ if verbose
110
+ puts "PWD: #{File.expand_path('.')}"
111
+ puts "mvn #{a.join(' ')}"
112
+ end
113
+ if defined? JRUBY_VERSION
114
+ puts "using jruby #{JRUBY_VERSION}" if verbose
115
+ launch_jruby(a)
116
+ else
117
+ puts "using java" if verbose
118
+ launch_java(a)
119
+ end
120
+ end
121
+
122
+ def exec_in(launchdirectory, *args)
123
+ succeeded = nil
124
+ Dir.chdir(launchdirectory) do
125
+ succeeded = exec(args)
126
+ end
127
+ succeeded
89
128
  end
90
- succeeded
91
129
  end
92
130
  end
131
+
93
132
  end
@@ -18,46 +18,50 @@ module Maven
18
18
  end
19
19
 
20
20
  def generate_pom(dir = '.', *args)
21
- if index = (args.index("-f") || args.index("--file"))
22
- filename = args[index + 1]
23
- if filename =~ /.gemspec$/
24
- proj = ::Maven::Tools::GemProject.new
25
- proj.load_gemspec(filename)
26
- elsif filename =~ /Gemfile/
27
- proj = ::Maven::Tools::GemProject.new
28
- proj.load_gemfile(filename)
29
- end
30
- else
31
- gemfiles = Dir[File.join(dir, "*Gemfile")]
32
- gemfiles.delete_if {|g| g =~ /.pom/}
33
- if gemfiles.size > 0
34
- proj =
35
- if File.exists? File.join( dir, 'config', 'application.rb' )
36
- new_rails_project
37
- else
38
- ::Maven::Tools::GemProject.new
39
- end
40
- filename = gemfiles[0]
41
- proj.load_gemfile(filename)
42
- else
43
- gemspecs = Dir[File.join(dir, "*.gemspec")]
44
- gemspecs.delete_if {|g| g =~ /.pom/}
45
- if gemspecs.size > 0
21
+ pom = nil
22
+ Dir.chdir(dir) do
23
+ if index = (args.index("-f") || args.index("--file"))
24
+ filename = args[index + 1]
25
+ if filename =~ /.gemspec$/
46
26
  proj = ::Maven::Tools::GemProject.new
47
- filename = gemspecs[0]
48
27
  proj.load_gemspec(filename)
28
+ elsif filename =~ /Gemfile/
29
+ proj = ::Maven::Tools::GemProject.new
30
+ proj.load_gemfile(filename)
31
+ end
32
+ else
33
+ gemfiles = Dir[File.join('.', "*Gemfile")]
34
+ gemfiles.delete_if {|g| g =~ /.pom/}
35
+ if gemfiles.size > 0
36
+ proj =
37
+ if File.exists? File.join( 'config', 'application.rb' )
38
+ new_rails_project
39
+ else
40
+ ::Maven::Tools::GemProject.new
41
+ end
42
+ filename = gemfiles[0]
43
+ proj.load_gemfile(filename)
44
+ else
45
+ gemspecs = Dir[File.join('.', "*.gemspec")]
46
+ gemspecs.delete_if {|g| g =~ /.pom/}
47
+ if gemspecs.size > 0
48
+ proj = ::Maven::Tools::GemProject.new
49
+ filename = File.basename(gemspecs[0])
50
+ proj.load_gemspec(filename)
51
+ end
49
52
  end
50
53
  end
51
- end
52
- if proj
53
- proj.load_jarfile(File.join(File.dirname(filename), 'Jarfile'))
54
- proj.load_gemfile(File.join(File.dirname(filename), 'Mavenfile'))
55
- proj.add_defaults
56
- File.open(pom_xml(dir), 'w') do |f|
57
- f.puts proj.to_xml
54
+ if proj
55
+ proj.load_jarfile(File.join(File.dirname(filename), 'Jarfile'))
56
+ proj.load_gemfile(File.join(File.dirname(filename), 'Mavenfile'))
57
+ proj.add_defaults
58
+ pom = pom_xml(dir)
59
+ File.open(pom, 'w') do |f|
60
+ f.puts proj.to_xml
61
+ end
58
62
  end
59
- pom_xml(dir)
60
63
  end
64
+ pom
61
65
  end
62
66
 
63
67
  def dump_pom(dir = '.', force = false, file = 'pom.xml')
@@ -1,55 +1,77 @@
1
1
  require 'fileutils'
2
2
  require 'maven/tools/rails_project'
3
- require 'java' if defined? JRUBY_VERSION
4
3
 
5
4
  module Maven
6
- class PomMagic
5
+ module Ruby
6
+ class PomMagic
7
7
 
8
- def new_rails_project
9
- Maven::Tools::RailsProject.new
10
- end
8
+ def initialize(pom = '.pom.xml')
9
+ @pom = pom
10
+ end
11
+
12
+ def new_rails_project
13
+ ::Maven::Tools::RailsProject.new
14
+ end
15
+
16
+ def pom_xml(dir = '.')
17
+ File.join(dir, @pom)
18
+ end
11
19
 
12
- def generate_pom(*args)
13
- unless args.member?("-f") || args.member?("--file")
14
- gemfiles = Dir["*Gemfile"]
15
- gemfiles.delete_if {|g| g =~ /.pom/}
16
- if gemfiles.size > 0
17
- proj =
18
- if File.exists? File.join( 'config', 'application.rb' )
19
- new_rails_project
20
+ def generate_pom(dir = '.', *args)
21
+ pom = nil
22
+ FileUtils.cd(dir) do
23
+ if index = (args.index("-f") || args.index("--file"))
24
+ filename = args[index + 1]
25
+ if filename =~ /.gemspec$/
26
+ proj = ::Maven::Tools::GemProject.new
27
+ proj.load_gemspec(filename)
28
+ elsif filename =~ /Gemfile/
29
+ proj = ::Maven::Tools::GemProject.new
30
+ proj.load_gemfile(filename)
31
+ end
32
+ else
33
+ gemfiles = Dir[File.join('.', "*Gemfile")]
34
+ gemfiles.delete_if {|g| g =~ /.pom/}
35
+ if gemfiles.size > 0
36
+ proj =
37
+ if File.exists? File.join( 'config', 'application.rb' )
38
+ new_rails_project
39
+ else
40
+ ::Maven::Tools::GemProject.new
41
+ end
42
+ filename = gemfiles[0]
43
+ proj.load_gemfile(filename)
20
44
  else
21
- Maven::Tools::GemProject.new
45
+ p File.join(dir, "*.gemspec")
46
+ gemspecs = Dir[File.join('.', "*.gemspec")]
47
+ gemspecs.delete_if {|g| g =~ /.pom/}
48
+ if gemspecs.size > 0
49
+ proj = ::Maven::Tools::GemProject.new
50
+ filename = File.basename(gemspecs[0])
51
+ p filename
52
+ p File.expand_path '.'
53
+ p dir
54
+ proj.load_gemspec(filename)
55
+ end
22
56
  end
23
- filename = gemfiles[0]
24
- proj.load_gemfile(filename)
25
- else
26
- gemspecs = Dir["*.gemspec"]
27
- gemspecs.delete_if {|g| g =~ /.pom/}
28
- if gemspecs.size > 0
29
- proj = Maven::Tools::GemProject.new
30
- filename = gemspecs[0]
31
- proj.load_gemspec(filename)
32
57
  end
33
- end
34
- if proc
35
- proj.load_jarfile(File.join(File.dirname(filename), 'Jarfile'))
36
- proj.load_gemfile(File.join(File.dirname(filename), 'Mavenfile'))
37
- proj.add_defaults
38
- pom = ".pom.xml"
39
- File.open(pom, 'w') do |f|
40
- f.puts proj.to_xml
58
+ if proj
59
+ proj.load_jarfile(File.join(File.dirname(filename), 'Jarfile'))
60
+ proj.load_gemfile(File.join(File.dirname(filename), 'Mavenfile'))
61
+ proj.add_defaults
62
+ pom = pom_xml(dir)
63
+ File.open(pom, 'w') do |f|
64
+ f.puts proj.to_xml
65
+ end
41
66
  end
42
- args << '-f'
43
- args << pom
44
67
  end
68
+ pom
45
69
  end
46
- args
47
- end
48
70
 
49
- def dump_pom(force = false, file = 'pom.xml')
50
- if force || !File.exists?(file)
51
- generate_pom
52
- FileUtils.cp(".pom.xml", file)
71
+ def dump_pom(dir = '.', force = false, file = 'pom.xml')
72
+ if force || !File.exists?(file)
73
+ FileUtils.cp(generate_pom(dir), file)
74
+ end
53
75
  end
54
76
  end
55
77
  end
@@ -1,5 +1,5 @@
1
1
  module Maven
2
2
  module Ruby
3
- VERSION = '3.0.4.1'
3
+ VERSION = '3.0.4.1.1'
4
4
  end
5
5
  end
@@ -1,6 +1,5 @@
1
1
  module Maven
2
2
  module Ruby
3
- class Version
4
- end
3
+ VERSION = '3.0.4.1'
5
4
  end
6
5
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: ruby-maven
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 3.0.4.1
5
+ version: 3.0.4.1.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - mkristian
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-08-13 00:00:00 Z
13
+ date: 2012-11-06 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: thor
@@ -34,7 +34,7 @@ dependencies:
34
34
  requirements:
35
35
  - - ~>
36
36
  - !ruby/object:Gem::Version
37
- version: 0.29.1
37
+ version: "0.29"
38
38
  type: :runtime
39
39
  version_requirements: *id002
40
40
  - !ruby/object:Gem::Dependency