Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoakim Erdfelt2014-11-17 20:20:12 +0000
committerJoakim Erdfelt2014-11-17 20:20:12 +0000
commit61e480c2c1f38e3eb0ba5a876933618ed4188f22 (patch)
tree7947e876e51f9aa635eac1f76ee38bd3bff830cc /jetty-start
parent453ab6d5c7852c73dc7cf107ea79902a43445c77 (diff)
downloadorg.eclipse.jetty.project-61e480c2c1f38e3eb0ba5a876933618ed4188f22.tar.gz
org.eclipse.jetty.project-61e480c2c1f38e3eb0ba5a876933618ed4188f22.tar.xz
org.eclipse.jetty.project-61e480c2c1f38e3eb0ba5a876933618ed4188f22.zip
451974 - Combine multiple start license acknowledgement into one
+ Initial work to combine licensing into a single event Depends on work from bug #451973
Diffstat (limited to 'jetty-start')
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/Licensing.java104
-rw-r--r--jetty-start/src/test/java/org/eclipse/jetty/start/LicensingTest.java (renamed from jetty-start/src/test/java/org/eclipse/jetty/start/LicenseTest.java)10
2 files changed, 109 insertions, 5 deletions
diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/Licensing.java b/jetty-start/src/main/java/org/eclipse/jetty/start/Licensing.java
new file mode 100644
index 0000000000..c9ca0de988
--- /dev/null
+++ b/jetty-start/src/main/java/org/eclipse/jetty/start/Licensing.java
@@ -0,0 +1,104 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+//
+
+package org.eclipse.jetty.start;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ * Handles basic license presentation and acknowledgement.
+ */
+public class Licensing
+{
+ private static final String PROP_ACK_LICENSES = "org.eclipse.jetty.start.ack.licenses";
+ public Map<String, List<String>> licenseMap = new TreeMap<>(new NaturalSort.Strings());
+
+ public void addModule(Module module)
+ {
+ if (!module.hasLicense())
+ {
+ // skip, no license
+ return;
+ }
+
+ if (licenseMap.containsKey(module.getName()))
+ {
+ // skip, already being tracked
+ return;
+ }
+
+ licenseMap.put(module.getName(),module.getLicense());
+ }
+
+ public boolean hasLicenses()
+ {
+ return !licenseMap.isEmpty();
+ }
+
+ public boolean acknowledgeLicenses() throws IOException
+ {
+ if (!hasLicenses())
+ {
+ return true;
+ }
+
+ System.err.printf("%nALERT: There are enabled module(s) with licenses.%n");
+ System.err.printf("The following %d module(s):%n", licenseMap.size());
+ System.err.printf(" + contains software not provided by the Eclipse Foundation!%n");
+ System.err.printf(" + contains software not covered by the Eclipse Public License!%n");
+ System.err.printf(" + has not been audited for compliance with its license%n");
+
+ for (String key : licenseMap.keySet())
+ {
+ System.err.printf("%n Module: %s%n",key);
+ for (String line : licenseMap.get(key))
+ {
+ System.err.printf(" + %s%n",line);
+ }
+ }
+
+ boolean licenseAck = false;
+
+ String propBasedAckValue = System.getProperty(PROP_ACK_LICENSES);
+ if (propBasedAckValue != null)
+ {
+ StartLog.log("TESTING MODE","Programmatic ACK - %s=%s",PROP_ACK_LICENSES,propBasedAckValue);
+ licenseAck = Boolean.parseBoolean(propBasedAckValue);
+ }
+ else
+ {
+ if (Boolean.getBoolean("org.eclipse.jetty.start.testing"))
+ {
+ throw new RuntimeException("Test Configuration Missing - Pre-specify answer to (" + PROP_ACK_LICENSES + ") in test case");
+ }
+
+ BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
+ System.err.printf("%nProceed (y/N)? ");
+ String response = input.readLine();
+
+ licenseAck = (Utils.isNotBlank(response) && response.toLowerCase().startsWith("y"));
+ }
+
+ return licenseAck;
+ }
+}
diff --git a/jetty-start/src/test/java/org/eclipse/jetty/start/LicenseTest.java b/jetty-start/src/test/java/org/eclipse/jetty/start/LicensingTest.java
index a7a7ebdd9f..a2b6fc45e2 100644
--- a/jetty-start/src/test/java/org/eclipse/jetty/start/LicenseTest.java
+++ b/jetty-start/src/test/java/org/eclipse/jetty/start/LicensingTest.java
@@ -38,7 +38,7 @@ import org.junit.Test;
/**
* Test various license handling.
*/
-public class LicenseTest
+public class LicensingTest
{
@Rule
public TestingDir testdir = new TestingDir();
@@ -93,7 +93,7 @@ public class LicenseTest
List<String> cmds = getBaseCommandLine(basePath);
- cmds.add("-Dorg.eclipse.jetty.start.ack.license.cdi=true");
+ cmds.add("-Dorg.eclipse.jetty.start.ack.licenses=true");
cmds.add("--add-to-start=cdi");
execMain(cmds);
@@ -106,7 +106,7 @@ public class LicenseTest
List<String> cmds = getBaseCommandLine(basePath);
- cmds.add("-Dorg.eclipse.jetty.start.ack.license.protonego-impl=true");
+ cmds.add("-Dorg.eclipse.jetty.start.ack.licenses=true");
cmds.add("--add-to-start=spdy");
execMain(cmds);
@@ -122,7 +122,7 @@ public class LicenseTest
List<String> cmds = getBaseCommandLine(basePath);
- cmds.add("-Dorg.eclipse.jetty.start.ack.license.protonego-impl=true");
+ cmds.add("-Dorg.eclipse.jetty.start.ack.licenses=true");
cmds.add("--dry-run");
StringReader startIni = new StringReader("--module=spdy\n");
@@ -141,7 +141,7 @@ public class LicenseTest
List<String> cmds = getBaseCommandLine(basePath);
- cmds.add("-Dorg.eclipse.jetty.start.ack.license.cdi=true");
+ cmds.add("-Dorg.eclipse.jetty.start.ack.licenses=true");
cmds.add("--create-files");
StringReader startIni = new StringReader("--module=cdi\n");

Back to the top