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 d488fed023c..ef41c244751 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 @@ -30,8 +30,6 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; -import javax.management.RuntimeErrorException; - import org.eclipse.jetty.start.builders.StartDirBuilder; import org.eclipse.jetty.start.builders.StartIniBuilder; import org.eclipse.jetty.start.fileinits.MavenLocalRepoFileInitializer; 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 20e89f1c7d7..7bf96fdf042 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 @@ -378,9 +378,11 @@ public class Module } } - public void setEnabled(boolean enabled) + public void clearTransitiveEnable() { - throw new RuntimeException("Don't enable directly"); + if (_notTransitive) + throw new IllegalStateException("Not Transitive"); + _enables.clear(); } public void setSkipFilesValidation(boolean skipFilesValidation) 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 2200e28d8b5..2811f318bdb 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 @@ -34,8 +34,6 @@ import java.util.function.Consumer; import java.util.stream.Collectors; import java.util.stream.Stream; -import javax.net.ssl.HostnameVerifier; - import org.eclipse.jetty.util.TopologicalSort; /** @@ -225,6 +223,7 @@ public class Modules implements Iterable private void enable(Set newlyEnabled, Module module, String enabledFrom, boolean transitive) { StartLog.debug("enable %s from %s transitive=%b",module,enabledFrom,transitive); + AtomicBoolean replace_ini_properties=new AtomicBoolean(false); // Check that this is not already provided by another module! for (String name:module.getProvides()) @@ -234,8 +233,19 @@ public class Modules implements Iterable { providers.forEach(p-> { - if (p!=module && p.isEnabled() && !p.isTransitive()) - throw new UsageException("Capability %s already enabled by %s for %s",name,p.getName(),module.getName()); + if (p!=module && p.isEnabled()) + { + // If the already enabled module is transitive and this enable is not + if (p.isTransitive() && !transitive) + { + p.clearTransitiveEnable(); + // TODO this is not a rigorous way to handle + // ini properties that were added by a default transitive module + replace_ini_properties.set(true); + } + else + throw new UsageException("Capability %s already enabled by %s for %s",name,p.getName(),module.getName()); + } }); } } @@ -253,7 +263,7 @@ public class Modules implements Iterable if (module.hasDefaultConfig()) { for(String line:module.getDefaultConfig()) - _args.parse(line,module.getName(),false); + _args.parse(line,module.getName(),replace_ini_properties.get()); for (Module m:_modules) m.expandProperties(_args.getProperties()); } diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/Props.java b/jetty-start/src/main/java/org/eclipse/jetty/start/Props.java index 505a8ca1260..72403675e14 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/Props.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/Props.java @@ -18,6 +18,8 @@ package org.eclipse.jetty.start; +import static org.eclipse.jetty.start.UsageException.ERR_BAD_ARG; + import java.io.IOException; import java.io.OutputStream; import java.util.ArrayList; @@ -32,8 +34,6 @@ import java.util.regex.Pattern; import org.eclipse.jetty.start.Props.Prop; -import static org.eclipse.jetty.start.UsageException.ERR_BAD_ARG; - /** * Management of Properties. *

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 c49a3a1d34b..a533f4a9b73 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 @@ -18,6 +18,8 @@ package org.eclipse.jetty.start; +import static org.eclipse.jetty.start.UsageException.ERR_BAD_ARG; + import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -41,8 +43,6 @@ import org.eclipse.jetty.start.config.ConfigSource; import org.eclipse.jetty.start.config.ConfigSources; import org.eclipse.jetty.start.config.DirConfigSource; -import static org.eclipse.jetty.start.UsageException.ERR_BAD_ARG; - /** * The Arguments required to start Jetty. */ diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/fileinits/MavenLocalRepoFileInitializer.java b/jetty-start/src/main/java/org/eclipse/jetty/start/fileinits/MavenLocalRepoFileInitializer.java index 74624d3eac2..81bf831e708 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/fileinits/MavenLocalRepoFileInitializer.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/fileinits/MavenLocalRepoFileInitializer.java @@ -25,7 +25,6 @@ import java.nio.file.Path; import org.eclipse.jetty.start.BaseHome; import org.eclipse.jetty.start.FS; -import org.eclipse.jetty.start.FileInitializer; import org.eclipse.jetty.start.StartLog; import org.eclipse.jetty.start.Utils; diff --git a/jetty-start/src/test/java/org/eclipse/jetty/start/ConfigurationAssert.java b/jetty-start/src/test/java/org/eclipse/jetty/start/ConfigurationAssert.java index 655e2c17b99..8e03ddac0ee 100644 --- a/jetty-start/src/test/java/org/eclipse/jetty/start/ConfigurationAssert.java +++ b/jetty-start/src/test/java/org/eclipse/jetty/start/ConfigurationAssert.java @@ -35,8 +35,6 @@ import java.util.Set; import org.eclipse.jetty.start.Props.Prop; import org.eclipse.jetty.toolchain.test.MavenTestingUtils; -import org.hamcrest.Matchers; -import org.hamcrest.core.StringStartsWith; import org.junit.Assert; public class ConfigurationAssert diff --git a/jetty-start/src/test/java/org/eclipse/jetty/start/IncludeJettyDirTest.java b/jetty-start/src/test/java/org/eclipse/jetty/start/IncludeJettyDirTest.java index ab0fe88567f..97e5adb5a6a 100644 --- a/jetty-start/src/test/java/org/eclipse/jetty/start/IncludeJettyDirTest.java +++ b/jetty-start/src/test/java/org/eclipse/jetty/start/IncludeJettyDirTest.java @@ -18,6 +18,10 @@ package org.eclipse.jetty.start; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; + import java.io.File; import java.util.ArrayList; import java.util.List; @@ -32,10 +36,6 @@ import org.junit.Assert; import org.junit.Rule; import org.junit.Test; -import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.notNullValue; - public class IncludeJettyDirTest { private static class MainResult diff --git a/jetty-start/src/test/java/org/eclipse/jetty/start/MainTest.java b/jetty-start/src/test/java/org/eclipse/jetty/start/MainTest.java index 91911591548..799a5a16963 100644 --- a/jetty-start/src/test/java/org/eclipse/jetty/start/MainTest.java +++ b/jetty-start/src/test/java/org/eclipse/jetty/start/MainTest.java @@ -18,8 +18,9 @@ package org.eclipse.jetty.start; -import static org.hamcrest.Matchers.*; -import static org.junit.Assert.*; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; import java.io.File; import java.nio.file.Files; 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 82f0164f102..22b88271d3c 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 @@ -18,13 +18,15 @@ package org.eclipse.jetty.start; +import static org.hamcrest.Matchers.anyOf; +import static org.hamcrest.Matchers.contains; +import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.assertThat; + import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; -import java.util.Set; -import java.util.regex.Pattern; -import java.util.stream.Collectors; import org.eclipse.jetty.start.config.CommandLineConfigSource; import org.eclipse.jetty.start.config.ConfigSources; @@ -33,13 +35,9 @@ import org.eclipse.jetty.start.config.JettyHomeConfigSource; import org.eclipse.jetty.toolchain.test.MavenTestingUtils; import org.eclipse.jetty.toolchain.test.TestingDir; import org.hamcrest.Matchers; -import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; -import static org.hamcrest.Matchers.*; -import static org.junit.Assert.assertThat; - public class ModulesTest { private final static String TEST_SOURCE = ""; diff --git a/jetty-start/src/test/java/org/eclipse/jetty/start/PropertyPassingTest.java b/jetty-start/src/test/java/org/eclipse/jetty/start/PropertyPassingTest.java index 831e7c6e7a3..9df35163fa9 100644 --- a/jetty-start/src/test/java/org/eclipse/jetty/start/PropertyPassingTest.java +++ b/jetty-start/src/test/java/org/eclipse/jetty/start/PropertyPassingTest.java @@ -18,7 +18,8 @@ package org.eclipse.jetty.start; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.is; import java.io.BufferedReader; import java.io.File; diff --git a/jetty-start/src/test/java/org/eclipse/jetty/start/PropsTest.java b/jetty-start/src/test/java/org/eclipse/jetty/start/PropsTest.java index 6c51f4552d7..47ed26e9985 100644 --- a/jetty-start/src/test/java/org/eclipse/jetty/start/PropsTest.java +++ b/jetty-start/src/test/java/org/eclipse/jetty/start/PropsTest.java @@ -18,18 +18,15 @@ package org.eclipse.jetty.start; -import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; -import org.eclipse.jetty.start.Props.Prop; -import org.junit.Test; - import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.nullValue; import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; +import org.eclipse.jetty.start.Props.Prop; +import org.junit.Test; + public class PropsTest { private static final String FROM_TEST = "(test)"; diff --git a/jetty-start/src/test/java/org/eclipse/jetty/start/TestBadUseCases.java b/jetty-start/src/test/java/org/eclipse/jetty/start/TestBadUseCases.java index 5a0ade9258f..d83d1431414 100644 --- a/jetty-start/src/test/java/org/eclipse/jetty/start/TestBadUseCases.java +++ b/jetty-start/src/test/java/org/eclipse/jetty/start/TestBadUseCases.java @@ -18,6 +18,8 @@ package org.eclipse.jetty.start; +import static org.hamcrest.Matchers.containsString; + import java.io.File; import java.util.ArrayList; import java.util.List; @@ -33,8 +35,6 @@ import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameter; import org.junit.runners.Parameterized.Parameters; -import static org.hamcrest.Matchers.containsString; - /** * Test bad configuration scenarios. */ diff --git a/jetty-start/src/test/java/org/eclipse/jetty/start/VersionTest.java b/jetty-start/src/test/java/org/eclipse/jetty/start/VersionTest.java index 4fa8065d748..55132802f57 100644 --- a/jetty-start/src/test/java/org/eclipse/jetty/start/VersionTest.java +++ b/jetty-start/src/test/java/org/eclipse/jetty/start/VersionTest.java @@ -18,8 +18,9 @@ package org.eclipse.jetty.start; -import static org.hamcrest.Matchers.*; -import static org.junit.Assert.*; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; import org.junit.Test; diff --git a/jetty-start/src/test/java/org/eclipse/jetty/start/config/ConfigSourcesTest.java b/jetty-start/src/test/java/org/eclipse/jetty/start/config/ConfigSourcesTest.java index 4fa622f8d34..68a798846c3 100644 --- a/jetty-start/src/test/java/org/eclipse/jetty/start/config/ConfigSourcesTest.java +++ b/jetty-start/src/test/java/org/eclipse/jetty/start/config/ConfigSourcesTest.java @@ -18,6 +18,10 @@ package org.eclipse.jetty.start.config; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; + import java.io.File; import java.io.IOException; import java.nio.file.Path; @@ -35,10 +39,6 @@ import org.junit.Assert; import org.junit.Rule; import org.junit.Test; -import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.notNullValue; - public class ConfigSourcesTest { @Rule