Method: Naether::Maven#invoke

Defined in:
lib/naether/maven.rb

#invoke(*opts) ⇒ Object

Invoke a Maven goal



152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/naether/maven.rb', line 152

def invoke( *opts )
  #defaults
  config = {
    # Checks ENV for maven home, otherwise defaults /usr/share/maven
    # XXX: Reuse Eng.getMavenHome?
    :maven_home => ENV['maven.home'] || ENV['MAVEN_HOME'] || '/usr/share/maven',
    :local_repo => File.expand_path('~/.m2/repository')
  }

  if opts.last.is_a? Hash
    config = config.merge( opts.pop )
  end
  goals = opts

  pom = @project.getPomFile().getAbsolutePath()

  invoker = Naether::Java.create("com.tobedevoured.naether.maven.Invoker", config[:local_repo], config[:maven_home] )

  java_list = Naether::Java.convert_to_java_list(goals)
  if Naether.platform == 'java'
    invoker.execute( pom, java_list )
  else
    invoker._invoke('execute', 'Ljava.lang.String;Ljava.util.List;', pom, java_list)
  end
end