Class: Licensed::Sources::Gradle

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

Defined Under Namespace

Classes: Dependency

Constant Summary collapse

DEFAULT_CONFIGURATIONS =
["runtime", "runtimeClasspath"].freeze
GRADLE_LICENSES_PATH =
".gradle-licenses".freeze

Instance Attribute Summary

Attributes inherited from Source

#config

Instance Method Summary collapse

Methods inherited from Source

#dependencies, full_type, #ignored?, inherited, #initialize, type, type_and_version

Constructor Details

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

Instance Method Details

#enabled?Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/licensed/sources/gradle.rb', line 82

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

#enumerate_dependenciesObject



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/licensed/sources/gradle.rb', line 86

def enumerate_dependencies
  JSON.parse(self.class.gradle_command("printDependencies", path: config.pwd, executable: gradle_executable, configurations: configurations)).map do |package|
    name = "#{package["group"]}:#{package["name"]}"
    Dependency.new(
      name: name,
      version: package["version"],
      path: config.pwd,
      executable: gradle_executable,
      configurations: configurations,
      metadata: {
        "type"     => Gradle.type
      }
    )
  end
end