Sha256: 88dc8e8416866e5484afab2d11efe75cb7867acd92bf46d9f480bf1dd9b4bfa4

Contents?: true

Size: 1.43 KB

Versions: 6

Compression:

Stored size: 1.43 KB

Contents

# encoding: UTF-8

module Tetra
  # runs Maven with tetra-specific options
  class MavenRunner < KitRunner
    include Logging

    # runs Maven in a subprocess
    def mvn(options)
      run_executable(get_maven_commandline(@project.full_path, options))
    end

    # runs Maven to attempt getting a source jar
    # returns true if successful
    def get_source_jar(group_id, artifact_id, version)
      mvn(["dependency:get", "-Dartifact=#{group_id}:#{artifact_id}:#{version}:jar:sources", "-Dtransitive=false"])
    end

    # runs Maven to get the effective POM from an existing POM
    # returns effective pom path or nil if not found
    def get_effective_pom(pom_path)
      effective_pom_path = "#{pom_path}.effective"
      success = mvn(["help:effective-pom", "-f#{pom_path}", "-Doutput=#{File.split(effective_pom_path)[1]}"])
      if success
        effective_pom_path
      else
        nil
      end
    end

    # returns a command line for running Maven from the specified
    # prefix
    def get_maven_commandline(prefix, options)
      executable = find_executable("mvn")

      if !executable.nil?
        mvn_path = File.join(prefix, executable)
        repo_path = File.join(prefix, "kit", "m2")
        config_path = File.join(prefix, "kit", "m2", "settings.xml")

        "#{mvn_path} -Dmaven.repo.local=#{repo_path} -s#{config_path} #{options.join(" ")}"
      else
        fail ExecutableNotFoundError, "mvn"
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
tetra-0.45.0 lib/tetra/maven_runner.rb
tetra-0.44.0 lib/tetra/maven_runner.rb
tetra-0.43.0 lib/tetra/maven_runner.rb
tetra-0.42.0 lib/tetra/maven_runner.rb
tetra-0.41.0 lib/tetra/maven_runner.rb
tetra-0.40.0 lib/tetra/maven_runner.rb