diff --git a/jetty-server/src/main/config/modules/ssl.mod b/jetty-server/src/main/config/modules/ssl.mod index 91916091417..43c29143bde 100644 --- a/jetty-server/src/main/config/modules/ssl.mod +++ b/jetty-server/src/main/config/modules/ssl.mod @@ -11,7 +11,7 @@ etc/jetty-ssl.xml etc/jetty-ssl-context.xml [files] -https://raw.githubusercontent.com/eclipse/jetty.project/master/jetty-server/src/test/config/etc/keystore?id=${jetty.tag.version}|etc/keystore +basehome:modules/ssl/keystore|etc/keystore [ini-template] ### TLS(SSL) Connector Configuration diff --git a/jetty-server/src/main/config/etc/keystore b/jetty-server/src/main/config/modules/ssl/keystore similarity index 100% rename from jetty-server/src/main/config/etc/keystore rename to jetty-server/src/main/config/modules/ssl/keystore diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/BaseBuilder.java b/jetty-start/src/main/java/org/eclipse/jetty/start/BaseBuilder.java index ae8db8c809e..7e1bd5d17ee 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/BaseBuilder.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/BaseBuilder.java @@ -113,24 +113,23 @@ public class BaseBuilder Modules modules = startArgs.getAllModules(); // Select all the added modules to determine which ones are newly enabled - // TODO this does not look correct???? - Set enabled = new HashSet<>(); - Set startModules = new HashSet<>(); + + + Set newly_enabled = new HashSet<>(); if (!startArgs.getStartModules().isEmpty()) { for (String name:startArgs.getStartModules()) - startModules.addAll(modules.select(name,"--add-to-start[d]")); - enabled.addAll(startModules); + newly_enabled.addAll(modules.enable(name,"--add-to-start[d]")); } if (StartLog.isDebugEnabled()) - StartLog.debug("start[d]=%s",startModules); + StartLog.debug("start[d]=%s",newly_enabled); // Check the licenses if (startArgs.isLicenseCheckRequired()) { Licensing licensing = new Licensing(); - for (String name : enabled) + for (String name : newly_enabled) licensing.addModule(modules.get(name)); if (licensing.hasLicenses()) @@ -152,7 +151,7 @@ public class BaseBuilder AtomicReference builder = new AtomicReference<>(); AtomicBoolean modified = new AtomicBoolean(); - if (!startModules.isEmpty()) + if (!newly_enabled.isEmpty()) { Path startd = getBaseHome().getBasePath("start.d"); Path startini = getBaseHome().getBasePath("start.ini"); @@ -167,7 +166,7 @@ public class BaseBuilder boolean useStartD=startArgs.isUseStartd() || Files.exists(startd); builder.set(useStartD?new StartDirBuilder(this):new StartIniBuilder(this)); - startModules.stream().map(n->modules.get(n)).forEach(module -> + newly_enabled.stream().map(n->modules.get(n)).forEach(module -> { try { @@ -187,7 +186,7 @@ public class BaseBuilder { throw new RuntimeException(e); } - }); + }); } files.addAll(startArgs.getFiles()); @@ -242,7 +241,8 @@ public class BaseBuilder } } - System.err.println("Failed to initialize: "+arg.uri+"|"+arg.location); + if (!FS.exists(file)) + System.err.println("Failed to initialize: "+arg.uri+"|"+arg.location); return modified; } 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 f0e258ea87a..49535e3f1d9 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 @@ -97,8 +97,8 @@ public class Main t.printStackTrace(System.err); } System.err.println(); - System.err.println("Usage: java -jar start.jar [options] [properties] [configs]"); - System.err.println(" java -jar start.jar --help # for more information"); + System.err.println("Usage: java -jar $JETTY_HOME/start.jar [options] [properties] [configs]"); + System.err.println(" java -jar $JETTY_HOME/start.jar --help # for more information"); if (test) System.err.println("EXIT: "+exit); @@ -301,7 +301,7 @@ public class Main for (String source : args.getSources(enabledModule)) { String shortForm = baseHome.toShortForm(source); - modules.select(enabledModule,shortForm); + modules.enable(enabledModule,shortForm); } } @@ -349,10 +349,6 @@ public class Main // ------------------------------------------------------------ // 9) Resolve Property Files args.resolvePropertyFiles(baseHome); - - // ------------------------------------------------------------ - // 10) Check enabled modules - args.getAllModules().checkEnabledModules(); return args; } @@ -418,7 +414,10 @@ public class Main StartLog.info("Base directory was modified"); else if (args.isDownload() || !args.getStartModules().isEmpty()) StartLog.info("Base directory was not modified"); - + + // Check module dependencies + args.getAllModules().checkEnabledModules(); + // Informational command line, don't run jetty if (!args.isRun()) { diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/Module.java b/jetty-start/src/main/java/org/eclipse/jetty/start/Module.java index 68c7abda387..13673fb7e8b 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/Module.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/Module.java @@ -402,16 +402,25 @@ public class Module public String toString() { StringBuilder str = new StringBuilder(); - str.append(getName()).append('{'); + str.append(getName()); + char sep='{'; + if (isDynamic()) + { + str.append(sep).append("dynamic"); + sep=','; + } if (isEnabled()) { - str.append("enabled"); - if (isTransitive()) - str.append(",transitive"); + str.append(sep).append("enabled"); + sep=','; } - else if (isTransitive()) - str.append("transitive"); - str.append('}'); + if (isTransitive()) + { + str.append(sep).append("transitive"); + sep=','; + } + if (sep!='{') + str.append('}'); return str.toString(); } diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/Modules.java b/jetty-start/src/main/java/org/eclipse/jetty/start/Modules.java index fecb64561a4..8fe14acbc72 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/Modules.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/Modules.java @@ -221,7 +221,12 @@ public class Modules implements Iterable return _modules.stream().filter(m->{return m.isEnabled();}).collect(Collectors.toList()); } - public Set select(String name, String enabledFrom) + /** Enable a module + * @param name The name of the module to enable + * @param enabledFrom The source the module was enabled from + * @return The set of modules newly enabled + */ + public Set enable(String name, String enabledFrom) { Module module = get(name); if (module==null) @@ -347,6 +352,7 @@ public class Modules implements Iterable public void checkEnabledModules() { + StringBuilder unsatisfied=new StringBuilder(); _modules.stream().filter(Module::isEnabled).forEach(m-> { // Check dependencies @@ -354,9 +360,17 @@ public class Modules implements Iterable { Set providers =_provided.get(d); if (providers.stream().filter(Module::isEnabled).count()==0) - throw new UsageException(-1,"Module %s requires %s from one of %s",m.getName(),d,providers); + { + if (unsatisfied.length()>0) + unsatisfied.append(','); + unsatisfied.append(m.getName()); + System.err.printf("%nWARN: Module %s requires %s from one of %s%n",m.getName(),d,providers); + } }); }); + + if (unsatisfied.length()>0) + throw new UsageException(-1,"Unsatisfied module dependencies: "+unsatisfied); } } diff --git a/jetty-start/src/test/java/org/eclipse/jetty/start/ModulesTest.java b/jetty-start/src/test/java/org/eclipse/jetty/start/ModulesTest.java index 9d36b5fb833..093fbd5d65a 100644 --- a/jetty-start/src/test/java/org/eclipse/jetty/start/ModulesTest.java +++ b/jetty-start/src/test/java/org/eclipse/jetty/start/ModulesTest.java @@ -166,8 +166,8 @@ public class ModulesTest modules.registerAll(); // Enable 2 modules - modules.select("base",TEST_SOURCE); - modules.select("optional",TEST_SOURCE); + modules.enable("base",TEST_SOURCE); + modules.enable("optional",TEST_SOURCE); modules.sort(); // Collect active module list diff --git a/jetty-start/src/test/java/org/eclipse/jetty/start/TestUseCases.java b/jetty-start/src/test/java/org/eclipse/jetty/start/TestUseCases.java index 184ef479bba..4daed6b654a 100644 --- a/jetty-start/src/test/java/org/eclipse/jetty/start/TestUseCases.java +++ b/jetty-start/src/test/java/org/eclipse/jetty/start/TestUseCases.java @@ -133,6 +133,7 @@ public class TestUseCases } StartArgs args = main.processCommandLine(cmdLine); + args.getAllModules().checkEnabledModules(); BaseHome baseHome = main.getBaseHome(); ConfigurationAssert.assertConfiguration(baseHome,args,assertFile); } diff --git a/jetty-start/src/test/resources/usecases/ordered.2.assert.txt b/jetty-start/src/test/resources/usecases/ordered.2.assert.txt index 9ba6defd67c..4dce98fbdd0 100644 --- a/jetty-start/src/test/resources/usecases/ordered.2.assert.txt +++ b/jetty-start/src/test/resources/usecases/ordered.2.assert.txt @@ -1 +1 @@ -EX|UsageException: Module dependent requires alternate from one of +EX|UsageException: Unsatisfied module dependencies diff --git a/jetty-util/src/main/config/etc/jetty-logging.xml b/jetty-util/src/main/config/etc/stderrout-logging.xml similarity index 100% rename from jetty-util/src/main/config/etc/jetty-logging.xml rename to jetty-util/src/main/config/etc/stderrout-logging.xml diff --git a/jetty-util/src/main/config/modules/jcl-slf4j.mod b/jetty-util/src/main/config/modules/jcl-slf4j.mod new file mode 100644 index 00000000000..2b2f7d2cd33 --- /dev/null +++ b/jetty-util/src/main/config/modules/jcl-slf4j.mod @@ -0,0 +1,16 @@ +[description] +Provides JCL implementation that routes logs into slf4j + +[depends] +slf4j-api + +[provides] +jcl-impl +jcl-api + +[files] +maven://org.slf4j/jcl-over-slf4j/1.7.21|lib/slf4j/jcl-over-slf4j-1.7.21.jar + +[lib] +lib/slf4j/jcl-over-slf4j-1.7.21.jar + diff --git a/jetty-util/src/main/config/modules/jcl.mod b/jetty-util/src/main/config/modules/jcl.mod new file mode 100644 index 00000000000..95ce66d163b --- /dev/null +++ b/jetty-util/src/main/config/modules/jcl.mod @@ -0,0 +1,18 @@ +[description] +Provides Apache Java Commons Logging API and implementation + +[depends] + +[provides] +jcl-api +jcl-impl + +[files] +maven://commons-logging/commons-logging/1.1.3|lib/jcl/commons-logging-1.1.3.jar + +[lib] +lib/jcl/commons-logging-1.1.3.jar + +[license] +Log4j is released under the Apache 2.0 license. +http://www.apache.org/licenses/LICENSE-2.0.html diff --git a/jetty-util/src/main/config/modules/java-util-logging.mod b/jetty-util/src/main/config/modules/jetty-jul.mod similarity index 100% rename from jetty-util/src/main/config/modules/java-util-logging.mod rename to jetty-util/src/main/config/modules/jetty-jul.mod diff --git a/jetty-util/src/main/config/modules/jetty-logging.mod b/jetty-util/src/main/config/modules/jetty-logging.mod new file mode 100644 index 00000000000..9ee296e8ede --- /dev/null +++ b/jetty-util/src/main/config/modules/jetty-logging.mod @@ -0,0 +1,12 @@ +[description] +Enables Java util logging + +[depends] +resources + +[provide] +logging + +[files] +basehome:modules/jetty-logging/jetty-logging.properties|resources/jetty-logging.properties + diff --git a/jetty-util/src/main/config/modules/jetty-logging/jetty-logging.properties b/jetty-util/src/main/config/modules/jetty-logging/jetty-logging.properties new file mode 100644 index 00000000000..f30a8967988 --- /dev/null +++ b/jetty-util/src/main/config/modules/jetty-logging/jetty-logging.properties @@ -0,0 +1,12 @@ +## Setup jetty logging implementation +org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog + +## Levels are ALL, DEBUG, INFO, WARN, OFF +org.eclipse.jetty.LEVEL=INFO +#com.example.LEVEL=INFO + +## Hide stacks traces in logs? +#com.example.STACKS=false + +## Show the source file of a log location? +#com.example.SOURCE=false diff --git a/jetty-util/src/main/config/modules/jetty-slf4j.mod b/jetty-util/src/main/config/modules/jetty-slf4j.mod new file mode 100644 index 00000000000..25a4063d4b6 --- /dev/null +++ b/jetty-util/src/main/config/modules/jetty-slf4j.mod @@ -0,0 +1,12 @@ +[description] +Configure Jetty logging to use SLF4J + +[depend] +slf4j-api +slf4j-impl + +[provide] +logging + +[exec] +-Dorg.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.Slf4jLog diff --git a/jetty-util/src/main/config/modules/slf4j-jcl.mod b/jetty-util/src/main/config/modules/slf4j-jcl.mod new file mode 100644 index 00000000000..538d601d8ae --- /dev/null +++ b/jetty-util/src/main/config/modules/slf4j-jcl.mod @@ -0,0 +1,18 @@ +[description] +Provides SLF4J bridge to apache java commons logging + +[depend] +slf4j-api +jcl-api + +[provide] +slf4j-impl + +[files] +maven://org.slf4j/slf4j-jcl/1.7.21|lib/slf4j/slf4j-jcl-1.7.21.jar + +[lib] +lib/slf4j/slf4j-jcl-1.7.21.jar + +[exec] +-Dorg.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.Slf4jLog diff --git a/jetty-util/src/main/config/modules/slf4j-log4j.mod b/jetty-util/src/main/config/modules/slf4j-log4j.mod new file mode 100644 index 00000000000..b37877789c3 --- /dev/null +++ b/jetty-util/src/main/config/modules/slf4j-log4j.mod @@ -0,0 +1,16 @@ +[description] +Provides SLF4J Log4j implementation. + +[depend] +slf4j-api +log4j-api + +[provide] +slf4j-impl + +[files] +maven://org.slf4j/slf4j-log4j12/1.7.21|lib/slf4j/slf4j-log4j12-1.7.21.jar + +[lib] +lib/slf4j/slf4j-log4j12-1.7.21.jar + diff --git a/jetty-util/src/main/config/modules/logging.mod b/jetty-util/src/main/config/modules/stderrout-logging.mod similarity index 94% rename from jetty-util/src/main/config/modules/logging.mod rename to jetty-util/src/main/config/modules/stderrout-logging.mod index 7cead93c737..846f2dabd84 100644 --- a/jetty-util/src/main/config/modules/logging.mod +++ b/jetty-util/src/main/config/modules/stderrout-logging.mod @@ -3,7 +3,7 @@ Redirects JVMs stderr and stdout to a log file, including output from Jetty's default StdErrLog logging. [xml] -etc/jetty-logging.xml +etc/stderrout-logging.xml [files] logs/