module MavenDependency
Constants
- DEFAULT_OPTIONS
- VERSION
Public Class Methods
pom(*args)
click to toggle source
# File lib/maven_dependency.rb, line 37 def pom(*args) pom_(*args_opts(args)) end
resolve(*args)
click to toggle source
# File lib/maven_dependency.rb, line 12 def resolve(*args) args, opts = args_opts args pom, dep = 2.times.map { Tempfile.new('maven_dependency') } redirection = opts[:verbose] ? '' : '> /dev/null' begin pom << pom_(args, opts) pom.close dep.close system(%[mvn org.apache.maven.plugins:maven-dependency-plugin:build-classpath -Dsilent=true -Dmdep.outputFile=#{dep.path} -f #{pom.path} #{redirection} ].gsub($/, ' ')) unless (x = $?.exitstatus) == 0 raise RuntimeError, "mvn: exit status #{x}" end File.read(dep).split(':') ensure pom.unlink dep.unlink end end
Private Class Methods
args_opts(args)
click to toggle source
# File lib/maven_dependency.rb, line 42 def args_opts args args = args.dup opts = DEFAULT_OPTIONS.merge(args.last.is_a?(Hash) ? args.pop : {}) [args, opts] end
pom_(args, opts)
click to toggle source
# File lib/maven_dependency.rb, line 48 def pom_ args, opts @template ||= File.read( File.expand_path('../maven_dependency/template.xml.erb', __FILE__)) _specs = args.map { |spec| g, a, v, x = spec.split(/[\@\/:]/) if x || a.nil? || v.nil? raise ArgumentError, "invalid dependency format: #{spec}" end [g, a, v] } _repos = opts[:repositories] ERB.new(@template).result(binding) end