def collect_transitive_dependency_licenses_for(software)
      # We collect the licenses of the transitive dependencies of this software
      # with LicenseScout. We place these files under
      # /opt/project-name/license-cache for them to be cached in git_cache. Once
      # the build completes we will process these license files but we need to
      # perform this step after build, before git_cache to be able to operate
      # correctly with the git_cache.

      collector = LicenseScout::Collector.new(
        software.name,
        software.project_dir,
        license_output_dir(software),
        LicenseScout::Options.new(
          environment: software.with_embedded_path,
          ruby_bin: software.embedded_bin("ruby"),
          manual_licenses: software.dependency_licenses
        )
      )

      begin
        # We do not automatically collect dependency licensing information when
        # skip_transitive_dependency_licensing is set on the software.
        collector.run
      rescue LicenseScout::Exceptions::UnsupportedProjectType => e
        # Looks like this project is not supported by LicenseScout. Either the
        # language and the dependency manager used by the project is not
        # supported, or the software definition does not have any transitive
        # dependencies.  In the latter case software definition should set
        # 'skip_transitive_dependency_licensing' to 'true' to correct this
        # error.
        transitive_dependency_licensing_warning(<<-EOH)
Software '#{software.name}' is not supported project type for transitive \
dependency license collection. See https://github.com/chef/license_scout for \
the list of supported languages and dependency managers. If this project does \
not have any transitive dependencies, consider setting \
'skip_transitive_dependency_licensing' to 'true' in order to correct this error.
EOH
        # If we got here, we need to fail now so we don't take a git
        # cache snapshot, or else the software build could be restored
        # from cache without fixing the license issue.
        raise_if_warnings_fatal!
      rescue LicenseScout::Exceptions::Error => e
        transitive_dependency_licensing_warning(<<-EOH)
Can not automatically detect licensing information for '#{software.name}' using \
license_scout. Error is: '#{e}'
EOH
        # If we got here, we need to fail now so we don't take a git
        # cache snapshot, or else the software build could be restored
        # from cache without fixing the license issue.
        raise_if_warnings_fatal!
      rescue Exception => e
        # This catch all exception handling is here in order not to fail builds
        # until license_scout gets more stable. As we are adding support for more
        # and more dependency managers we discover unhandled edge cases which
        # requires us to have this. Remove this once license_scout is stable.
        transitive_dependency_licensing_warning(<<-EOH)
Unexpected error while running license_scout for '#{software.name}': '#{e}'
EOH
        # If we got here, we need to fail now so we don't take a git
        # cache snapshot, or else the software build could be restored
        # from cache without fixing the license issue.
        raise_if_warnings_fatal!
      end
    end
def collect_transitive_dependency_licenses_for(software)
      # We collect the licenses of the transitive dependencies of this software
      # with LicenseScout. We place these files under
      # /opt/project-name/license-cache for them to be cached in git_cache. Once
      # the build completes we will process these license files but we need to
      # perform this step after build, before git_cache to be able to operate
      # correctly with the git_cache.

      collector = LicenseScout::Collector.new(
        software.name,
        software.project_dir,
        license_output_dir(software),
        LicenseScout::Options.new(
          environment: software.with_embedded_path,
          ruby_bin: software.embedded_bin("ruby"),
          manual_licenses: software.dependency_licenses
        )
      )

      begin
        # We do not automatically collect dependency licensing information when
        # skip_transitive_dependency_licensing is set on the software.
        collector.run
      rescue LicenseScout::Exceptions::UnsupportedProjectType => e
        # Looks like this project is not supported by LicenseScout. Either the
        # language and the dependency manager used by the project is not
        # supported, or the software definition does not have any transitive
        # dependencies.  In the latter case software definition should set
        # 'skip_transitive_dependency_licensing' to 'true' to correct this
        # error.
        transitive_dependency_licensing_warning(<<-EOH)
Software '#{software.name}' is not supported project type for transitive \
dependency license collection. See https://github.com/chef/license_scout for \
the list of supported languages and dependency managers. If this project does \
not have any transitive dependencies, consider setting \
'skip_transitive_dependency_licensing' to 'true' in order to correct this error.
EOH
        # If we got here, we need to fail now so we don't take a git
        # cache snapshot, or else the software build could be restored
        # from cache without fixing the license issue.
        raise_if_warnings_fatal!
      rescue LicenseScout::Exceptions::Error => e
        transitive_dependency_licensing_warning(<<-EOH)
Can not automatically detect licensing information for '#{software.name}' using \
license_scout. Error is: '#{e}'
EOH
        # If we got here, we need to fail now so we don't take a git
        # cache snapshot, or else the software build could be restored
        # from cache without fixing the license issue.
        raise_if_warnings_fatal!
      rescue Exception => e
        # This catch all exception handling is here in order not to fail builds
        # until license_scout gets more stable. As we are adding support for more
        # and more dependency managers we discover unhandled edge cases which
        # requires us to have this. Remove this once license_scout is stable.
        transitive_dependency_licensing_warning(<<-EOH)
Unexpected error while running license_scout for '#{software.name}': '#{e}'
EOH
        # If we got here, we need to fail now so we don't take a git
        # cache snapshot, or else the software build could be restored
        # from cache without fixing the license issue.
        raise_if_warnings_fatal!
      end
    end
Uses license_scout to collect the licenses for transitive dependencies
 into #{output_dir}/license-cache/#{software.name}