Add rules_license package metadata to nuget archive BUILD files#536
Add rules_license package metadata to nuget archive BUILD files#536nickcollier wants to merge 4 commits intobazel-contrib:masterfrom
Conversation
|
I think this would be a very nice feature to have but I have an issue with the end-user having to add rules_license as a direct dependency for things to work. Ideally rules_license would just come as a transitive dependency and the end-user would not have to worry about it. If you can find a way to achieve this then and also add some tests that verify the outputs then I'm ready to merge this feature. |
|
@purkhusid since the nuget_archive repos are currently created in the context of the end-user workspace they will not be able to directly access the rules_license bazel_dep in rules_dotnet as bzlmod isolates these. I've listed all the options I could think of below. Each one has a link to a proof of concept branch in my fork of rules_dotnet. In these I've got them to the point you can Option 1: Expose rules_license rules/targets from rules_dotnetSimilar to how To expose the license_kind targets that are required you can create an alias to them in a BUILD.bazel file in rules_dotnet. There are many of these under Proof of concept: nickcollier/rules_dotnet@add_rules_license_package_metadata...nickcollier:rules_dotnet:add_rules_license_package_metadata-option1 Option 2: Add module_extension to rules_dotnet so nuget_archive repos are generated in the rules_dotnet contextCurrently paket2bazel generates a module_extension .bzl file however it is placed in the end-user workspace so it does not have access to any bazel_deps rules_dotnet imports. If you exposed a module_extension within rules_dotnet itself then the generated nuget_archive BUILD files would be able to access rules_license directly. The end-user MODULE.bazel would look something like: For this example to work paket2bazel would need to be updated to output the packages list of each group as a JSON file. Option 3: Add global flag to control if rules_license metadata is added is added to nuget_archive reposIn this case the end-user might still have to add a direct dependency on rules_license - but only if they opt-in by enabling the flag to generate rules_license metadata. To configure this globally in a way that is exposed to the nuget_archive repo_rules you can add a The end-user MODULE.bazel would look like The rules dotnet MODULE.bazel would look like Then rules_dotnet .bzl files access the config like this This config module_extension and internal_config_repo rule were inspired by rules_python Option 4: Add flag to paket2bazel to control if rules_license metadata is added to nuget_archive reposIn this case the end-user might still have to add a direct dependency on rules_license - but only if they opt-in by passing the flag to paket2bazel. |
|
@purkhusid any thoughts on which option, if any, you would like me to go with? Personally I think Option 2 is the better long term solution as it would allow the generated BUILD files access to all rules_dotnet bazel_deps if you decided you wanted to use some other external rules/target in the future. |
|
Sorry about the radio silence. Been very busy with other things. I agree that option 2 is the way to go. I want to eventually get rid of the paket2bazel tool and instead use a module extension that can just parse the paket.dependencies/paket.lock file and all repositories are just created within that module extension. The rules_license targets could then just be part of that extension and the end-user would not have to worry about the transitive dependency on rules_license. If you want to take a stab at this then that would be great, I'll try my best to be available for review in a timely manner. |
No description provided.