Sha256: 05e154b96506250b2fdaf7cb013f9d29f0042defd87c1d14b9c8d32490b953a0
Contents?: true
Size: 1.5 KB
Versions: 1
Compression:
Stored size: 1.5 KB
Contents
# encoding: UTF-8 require 'find' require 'pathname' module Gjp # runs Maven from a gjp kit with gjp-specific options class MavenRunner def log Gjp.logger end def initialize(project) @project = project end # finds mvn in kit def find_maven_executable @project.from_directory do Find.find("kit") do |path| if path =~ /bin\/mvn$/ log.debug("found Maven executable: #{path}") return path end end end nil end # returns a command line for running Maven def get_maven_commandline(kit_full_path, running_full_path) prefix = path_from running_full_path, kit_full_path maven_executable = find_maven_executable mvn_path = File.join(prefix, maven_executable) repo_path = File.join(prefix, "kit", "m2") config_path = File.join(prefix, "kit", "m2", "settings.xml") "#{mvn_path} -Dmaven.repo.local=`readlink -e #{repo_path}` -s`readlink -e #{config_path}`" end # returns a path from origin to destination, provided they are both absolute def path_from(origin, destination) (Pathname.new(destination).relative_path_from Pathname.new(origin)).split.first end # runs mvn in a subprocess def mvn(options) kit_full_path = File.join(@project.full_path, "kit") running_full_path = File.expand_path(".") Process.wait(Process.spawn("#{get_maven_commandline(kit_full_path, running_full_path)} #{options.join(' ')}")) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gjp-0.11.1 | lib/gjp/maven_runner.rb |