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

Populate dependencies from module graph #109

Merged
merged 5 commits into from
Jan 13, 2025

Conversation

matmannion
Copy link
Contributor

@matmannion matmannion commented Jan 6, 2025

Populates dependencies in the bom output by using the details from the configuration report.

This relies on an sbt.internal class (SbtUpdateReport) which is what is used by the built-in dependency graph/tree plugin; I'm not sure how I feel about that and maybe it'd be better to just re-implement the logic that it uses (https://github.com/sbt/sbt/blob/1.10.x/main/src/main/scala/sbt/internal/graph/backend/SbtUpdateReport.scala) - happy to take views on that.

Dependency has equality based on the ref alone, so calling .distinct on the result from dependenciesForConfiguration is sufficient to ensure that only one ends up in the output.

fixes #88

Copy link
Contributor

@raboof raboof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks for looking into this!

This relies on an sbt.internal class (SbtUpdateReport) which is what is used by the built-in dependency graph/tree plugin; I'm not sure how I feel about that and maybe it'd be better to just re-implement the logic that it uses (https://github.com/sbt/sbt/blob/1.10.x/main/src/main/scala/sbt/internal/graph/backend/SbtUpdateReport.scala) - happy to take views on that.

It looks small enough that re-implementing the logic might be safer - or does it end up 'pulling in' a lot of other internals?

As it makes the generated sbom considerably larger, I think we should make populating the dependencies section optional (default enabled).

.gitignore Show resolved Hide resolved
@@ -89,7 +89,7 @@ executed.
[Scripted](https://www.scala-sbt.org/1.x/docs/Testing-sbt-plugins.html) is a tool that allow you to test sbt plugins.
For each test it is necessary to create a specially crafted project. These projects are inside src/sbt-test directory.

Scripted tests are run using `scripted` command.
Scripted tests are run using `scripted` command. Note that these fail on JDK 21 due to the old version of sbt.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we create an issue for this capturing what exactly is going wrong and what the plan to fix that should be?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there's much we can do about it as it's the version of Scala 2.12 pulled in by sbt, so other than moving to a more recent baseline (which feels like a possibly breaking major change) I thought maybe documenting here for local development was sufficient?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documenting it is a great improvement. I've opened #110 to discuss going further

@matmannion
Copy link
Contributor Author

Awesome, thanks for looking into this!

This relies on an sbt.internal class (SbtUpdateReport) which is what is used by the built-in dependency graph/tree plugin; I'm not sure how I feel about that and maybe it'd be better to just re-implement the logic that it uses (https://github.com/sbt/sbt/blob/1.10.x/main/src/main/scala/sbt/internal/graph/backend/SbtUpdateReport.scala) - happy to take views on that.

It looks small enough that re-implementing the logic might be safer - or does it end up 'pulling in' a lot of other internals?

As it makes the generated sbom considerably larger, I think we should make populating the dependencies section optional (default enabled).

Makes sense - I've done both of these.

Copy link
Contributor

@raboof raboof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! We should research the licensing question before merging, but I don't necessarily want to burden you with that, I can look into it later.

README.md Outdated
| includeBomToolVersion | Boolean | `true` | include tool version in bom |
| includeBomHashes | Boolean | `true` | include artifact hashes in bom |
| enableBomSha3Hashes | Boolean | `true` | enable the generation of sha3 hashes (not available on java 8) |
| includeBomDependencyTree | Boolean | `true` | include dependency tree in bom (bomSchemaVersion 1.1 and later) |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I'm not sure the detail 'bomSchemaVersion 1.1 and later' is needed here, but OK)

src/main/scala/com/github/sbt/sbom/BomExtractor.scala Outdated Show resolved Hide resolved
src/main/scala/com/github/sbt/sbom/BomExtractor.scala Outdated Show resolved Hide resolved
dependency
}

// https://github.com/sbt/sbt/blob/1.10.x/main/src/main/scala/sbt/internal/graph/backend/SbtUpdateReport.scala
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. Sorry to go back-and-forth on this a bit, but I just noticed that this is including Apache-licensed code into an MIT-licensed project. That might be possible (they're both premissively-licensed, after all), but we'd want to double-check that adding this comment is sufficient, or that we'd want to do a bit more to make sure this is responsibly tracked.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense, thank you for checking this as well

@raboof raboof force-pushed the populate-dependencies branch from 0d1696c to 969d7fa Compare January 7, 2025 22:47
raboof added a commit to raboof/sbt-bom that referenced this pull request Jan 7, 2025
In preparation of including a file with Apache-2.0-licensed code from
sbt in sbt#109

https://reuse.software/
@raboof raboof force-pushed the populate-dependencies branch 4 times, most recently from 5ae3656 to 224f7e2 Compare January 7, 2025 23:32
Copy link
Contributor

@raboof raboof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took the liberty of breaking out the sbt code to its own file (so it can have its own license header).

I proposed a general approach to license headers in #111, but I don't think this PR necessarily needs to be blocked on that. So this PR LGTM (thanks!) but I'll give other maintainers some time to chime in before merging.

@matmannion
Copy link
Contributor Author

Thanks so much @raboof, breaking into its own file seems like a pragmatic solution until we can get the SPDX headers in

Copy link
Contributor

@lhns lhns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very good! Thank you!

@raboof raboof changed the title Populate dependencies from module graph, fixes #108 Populate dependencies from module graph Jan 8, 2025
raboof added a commit to raboof/sbt-bom that referenced this pull request Jan 10, 2025
In preparation of including a file with Apache-2.0-licensed code from
sbt in sbt#109

https://reuse.software/
raboof added a commit that referenced this pull request Jan 10, 2025
* Add explicit license headers

In preparation of including a file with Apache-2.0-licensed code from
sbt in #109

https://reuse.software/

* Add reuse check GitHub action
@raboof raboof force-pushed the populate-dependencies branch 3 times, most recently from 1c84bed to e0af721 Compare January 13, 2025 08:35
@raboof raboof force-pushed the populate-dependencies branch from e0af721 to 783b8c4 Compare January 13, 2025 08:38
@raboof raboof force-pushed the populate-dependencies branch from 783b8c4 to d95b03b Compare January 13, 2025 09:01
@raboof raboof merged commit dfce9ff into sbt:main Jan 13, 2025
11 checks passed
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.

record the dependency tree, not just the list
3 participants