2 // ========================================================================
3 // Copyright (c) 1995-2016 Mort Bay Consulting Pty. Ltd.
4 // ------------------------------------------------------------------------
5 // All rights reserved. This program and the accompanying materials
6 // are made available under the terms of the Eclipse Public License v1.0
7 // and Apache License v2.0 which accompanies this distribution.
9 // The Eclipse Public License is available at
10 // http://www.eclipse.org/legal/epl-v10.html
12 // The Apache License v2.0 is available at
13 // http://www.opensource.org/licenses/apache2.0.php
15 // You may elect to redistribute this code under either of these licenses.
16 // ========================================================================
19 package org.eclipse.jetty.server;
22 import java.io.IOException;
23 import java.nio.file.Files;
24 import java.nio.file.Path;
26 import org.eclipse.jetty.util.StringUtil;
27 import org.eclipse.jetty.util.log.Log;
28 import org.eclipse.jetty.util.log.Logger;
31 * Display an optional Warning Message if the {jetty.home} and {jetty.base} are the same directory.
33 * This is to warn about not recommended approach to setting up the Jetty Distribution.
35 public class HomeBaseWarning
37 private static final Logger LOG = Log.getLogger(HomeBaseWarning.class);
39 public HomeBaseWarning()
41 boolean showWarn = false;
43 String home = System.getProperty("jetty.home");
44 String base = System.getProperty("jetty.base");
46 if (StringUtil.isBlank(base))
48 // no base defined? then we are likely running
49 // via direct command line.
53 Path homePath = new File(home).toPath();
54 Path basePath = new File(base).toPath();
58 showWarn = Files.isSameFile(homePath,basePath);
63 // Can't definitively determine this state
69 StringBuilder warn = new StringBuilder();
70 warn.append("This instance of Jetty is not running from a separate {jetty.base} directory");
71 warn.append(", this is not recommended. See documentation at http://www.eclipse.org/jetty/documentation/current/startup.html");
72 LOG.warn("{}",warn.toString());