From 9dd0db8eeb5b76b8dd940a15fa6925a38da51138 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Tue, 28 Oct 2014 09:04:25 -0700 Subject: [PATCH] 449001 - Remove start.d directory from JETTY_HOME + Removed start.d from {jetty.home} + Removed most of start.ini content as well + DID NOT remove or alter start.d functionality from start.jar + DID NOT remove or alter demo-base/start.d/ example + Made running jetty from {jetty.home} simply show a warning message + DID NOT remove ability to run jetty from {jetty.home} Just made it a manual process requiring intention on behalf of the user --- jetty-distribution/pom.xml | 16 -------- .../src/main/resources/start.ini | 41 +++++-------------- .../eclipse/jetty/start/BaseHomeWarning.java | 34 +++++++++++++++ .../java/org/eclipse/jetty/start/Main.java | 35 +++++++++------- .../org/eclipse/jetty/start/StartArgs.java | 2 +- .../eclipse/jetty/start/base-home-warning.txt | 15 +++++++ 6 files changed, 81 insertions(+), 62 deletions(-) create mode 100644 jetty-start/src/main/java/org/eclipse/jetty/start/BaseHomeWarning.java create mode 100644 jetty-start/src/main/resources/org/eclipse/jetty/start/base-home-warning.txt diff --git a/jetty-distribution/pom.xml b/jetty-distribution/pom.xml index dfec0abd0ef..184d83d6ee7 100644 --- a/jetty-distribution/pom.xml +++ b/jetty-distribution/pom.xml @@ -558,22 +558,6 @@ org.codehaus.mojo exec-maven-plugin - - setup home - process-classes - - org.eclipse.jetty.start.Main - - jetty.home=${assembly-directory} - jetty.base=${assembly-directory} - --add-to-start=server,deploy,websocket,ext,resources - --add-to-startd=jsp,jstl,http - - - - java - - setup demo-base process-classes diff --git a/jetty-distribution/src/main/resources/start.ini b/jetty-distribution/src/main/resources/start.ini index 59d94becc09..9d0bdc17c9b 100644 --- a/jetty-distribution/src/main/resources/start.ini +++ b/jetty-distribution/src/main/resources/start.ini @@ -1,35 +1,16 @@ #=========================================================== -# Jetty start.jar arguments +# Jetty Home Start INI # -# The contents of this file, together with the *.ini -# files found in start.d directory are used to build -# the classpath and command line on a call to -# java -jar start.jar [arg...] -# -# Use the following command to see more options -# java -jar start.jar --help -# -# Each line in these files is prepended to the command line -# as arguments and may be either: -# + A property like: name=value -# + A module to enable like: --module=jmx -# + An XML configuration file like: etc/jetty-feature.xml -# + A start.jar option like: --dry-run -# -# If --exec or --dry-run are used, then this file may also -# contain lines with: -# + A JVM option like: -Xmx2000m -# + A System Property like: -Dcom.sun.management.jmxremote -# -# The --add-to-start=module option can be used to append -# a configuration template for a module to start.ini -# The --add-to-startd=module option can be used to create -# a configuration template for a module in start.d/module.ini -# For example configure and run with SPDY use -# -# java -jar start.jar --add-to-startd=spdy -# $EDITOR start.d/spdy.ini -# java -jar start.jar +# It is not recommended to run Jetty from {jetty.home} +# +# This configuration simply presents a warning message +# about this recommendation. # +# It is considered an advanced features to run Jetty +# from {jetty.home}. If you are brave enough to do this +# then start with a fresh {jetty.home}/start.ini #=========================================================== +# Show warning message +-Dmain.class=org.eclipse.jetty.start.BaseHomeWarning + diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/BaseHomeWarning.java b/jetty-start/src/main/java/org/eclipse/jetty/start/BaseHomeWarning.java new file mode 100644 index 00000000000..0c4c6b8a311 --- /dev/null +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/BaseHomeWarning.java @@ -0,0 +1,34 @@ +// +// ======================================================================== +// 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; + + +public class BaseHomeWarning +{ + public static void main(String[] args) + { + if(!Main.printTextResource("org/eclipse/jetty/start/base-home-warning.txt")) + { + StartLog.warn("It is not recommended to run Jetty from within {jetty.home}"); + StartLog.warn("Use proper {jetty.base} setup"); + StartLog.warn("See: http://www.eclipse.org/jetty/documentation/current/startup.html"); + } + System.exit(-1); + } +} diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java b/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java index f405ae22ecd..60e827b1b54 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java @@ -880,15 +880,26 @@ public class Main public void usage(boolean exit) { StartLog.endStartLog(); - String usageResource = "org/eclipse/jetty/start/usage.txt"; - boolean usagePresented = false; - try (InputStream usageStream = getClass().getClassLoader().getResourceAsStream(usageResource)) + if(!printTextResource("org/eclipse/jetty/start/usage.txt")) { - if (usageStream != null) + System.err.println("ERROR: detailed usage resource unavailable"); + } + if (exit) + { + System.exit(EXIT_USAGE); + } + } + + public static boolean printTextResource(String resourceName) + { + boolean resourcePrinted = false; + try (InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(resourceName)) + { + if (stream != null) { - try (InputStreamReader reader = new InputStreamReader(usageStream); BufferedReader buf = new BufferedReader(reader)) + try (InputStreamReader reader = new InputStreamReader(stream); BufferedReader buf = new BufferedReader(reader)) { - usagePresented = true; + resourcePrinted = true; String line; while ((line = buf.readLine()) != null) { @@ -898,21 +909,15 @@ public class Main } else { - System.out.println("No usage.txt ??"); + System.out.println("Unable to find resource: " + resourceName); } } catch (IOException e) { StartLog.warn(e); } - if (!usagePresented) - { - System.err.println("ERROR: detailed usage resource unavailable"); - } - if (exit) - { - System.exit(EXIT_USAGE); - } + + return resourcePrinted; } // ------------------------------------------------------------ diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java b/jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java index 4aff293052b..90441420675 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java @@ -573,7 +573,7 @@ public class StartArgs for (String key : systemPropertyKeys) { // ignored keys - if ("jetty.home".equals(key) || "jetty.base".equals(key)) + if ("jetty.home".equals(key) || "jetty.base".equals(key) || "main.class".equals(key)) { // skip continue; diff --git a/jetty-start/src/main/resources/org/eclipse/jetty/start/base-home-warning.txt b/jetty-start/src/main/resources/org/eclipse/jetty/start/base-home-warning.txt new file mode 100644 index 00000000000..c0fa8298ba7 --- /dev/null +++ b/jetty-start/src/main/resources/org/eclipse/jetty/start/base-home-warning.txt @@ -0,0 +1,15 @@ +WARNING +------- + +While it is possible to run Jetty from within {jetty.home}, +it is not recommended that you run Jetty this way. + +Please setup a proper {jetty.base}. + +See http://www.eclipse.org/jetty/documentation/current/startup.html + +The demo-base has been provided to you for an example of this kind of setup. + + $ cd demo-base + $ java -jar ../start.jar +