Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to detect Maven when using Maven Wrapper with aggregate paths on a Maven project in a subdirectory #889

Closed
jbmgrtn opened this issue Mar 9, 2022 · 2 comments · Fixed by #890
Labels

Comments

@jbmgrtn
Copy link
Contributor

jbmgrtn commented Mar 9, 2022

We are currently evaluating License Finder at work and we are facing an issue with Maven project in a subdirectory when scanning multiple projects using the --aggregate_paths option.

To simply and quickly evaluate License Finder, we are using the Docker image in interactive mode (docker run -v $PWD:/scan -it licensefinder/license_finder).

In our case we have a mono repository that is organized this way (simplified/redacted view):

project/
├── backend
│   ├── mvnw
│   ├── mvnw.cmd
│   └── pom.xml
├── frontend
│   └── package.json
└── package.json

The project directory is mounted at the path /scan and we run License Finder with /LicenseFinder/bin/license_finder report --aggregate_paths='.' './frontend/' './backend/'

Scanning NPM projects located at . and ./frontend/ works fine.

But scanning the Maven project (with submodules) located at ./backend/ fails with the following:

LicenseFinder::Maven: is active
LicenseFinder::Maven: is not installed

This is because it is not able to find the ./mvnw command from the root directory of the project. Indeed that file is located in the backend directory.

In PackageManager it checks that a command exists:

    def command_exists?(command)
      _stdout, _stderr, status =
        if LicenseFinder::Platform.windows?
          Cmd.run("where #{command}")
        else
          Cmd.run("which #{command}")
        end

      status.success?
    end

And in Maven the command is defined as:

    def package_management_command
      wrapper = if Platform.windows?
                  'mvnw.cmd'
                else
                  './mvnw'
                end
      maven = 'mvn'

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

In the case of Maven Wrapper the path to the command should not be relative (./mvnw) but absolute w.r.t project_path.

We tested with the following and it works as expected:

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

      File.exist?(wrapper) ? wrapper : maven
    end

We will shortly create a PR to fix that issue.

@cf-gitbot
Copy link
Collaborator

We have created an issue in Pivotal Tracker to manage this. Unfortunately, the Pivotal Tracker project is private so you may be unable to view the contents of the story.

The labels on this github issue will be updated when the story is started.

@jbmgrtn
Copy link
Contributor Author

jbmgrtn commented Mar 9, 2022

In the case of Maven Wrapper the path to the command should not be relative to project_path (i.e. ./mvnw) but relative to working directory (as in $PWD) (e.g. backend/mvnw).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants