Class: Gjp::GetSourceCommand

Inherits:
BaseCommand
  • Object
show all
Defined in:
lib/gjp/commands/get_source.rb

Overview

gjp get-source

Instance Method Summary collapse

Methods inherited from BaseCommand

#checking_exceptions, #configure_log_level, #ensure_dry_running, #format_path, #print_generation_result, #verbose=, #very_verbose=, #very_very_verbose=

Methods included from Logging

#log

Instance Method Details

#executeObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/gjp/commands/get_source.rb', line 8

def execute
  checking_exceptions do
    project = Gjp::Project.new(".")
    source_getter = Gjp::SourceGetter.new

    puts "Attempting to find source through Maven..."
    if source_getter.get_maven_source_jar(project, pom)
      puts "Source jar found and added to Maven repository."
    else
      effective_pom_path = Gjp::MavenRunner.new(project).get_effective_pom(pom)
      puts "Source jar not found in Maven. Try looking here:"
      pom = Gjp::Pom.new(effective_pom_path)
      puts "Website: #{pom.url}" unless pom.url.empty?
      puts "SCM connection: #{pom.scm_connection}" unless pom.scm_connection.empty?
      puts "SCM connection: #{pom.scm_url}" unless pom.scm_url.empty?
      puts "The effective POM: #{effective_pom_path}"
      name = !pom.name.empty? ? pom.name : pom.artifact_id
      puts "Google: http://google.com/#q=#{URI.encode("#{name} sources")}"
    end
  end
end