Skip to content

feat(scanner): Store detected and effective license in database#4791

Closed
Joelp03 wants to merge 2 commits intoeclipse-apoapsis:mainfrom
Joelp03:feat/store-license
Closed

feat(scanner): Store detected and effective license in database#4791
Joelp03 wants to merge 2 commits intoeclipse-apoapsis:mainfrom
Joelp03:feat/store-license

Conversation

@Joelp03
Copy link
Copy Markdown
Contributor

@Joelp03 Joelp03 commented Apr 2, 2026

Hi there.
This implementation resolves the issue of storing detected and effective licenses for packages and projects in the database during the scanning process, making them readily available for API routes without needing to iterate through all scan results.

Resolve #4607

@mnonnenmacher
Copy link
Copy Markdown
Contributor

@Joelp03 Thank you for the contribution!

I don't have time to review this now and I won't be available for review for the next week, so some hints for anyone who picks up the review:

  • Make sure that package curations and package configurations are applied before storing the licenses, otherwise wrong data could be shown.
  • I think we should store the concluded license as well to have the full picture. Could be done separately, but this would also be a chance to do all of them together.
  • Filtering by license will be important for the UI, this should be considered when designing the storage model.

Etsija

This comment was marked as resolved.

@Joelp03 Joelp03 force-pushed the feat/store-license branch 3 times, most recently from aca98ee to f66517c Compare April 10, 2026 15:08
@Joelp03

This comment was marked as resolved.

@Etsija
Copy link
Copy Markdown
Contributor

Etsija commented Apr 14, 2026

Thanks @Etsija I’ve reverted the merge and rebased the branch. I’m standing by for any further changes or feedback.

For starters, you should run ./gradlew detekt detektMain detektTest to fix all linting issues, as the action is failing. Then, I believe it would be needed to address the points @mnonnenmacher is giving in his comment.

@sschuberth
Copy link
Copy Markdown
Contributor

you should run ./gradlew detekt detektMain detektTest

FYI, we have the ./gradlew detektAll shorthand for that.

@Etsija

This comment was marked as off-topic.

@sschuberth

This comment was marked as off-topic.

@Etsija

This comment was marked as off-topic.

@Joelp03

This comment was marked as resolved.

@sschuberth

This comment was marked as resolved.

@Joelp03 Joelp03 force-pushed the feat/store-license branch from e250b1a to d77894a Compare April 14, 2026 16:30
@Joelp03

This comment was marked as resolved.

@sschuberth sschuberth dismissed Etsija’s stale review April 15, 2026 16:45

The merge commit was removed.

Comment thread dao/src/main/kotlin/queries/analyzer/GetPackagesForAnalyzerRunQuery.kt Outdated
Comment thread dao/src/main/kotlin/queries/analyzer/GetProjectsForAnalyzerRunQuery.kt Outdated
Comment thread dao/src/main/kotlin/repositories/analyzerrun/PackagesTable.kt Outdated
Comment thread dao/src/main/kotlin/repositories/analyzerrun/ProjectsTable.kt Outdated
@Joelp03 Joelp03 force-pushed the feat/store-license branch from d77894a to e8fb184 Compare April 17, 2026 13:49
@sschuberth
Copy link
Copy Markdown
Contributor

  • Make sure that package curations and package configurations are applied before storing the licenses, otherwise wrong data could be shown.

@Joelp03, can you confirm that esp. this first point from @mnonnenmacher has been addressed?

@Joelp03
Copy link
Copy Markdown
Contributor Author

Joelp03 commented Apr 20, 2026

  • Make sure that package curations and package configurations are applied before storing the licenses, otherwise wrong data could be shown.

@Joelp03, can you confirm that esp. this first point from @mnonnenmacher has been addressed?

It is not yet implemented. This latest commit contains the implementation.

@Joelp03 Joelp03 marked this pull request as draft April 20, 2026 19:03
Store detected licenses and effective license for packages and projects
during the scanner phase to make them easily available via API routes
without having to traverse all license findings from scan results.

- Add detectedLicenses and effectiveLicense columns to packages and
  projects tables (Flyway V139 migration)
- Add fields to Package and Project models
- Add DAO support for new columns with comma-separated serialization
- Create LicenseComputation.kt with functions to compute licenses
- Integrate license computation in ScannerWorker
- Expose new fields in API v1 Package and Project responses
- Add unit tests for DAO and LicenseComputation

Signed-off-by: Joel Pimentel <joelpimentel1995@gmail.com>

Resolves eclipse-apoapsis#4607.
@Joelp03 Joelp03 force-pushed the feat/store-license branch 2 times, most recently from 511cc09 to d9cb2e5 Compare April 20, 2026 19:07
Detected licenses must have PackageCuration and
PackageConfiguration applied before storing, otherwise
wrong data could be shown.

- Change computeDetectedLicenses to use LicenseInfoResolver
  which applies LicenseFindingCuration and PathExclude from
  PackageConfiguration
- Remove scannerRun parameter from computeAndStoreLicenses
  since it's no longer needed after using LicenseInfoResolver

Signed-off-by: Joelp03 <joelpimentel1995@gmail.com>
@Joelp03 Joelp03 force-pushed the feat/store-license branch from d9cb2e5 to ed6934c Compare April 20, 2026 19:13
@Joelp03 Joelp03 marked this pull request as ready for review April 20, 2026 19:47
@Joelp03
Copy link
Copy Markdown
Contributor Author

Joelp03 commented Apr 20, 2026

I would appreciate a thorough review of this request to ensure it fully aligns with the project's requirements and standards. Please let me know if any adjustments

@Etsija
Copy link
Copy Markdown
Contributor

Etsija commented Apr 21, 2026

Some comments:

  1. Commit structure

See Contributing Guide / Atomic Commits: each commit should be atomic and buildable. The first commit is pretty hard to follow, as it touches four software layers (model, DAO, workers, API) in a single commit.

I would consider splitting the commit into smaller, more manageable and reviewable commits with their respective tests, and making sure each commit builds and tests pass. However I will not block this PR because it, as other reviewers may have easier time reading it than me as a non-back-end guy.

  1. API layer

Do I understand correctly that no API endpoints are affected yet, ie. no detected/effective license data can yet be retrieved from packages/projects endpoints? I am asking because if the data is already available and meant to be provided by the API in this PR and not a follow-up, the PR should probably also touch routes and apiDocs for the corresponding endpoints. But if not, maybe just make it clear that the API changes will come in a follow-up.

  1. Some code smell issues

There's a lot of splitting by ",", then joining by "," in the code, which to me is a bit suspicious.

@oheger-bosch
Copy link
Copy Markdown
Contributor

Similar to point 3 from @Etsija : Wouldn't it be preferable to have a normalized data model for the detected licenses, i.e., storing them in a separate table and having a relation to the packages and projects tables? Just asking.

@Etsija
Copy link
Copy Markdown
Contributor

Etsija commented Apr 21, 2026

Similar to point 3 from @Etsija : Wouldn't it be preferable to have a normalized data model for the detected licenses, i.e., storing them in a separate table and having a relation to the packages and projects tables? Just asking.

True, and as I am not exactly loving the fact that my license-findings service currently needs something like a 10-way join to fetch detected licenses of a package found from an ORT run, it could potentially be greatly simplified with your suggestion.

@Joelp03 Joelp03 marked this pull request as draft April 21, 2026 13:02
@Joelp03 Joelp03 closed this Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Store the detected and effective license of projects and packages

5 participants