12

I'm using source code from a code example that is licensed under the Apache 2.0 License in my program. Now I would like to publish that program and source code on GitHub using the MIT License. I've read the following in the license:

You must cause any modified files to carry prominent notices stating that You changed the files;

But I didn't change any of the files I just copied the relevant parts of the code into my source files.

Now here are my questions:

I know I have to add a copy of the Apache 2.0 License into my project but do I have to put anything into my source files to correctly publish my program/source code?

As it is a command line program do I have to add a -license switch and display the license or do I have to add it the "USAGE" output?

Do I have to put the MIT License into every of my source files or is it enough to have a copy of it in the project?

Thanks in advance!

7
  • Can you put the parts that you took from the Apache-licensed project in its own file? Then you can include the Apache license terms there. You don't have to add a notice to the "Usage" part of your program.
    – Brandin
    Sep 14, 2015 at 12:02
  • Unfortunately I can't because its basically a client/server thing and it would break the code if I had to.
    – MemphiZ
    Sep 14, 2015 at 12:03
  • I guess you could put at the top of the file an explanation of which parts fall under which licenses. But that's probably going to be confusing. Personally I would look harder into separating that other-license code to another file. This probably comes down to a technical question of how to implement that in the programming langauge you're using. For example if its Python you can easily put that in its own package and then call it from your own code.
    – Brandin
    Sep 14, 2015 at 12:09
  • "But I didn't change any of the files I just copied the relevant parts of the code into my source files." Then you did change it; you removed the parts you didn't need. Therefore you must make it clear that those pieces of code are a modified version of the original code. You should also make it clear that your library is covered by both the MIT and Apache licences.
    – David Arno
    Sep 14, 2015 at 12:46
  • Is there a reason you don't want to use the Apache License for your work? Apache and MIT are functionally nearly the same. (The apache license has some patent right grants that the MIT license is missing). Having a single license will make things much easier for you and any potential users.
    – Craig
    Sep 14, 2015 at 18:53

1 Answer 1

6

As parts of the sources are licensed under one license (Apache 2.0) and parts are under a different license (MIT), it is important that each file carries a notice stating which license applies to the contents of that file.

It is strongly recommended to have only a single license for each source file, so you should have the code that you copied from the third-party library in a separate source file (or multiple separate source files). These files should have a copyright notice referring to the Apache license and state that you copied the code from the third-party library.

For your own code that you want to publish under the MIT license, it is recommended to put the MIT license in its entirety in a comment at the top of your files.
The MIT license isn't that long, and it will avoid all confusion about what license the code is under even if the file gets separated from the rest of the project.


If it is unfeasible to separate the code under the different licenses into separate files, then you could proceed like this (assuming a small portion of a file is under the Apache license):

  • Put your source file under the MIT license
  • Directly below the copyright & license statements, add a comment that parts of the file are under a different license.
  • Immediately above the code that is under the Apache license, add a comment block giving the copyright and license details for the code following it.
    To avoid thoroughly confusing others, this should be done at the granularity of a function.
3
  • What if I can't separate the code under Apache License from the rest because it would completely break the code or make it unreadable?
    – MemphiZ
    Sep 14, 2015 at 12:20
  • 1
    @MemphiZ What programming language is it? Maybe you should post a question on SO. "I have this code here - how can I put it in its own file"
    – Brandin
    Sep 14, 2015 at 12:28
  • @MemphiZ: Added what you can do if you can't separate the functions to different files. Sep 14, 2015 at 13:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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