11

JUnit is licenced under Eclipse Public Licence which, according to Wikipedia, is incompatible with GPL. So does this mean if you’re working on a project licenced with GPL you can’t use JUnit? It's too bad as JUnit is quite common.

5

At a high level, this question is about how licensing flows between pieces of code.

Let's assume here a grossly simplified view that calling GPL-licensed code means that the copyleft applies to the calling code. (Things are much more nuanced in practice.)

Case 1. Non-GPL-licensed code calling GPL-licensed code

Under my simplifying assumption, calling GPL-licensed code could only be done from code that is under the GPL or a GPL-compatible license. Think of it as if the license terms flow backwards from the called code to the calling code.

Case 2. GPL-licensed code calling non-GPL-licensed code

Technically you cannot/should not make your GPL-licensed code depend on code that is not under the GPL or a GPL-compatible license.

But details matter.

Say you are creating a piece of GPL-licensed software designed to run on a proprietary OS and calling its proprietary API such as Windows. Can you do this? I think yes: generally speaking what is infrastructure and OS code does not have to be GPL-licensed. There are specific terms in the GPL about this as these are considered system libraries.

Say your GPL code calls OpenSSL? can you do this? The OpenSSL/SSLEay license is explicitly saying no. See at the bottom of this license text.

The licence and distribution terms for any publically available version or derivative of this code cannot be changed. i.e. this code cannot simply be copied and put under another distribution licence including the GNU Public Licence.

(note the typo "publically" is in the original license text)

So what GPL projects that are using OpenSSL do typically is to release their code with an exception to the GPL allowing the use of OpenSSL.

Now let's get back to your actual question

Can GPL-licensed code call the EPL-licensed JUnit library? The case 2. applies and this very similar to using OpenSSL. Therefore technically, you could/should not apply the bare GPL to your test code. And you should provide your test code calling JUnit under the GPL with some exception in the same way GPL-licensed code using OpenSSL typically uses such an exception.

Now practically (unless you are building a test framework based on JUnit) none may really cares about the licensing of your test code: JUnit is open source and may not be GPL-compatible. Its license requirements do not flow backward. So every GPL project that may call JUnit does that without much ceremony even if technically they should.

For reference you can also check these entries in the GPL FAQ:

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.