MartinP7r / AckGen

Generate a list of license information for all Swift packages used in your project. For easy *Acknowledgement* views.
MIT License
37 stars 11 forks source link

How to add custom license that cannot be generated? #24

Open alizainc opened 3 weeks ago

alizainc commented 3 weeks ago

AckGen is unable to generate the License details for https://github.com/cozality/Thrift-Swift package. I guess the reason is because it does not have a LICENSE file in it, but rather the license is in readme and in comments of Package.swift. How can I manually add the license details for this package if AckGen cannot pull it from the SPM resolve file.

MartinP7r commented 3 weeks ago

Hello @alizainc! Thank you for reaching out!

You're right. The reason is that the package doesn't contain a LICENSE file at the root.

Aside from the adding the license manually, I would actually recommend that you file an issue or create a PR for that package to add the license file. Btw, I think you linked a fork of Thrift-Swift. The original package seems to be here: https://github.com/apocolipse/Thrift-Swift

There are several method to do it manually, depending on how you use AckGen.

You could

  1. add the information as another entry to the Acknowledgements.plist after it's created by AckGen.

  2. use the otherAcknowledgements parameter of AcknowledgementsList

AcknowledgementsList(
    otherAcknowledgements: [
        .init(
            title: "Thrift-Swift", 
            license: "Licensed to the Apache Software Foundation (ASF) under..."
        )
    ]
)

Please let me know if this doesn't help!

Cheers, Martin

JulesMoorhouse commented 3 weeks ago

To solve this for font awesome, I create my own dummy package and added their policy etc.

alizainc commented 3 weeks ago

Thank you @MartinP7r for the quick response. I have updated our project to use the original package by apocolipse, but it seems like even that package does not have a LICENSE file. I have create an issue to the project to create a LICENSE file, instead of adding the LICENSE in readme.

For the first solution you provided, if I just add another entry in the Acknowledgements.plist wouldn't it be overwritten when we re-run the build for the package? Or will it be able to somehow handle that and keep the extra added entry? Thanks.

MartinP7r commented 3 weeks ago

For the first solution you provided, if I just add another entry in the Acknowledgements.plist wouldn't it be overwritten when we re-run the build for the package? Or will it be able to somehow handle that and keep the extra added entry?

You're right. This would be overwritten every time you run ackgen. For example in your run script, if you followed the normal installation instructions. If you have the plist generated automatically, it would make sense to add other licenses also automatically.

The 2. option (adding an Acknowledgement manually in code is maybe easiest to implement. Especially if you don't have many licenses that need adding manually.

But for completeness, one approach you could take is to have the additional license's information in a separate plist and merge that after running swift run ackgen in your build script (PlistBuddy should be able to do that).

  1. Create a separate plist (e.g. OtherLicense.plist) with the same content format
  2. Add merge command to your run script after swift run ackgen

I haven't tried it myself, but something like below might work (would need to set correct paths)

DIR=$PROJECT_TEMP_DIR/../../../SourcePackages/checkouts/AckGen
if [ -d "$DIR" ]; then
  cd $DIR
  SDKROOT=(xcrun --sdk macosx --show-sdk-path)
  swift run ackgen
  /usr/libexec/PlistBuddy -x -c "Merge /path/to/OtherLicense.plist" /path/to/Acknowledgements.plist
fi