4

Let's say I have an open source project (Apache2)

And I only take one function from another project which is also open sourced under MIT/Apache2 license, and put it together with my code in a single file.

Where do I put original license from the function author?

How to attribute author for just that one single function?

2

For clarity, it is easiest if you can put the third-party source code in a separate source file. Then you can put the copyright and license notices without any issue at the normal place (the top) in the file.

If you can't use a separate source file and both projects use the same license (or the third party code uses a dual license with the license of your project among the choices), then you should add the copyright of the third party code next to your copyright. You don't have to copy over the license, because that should match the already existing license statement for your own code.

I once had a situation where I included third-party code with a different license into a source file, and I solved that by stating at the top of the file (next to the copyright/license applying to the bulk of the file) that some functions are subject to a different license. Then, in a comment block directly next to the relevant functions, I included the license that applied to that function.

  • Yes that makes sense. I think that the cleanest approach would be isolating those functions in a separate file when possible. – Sava Jan 25 at 13:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.