Skip to content

Commit

Permalink
[Fixed] Crash when gradle runs with project roots recursive [#169465210]
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Jun <jjun@pivotal.io>
  • Loading branch information
xtreme-shane-lattanzio authored and Pivotal-Jeff-Jun committed Nov 5, 2019
1 parent 9e32228 commit 08e0df8
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/license_finder/package_managers/gradle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,18 @@ def project_root?
private

def root_module?
command = "#{package_management_command} properties | grep 'parent: '"
return false if project_path.to_s.include?('buildSrc')
command = "#{package_management_command} -Dorg.gradle.jvmargs=-Xmx6144m properties | grep 'parent: '"
stdout, stderr, status = Dir.chdir(project_path) { Cmd.run(command) }

if stderr.include?('not part of the build defined by settings file')
Dir.chdir(project_path) do
Cmd.run('touch settings.gradle')
stdout, stderr, status = Cmd.run(command)
Cmd.run('rm settings.gradle')
end
end

raise "Command '#{command}' failed to execute: #{stderr}" unless status.success?

root_project_name = stdout.gsub(/\s|parent:|\n/, '')
Expand Down

0 comments on commit 08e0df8

Please sign in to comment.