Class: Gjp::SourceGetter

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/gjp/source_getter.rb

Overview

attempts to get java projects’ sources

Instance Method Summary collapse

Methods included from Logging

#log

Instance Method Details

#get_maven_source_jar(project, pom_path) ⇒ Object

attempts to download a project’s sources



11
12
13
14
15
# File 'lib/gjp/source_getter.rb', line 11

def get_maven_source_jar(project, pom_path)
  maven_runner = Gjp::MavenRunner.new(project)
  pom = Pom.new(pom_path)
  maven_runner.get_source_jar(pom.group_id, pom.artifact_id, pom.version)
end

#get_maven_source_jars(project) ⇒ Object

looks for jars in maven’s local repo and downloads corresponding source jars



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/gjp/source_getter.rb', line 19

def get_maven_source_jars(project)
  maven_runner = Gjp::MavenRunner.new(project)

  project.from_directory do
    paths = Find.find(".").reject { |path| artifact_from_path(path).nil? }.sort

    succeded_paths = paths.select.with_index do |path, i|
      group_id, artifact_id, version = artifact_from_path(path)
      log.info("attempting source download for #{path} (#{group_id}:#{artifact_id}:#{version})")
      maven_runner.get_source_jar(group_id, artifact_id, version)
    end

    [succeded_paths, (paths - succeded_paths)]
  end
end