1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.jetty.start;
20
21 import java.io.BufferedReader;
22 import java.io.IOException;
23 import java.io.InputStreamReader;
24 import java.util.List;
25 import java.util.Map;
26 import java.util.TreeMap;
27
28
29
30
31 public class Licensing
32 {
33 private static final String PROP_ACK_LICENSES = "org.eclipse.jetty.start.ack.licenses";
34 public Map<String, List<String>> licenseMap = new TreeMap<>(new NaturalSort.Strings());
35
36 public void addModule(Module module)
37 {
38 if (!module.hasLicense())
39 {
40
41 return;
42 }
43
44 if (licenseMap.containsKey(module.getName()))
45 {
46
47 return;
48 }
49
50 licenseMap.put(module.getName(),module.getLicense());
51 }
52
53 public boolean hasLicenses()
54 {
55 return !licenseMap.isEmpty();
56 }
57
58 public boolean acknowledgeLicenses() throws IOException
59 {
60 if (!hasLicenses())
61 {
62 return true;
63 }
64
65 System.err.printf("%nALERT: There are enabled module(s) with licenses.%n");
66 System.err.printf("The following %d module(s):%n", licenseMap.size());
67 System.err.printf(" + contains software not provided by the Eclipse Foundation!%n");
68 System.err.printf(" + contains software not covered by the Eclipse Public License!%n");
69 System.err.printf(" + has not been audited for compliance with its license%n");
70
71 for (String key : licenseMap.keySet())
72 {
73 System.err.printf("%n Module: %s%n",key);
74 for (String line : licenseMap.get(key))
75 {
76 System.err.printf(" + %s%n",line);
77 }
78 }
79
80 boolean licenseAck = false;
81
82 String propBasedAckValue = System.getProperty(PROP_ACK_LICENSES);
83 if (propBasedAckValue != null)
84 {
85 StartLog.log("TESTING MODE","Programmatic ACK - %s=%s",PROP_ACK_LICENSES,propBasedAckValue);
86 licenseAck = Boolean.parseBoolean(propBasedAckValue);
87 }
88 else
89 {
90 if (Boolean.getBoolean("org.eclipse.jetty.start.testing"))
91 {
92 throw new RuntimeException("Test Configuration Missing - Pre-specify answer to (" + PROP_ACK_LICENSES + ") in test case");
93 }
94
95 BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
96 System.err.printf("%nProceed (y/N)? ");
97 String response = input.readLine();
98
99 licenseAck = (Utils.isNotBlank(response) && response.toLowerCase().startsWith("y"));
100 }
101
102 return licenseAck;
103 }
104 }