Class: Licensed::Sources::Gradle

Inherits:
Source
  • Object
show all
Defined in:
lib/licensed/sources/gradle.rb

Defined Under Namespace

Classes: Dependency, Runner

Constant Summary collapse

DEFAULT_CONFIGURATIONS =
["runtimeOnly", "runtimeClasspath"].freeze
GRADLE_LICENSES_PATH =
".gradle-licenses".freeze
GRADLE_LICENSES_CSV_NAME =
"licenses.csv".freeze

Instance Attribute Summary

Attributes inherited from Source

#config

Instance Method Summary collapse

Methods inherited from Source

#dependencies, full_type, #ignored?, inherited, #initialize, register_source, require_matched_dependency_version, #source_config, type, type_and_version

Constructor Details

This class inherits a constructor from Licensed::Sources::Source

Instance Method Details

#enabled?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/licensed/sources/gradle.rb', line 44

def enabled?
  !executable.to_s.empty? && File.exist?(config.pwd.join("build.gradle"))
end

#enumerate_dependenciesObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/licensed/sources/gradle.rb', line 48

def enumerate_dependencies
  JSON.parse(gradle_runner.run("printDependencies")).map do |package|
    name = "#{package['group']}:#{package['name']}"
    Dependency.new(
      name: name,
      version: package["version"],
      path: config.pwd,
      url: package_url(name: name, version: package["version"]),
      metadata: {
        "type" => Gradle.type,
      }
    )
  end
end