THINK FIRST·CODE LATER

← All labs

Licence compatibility checker

Problem

Check StudyBuddy's dependencies against its distribution mode and project licence using these simplified rules (not legal advice):

  • Licence families: MIT, BSD, APACHE2 → permissive; LGPL, MPL2 → weak; GPL2, GPL3 → strong; AGPL3 → network; NONE → no licence.
  • Project licence: PROPRIETARY, APACHE2, GPL3. Mode: DISTRIBUTED (app/download) or SERVICE (runs only on our server).

Rules for each dependency, checked in this order:

  1. NONE → BLOCK (no licence: no permission).
  2. AGPL3: if the project licence is GPL3 → OK (offer source to network users); otherwise → BLOCK (AGPL3 requires offering source) — in both modes.
  3. GPL2 or GPL3 in mode SERVICE → OK (not distributed).
  4. GPL2/GPL3 in mode DISTRIBUTED: allowed only if the project is GPL3 and the dependency is GPL3 → OK (same licence); project GPL3 with GPL2 → BLOCK (GPL2-only is incompatible with GPL3); otherwise → BLOCK (strong copyleft in distributed non-GPL work).
  5. APACHE2 when the project is GPL3 → OK (compatible with GPL3; keep NOTICE).
  6. Weak copyleft → OK (keep library changes under its licence).
  7. Other permissive → OK (keep notices).

Input: first line projectLicence mode, then lines dependency licence. Output dependency (LICENCE): RESULT per line, then Blocked: b and Verdict: SHIP if b = 0, otherwise Verdict: DO NOT SHIP.

Input:

PROPRIETARY DISTRIBUTED
gson APACHE2
charts GPL3
utils NONE
pdfkit MPL2

Output:

gson (APACHE2): OK (keep notices)
charts (GPL3): BLOCK (strong copyleft in distributed non-GPL work)
utils (NONE): BLOCK (no licence: no permission)
pdfkit (MPL2): OK (keep library changes under its licence)
Blocked: 2
Verdict: DO NOT SHIP

Data for this lab

Your program reads its data from standard input. Download the file, then give it to your program as shown below. Start with data set 1: its expected output is given.

s12-1-data-1.txt

PROPRIETARY DISTRIBUTED
gson APACHE2
charts GPL3
utils NONE
pdfkit MPL2
What your program must print for s12-1-data-1.txt
gson (APACHE2): OK (keep notices)
charts (GPL3): BLOCK (strong copyleft in distributed non-GPL work)
utils (NONE): BLOCK (no licence: no permission)
pdfkit (MPL2): OK (keep library changes under its licence)
Blocked: 2
Verdict: DO NOT SHIP

Run your program first, then open this and compare line by line: your output must contain these lines exactly.

How to give the file to my program

Terminal (macOS, Linux, or Windows Command Prompt), after compiling:

java Main < s12-1-data-1.txt

Windows PowerShell does not understand <:

Get-Content s12-1-data-1.txt | java Main

IntelliJ IDEA: Run → Edit Configurations → Redirect input from. Or simply paste the content of the file into the console when the program waits for input.

Write it here or in your IDE, then paste it. Compile and test it yourself before comparing. Your code stays in your browser — it is never sent to or stored on the server.