Sha256: d55254e7619f9631e51318a01a755e864a39f6feef19ab90d5f5eefe8bdfc950
Contents?: true
Size: 1.75 KB
Versions: 2
Compression:
Stored size: 1.75 KB
Contents
# encoding: UTF-8 require 'find' require 'pathname' module Gjp # runs Maven from a gjp kit with gjp-specific options class MavenRunner include Logger 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 log.debug("Maven executable not found") 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 if maven_executable != nil 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 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(".") maven_commandline = get_maven_commandline(kit_full_path, running_full_path) if maven_commandline == nil raise MavenNotFoundException end Process.wait(Process.spawn("#{maven_commandline} #{options.join(' ')}")) end end class MavenNotFoundException < Exception end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gjp-0.14.1 | lib/gjp/maven_runner.rb |
gjp-0.13.1 | lib/gjp/maven_runner.rb |