-
Notifications
You must be signed in to change notification settings - Fork 127
Fix for issues/533 (dual licensed dependency with one license on whitelist and the other on blacklist) #670
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
Conversation
…hould be sufficient to allow the project, because this is the licence you choose.
|
Hey @slawekjaranowski is something off with my pull request? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes issue #533 by modifying the license validation logic to properly handle dual-licensed dependencies. When a dependency has multiple licenses, the new logic treats it as compliant if at least one of its licenses is whitelisted, even if another license appears on the blacklist.
Key Changes:
- Refactored the
checkForbiddenLicenses()method to store unsafe licenses in aLicenseMapinstead of aSet<String>, enabling project-level tracking - Extracted duplicate whitelist checking logic into a new
isDependencyWhitelisted()helper method - Added comprehensive test coverage for various license validation scenarios including dual-licensed dependencies
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 9 comments.
| File | Description |
|---|---|
| AbstractAddThirdPartyMojo.java | Refactored license checking logic to handle dual-licensed dependencies by tracking projects per license and validating each project individually against whitelist |
| AbstractAddThirdPartyMojoTest.java | Added comprehensive test suite covering whitelist/blacklist scenarios, including edge cases for dual-licensed dependencies |
| pom.xml | Added Mockito 5.20.0 test dependency to support the new test cases |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
src/test/java/org/codehaus/mojo/license/AbstractAddThirdPartyMojoTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/codehaus/mojo/license/AbstractAddThirdPartyMojoTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/codehaus/mojo/license/AbstractAddThirdPartyMojoTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/codehaus/mojo/license/AbstractAddThirdPartyMojoTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/codehaus/mojo/license/AbstractAddThirdPartyMojoTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/codehaus/mojo/license/AbstractAddThirdPartyMojoTest.java
Outdated
Show resolved
Hide resolved
src/main/java/org/codehaus/mojo/license/AbstractAddThirdPartyMojo.java
Outdated
Show resolved
Hide resolved
src/main/java/org/codehaus/mojo/license/AbstractAddThirdPartyMojo.java
Outdated
Show resolved
Hide resolved
src/main/java/org/codehaus/mojo/license/AbstractAddThirdPartyMojo.java
Outdated
Show resolved
Hide resolved
…ojoTest.java fixed spelling Co-authored-by: Copilot <[email protected]>
|
thank you @slawekjaranowski for checking my pull request. I changed Britsh English licence to American English license in both files and downgraded mockito from 5 to 4 to be jdk 8 compatible. |
|
Hello @slawekjaranowski |
I will try to look 😄 |
|
merged with current master in order to run build |
See #533
If a project dependency has multiple licences I can choose the licence I want to use. So only 1 of the licences must be included in the whitelist.