From af5f9382a4f063f36c0fdc95121bfb597a91a4c9 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Tue, 28 Oct 2014 10:28:17 -0700 Subject: [PATCH] 449001 - Remove start.d directory from JETTY_HOME + Reworking warning to be optional but still start Jetty also. + Leaving start.d out of {jetty.home} still. --- jetty-distribution/pom.xml | 15 ++++++++++ .../src/main/resources/start.ini | 29 ++++++++++++------- .../eclipse/jetty/start/BaseHomeWarning.java | 29 +++++++++++++++---- .../java/org/eclipse/jetty/start/Main.java | 6 ++++ .../org/eclipse/jetty/start/StartArgs.java | 5 ++++ .../eclipse/jetty/start/base-home-warning.txt | 19 ++++++------ 6 files changed, 77 insertions(+), 26 deletions(-) diff --git a/jetty-distribution/pom.xml b/jetty-distribution/pom.xml index 084ca87ba49..f2a3612bd1b 100644 --- a/jetty-distribution/pom.xml +++ b/jetty-distribution/pom.xml @@ -558,6 +558,21 @@ 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,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 9d0bdc17c9b..81f0f0656e9 100644 --- a/jetty-distribution/src/main/resources/start.ini +++ b/jetty-distribution/src/main/resources/start.ini @@ -1,16 +1,23 @@ #=========================================================== -# Jetty Home Start INI +# NOTE: Jetty is starting using LEGACY behavior # -# It is not recommended to run Jetty from {jetty.home} -# -# This configuration simply presents a warning message -# about this recommendation. +# Starting Jetty from this {jetty.home} is LEGACY behavior. +# +# A proper {jetty.base} should be configured with no changes +# being made to this {jetty.home}. +# +# http://www.eclipse.org/jetty/documentation/current/startup.html +# +# A demo-base directory has been provided as an example of +# this setup. +# +# $ cd demo-base +# $ java -jar ../start.jar +# +# This {jetty.home}/start.ini has been provided to duplicate +# historical default jetty-distribution settings. # -# 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 - +# To disable the warning message, uncomment the following line +# -Dorg.eclipse.jetty.start.home.warning=false 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 index 0c4c6b8a311..bd1fc70561d 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/BaseHomeWarning.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/BaseHomeWarning.java @@ -18,17 +18,34 @@ package org.eclipse.jetty.start; +import java.util.concurrent.TimeUnit; + +import org.eclipse.jetty.start.Props.Prop; public class BaseHomeWarning { - public static void main(String[] args) + public static void show(Props props) { - if(!Main.printTextResource("org/eclipse/jetty/start/base-home-warning.txt")) + Prop showWarn = props.getProp("org.eclipse.jetty.start.home.warning",true); + if (showWarn == null || Boolean.parseBoolean(showWarn.value)) { - 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"); + 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 a proper {jetty.base} setup"); + StartLog.warn("See: http://www.eclipse.org/jetty/documentation/current/startup.html"); + } + + try + { + System.err.print("Your startup will proceed shortly ..."); + TimeUnit.SECONDS.sleep(2); + System.err.println(); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } } - 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 65c5a29bfe5..ba0e2aa681d 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 @@ -779,6 +779,12 @@ public class Main { return; } + + // Warning Message + if (!baseHome.isBaseDifferent() && args.isNormalMainClass()) + { + BaseHomeWarning.show(args.getProperties()); + } // execute Jetty in another JVM if (args.isExec()) 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 ecca0a6afbd..74659fb941b 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 @@ -603,6 +603,11 @@ public class StartArgs { return exec; } + + public boolean isNormalMainClass() + { + return SERVER_MAIN.equals(getMainClassname()); + } public boolean isHelp() { 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 index c0fa8298ba7..a34bfdba7e3 100644 --- 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 @@ -1,15 +1,16 @@ -WARNING -------- +============================================================================ +WARNING: Jetty is starting using LEGACY behavior. -While it is possible to run Jetty from within {jetty.home}, -it is not recommended that you run Jetty this way. +A proper {jetty.base} should be configured with no changes being made to the {jetty.home} directory. -Please setup a proper {jetty.base}. +Please see http://www.eclipse.org/jetty/documentation/current/startup.html -See http://www.eclipse.org/jetty/documentation/current/startup.html +A demo-base directory has been provided as an example of this setup. -The demo-base has been provided to you for an example of this kind of setup. + $ cd demo-base + $ java -jar ../start.jar - $ cd demo-base - $ java -jar ../start.jar +This warning may be disabled by setting the system property + -Dorg.eclipse.jetty.start.home.warning=false +============================================================================