Skip to content

Commit

Permalink
Merge pull request #890 from jbmgrtn/fix/use_relative_path_to_working…
Browse files Browse the repository at this point in the history
…_directory_for_maven_wrapper_command

[Fixed] Use relative path to working directory for maven wrapper command
  • Loading branch information
xtreme-shane-lattanzio committed Mar 15, 2022
2 parents e2fd289 + 89a9253 commit 298a733
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
8 changes: 2 additions & 6 deletions lib/license_finder/package_managers/maven.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,10 @@ def current_packages
end

def package_management_command
wrapper = if Platform.windows?
'mvnw.cmd'
else
'./mvnw'
end
wrapper = File.join(project_path, Platform.windows? ? 'mvnw.cmd' : 'mvnw')
maven = 'mvn'

File.exist?(File.join(project_path, wrapper)) ? wrapper : maven
File.exist?(wrapper) ? wrapper : maven
end

def possible_package_paths
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/license_finder/package_managers/maven_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ def stub_license_report(deps)

it 'uses the maven wrapper, if present' do
subject = Maven.new(project_path: Pathname('features/fixtures/maven-wrapper'))
allow(SharedHelpers::Cmd).to receive(:run).with('./mvnw org.codehaus.mojo:license-maven-plugin:download-licenses').and_return(['', '', cmd_success])
allow(SharedHelpers::Cmd).to receive(:run).with('features/fixtures/maven-wrapper/mvnw org.codehaus.mojo:license-maven-plugin:download-licenses').and_return(['', '', cmd_success])
expect(Dir).to receive(:chdir).with(Pathname('features/fixtures/maven-wrapper')).and_call_original
expect(subject.package_management_command).to eq('./mvnw').or eq('mvnw.cmd')
expect(subject.package_management_command).to eq('features/fixtures/maven-wrapper/mvnw').or eq('features/fixtures/maven-wrapper/mvnw.cmd')
subject.current_packages
end

Expand Down

0 comments on commit 298a733

Please sign in to comment.