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?

3

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.

| improve this answer | |
  • 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
  • @Sava if you're happy with this answer, do you want to accept it by clicking the tick outline next to it? That drives our reputation system for both you and the author of the answer, and it puts the question to bed and stops it floating around like some kind of querulous albatross. It might be a good idea to do the same thing for your other question(s) also. – MadHatter Apr 15 at 5:10
  • yes, just did that @MadHatter. I think isolation of code to a separate file followed by the original licence would do the job, however it's not always practical to do it like that. – Sava Apr 15 at 12:04
  • @Sava sorry, are you saying you accepted this answer, or indeed any answer to any of your questions? – MadHatter Apr 15 at 12:59
  • @MadHatter I just realized I need to click the checkmark to accept it :) – Sava Apr 15 at 13:04

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.