Sha256: 2be9c010ccefcfb5c4ef981850d7479e716e93d0568449d4ba66dac3df999a84

Contents?: true

Size: 663 Bytes

Versions: 2

Compression:

Stored size: 663 Bytes

Contents

require "xmlsimple"

module LicenseFinder
  class Maven
    def self.current_packages
      `mvn license:download-licenses`

      xml = File.read('target/generated-resources/licenses.xml')

      options = {
        'GroupTags' => { 'licenses' => 'license', 'dependencies' => 'dependency' },
        'ForceArray' => ['license', 'dependency']
      }
      dependencies = XmlSimple.xml_in(xml, options)["dependencies"]

      dependencies.map do |dep|
        MavenPackage.new(dep)
      end
    end

    def self.active?
      File.exists?(package_path)
    end

    private

    def self.package_path
      Pathname.new('pom.xml').expand_path
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
license_finder-1.0.0.0 lib/license_finder/package_managers/maven.rb
license_finder-1.0.0.0-java lib/license_finder/package_managers/maven.rb