Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoakim Erdfelt2013-09-03 18:26:35 +0000
committerJoakim Erdfelt2013-09-03 18:26:35 +0000
commitd920ef8c40a1552022e6de32a04d63ed92f9c29b (patch)
tree8442345ea4f01580ace590d354163a8880e079d2
parent02a838bef723950b941913cd1d9bebbf3e66dff8 (diff)
downloadorg.eclipse.jetty.project-d920ef8c40a1552022e6de32a04d63ed92f9c29b.tar.gz
org.eclipse.jetty.project-d920ef8c40a1552022e6de32a04d63ed92f9c29b.tar.xz
org.eclipse.jetty.project-d920ef8c40a1552022e6de32a04d63ed92f9c29b.zip
415899 - jetty-start / add --lib=<cp> capability from Jetty 7/8
+ Adding --lib=<cp> concept from Jetty 7/8 to allow for arbitrary library additions, similar to how path=<name> and lib=<name> was used back in those revisions.
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java10
-rw-r--r--jetty-start/src/main/resources/org/eclipse/jetty/start/usage.txt9
-rw-r--r--jetty-start/src/test/java/org/eclipse/jetty/start/ConfigurationAssert.java29
-rw-r--r--jetty-start/src/test/java/org/eclipse/jetty/start/MainTest.java5
-rw-r--r--jetty-start/src/test/resources/assert-home-with-jvm.txt3
-rw-r--r--jetty-start/src/test/resources/extra-libs/example.jar0
-rw-r--r--jetty-start/src/test/resources/extra-resources/example.properties1
7 files changed, 46 insertions, 11 deletions
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 d3001317a1..ae49cf7449 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
@@ -64,7 +64,6 @@ public class StartArgs
System.setProperty("jetty.version",VERSION);
}
- // TODO: might make sense to declare this in modules/base.mod
private static final String SERVER_MAIN = "org.eclipse.jetty.xml.XmlConfiguration";
private List<String> commandLine = new ArrayList<>();
@@ -669,6 +668,15 @@ public class StartArgs
exec = true;
return;
}
+
+ // Arbitrary Libraries
+
+ if(arg.startsWith("--lib="))
+ {
+ String cp = getValue(arg);
+ classpath.addClasspath(cp);
+ return;
+ }
// Module Management
diff --git a/jetty-start/src/main/resources/org/eclipse/jetty/start/usage.txt b/jetty-start/src/main/resources/org/eclipse/jetty/start/usage.txt
index c72edbb554..ec19dd47c9 100644
--- a/jetty-start/src/main/resources/org/eclipse/jetty/start/usage.txt
+++ b/jetty-start/src/main/resources/org/eclipse/jetty/start/usage.txt
@@ -6,6 +6,8 @@ Usage: java -jar start.jar [options...] [properties...] [configs...]
configured to start any java main class.
Command Line Options:
+---------------------
+
--help This help / usage information.
--version Print the version information for Jetty and
@@ -23,7 +25,7 @@ Command Line Options:
o Properties
o Server Classpath
o Server XML Configuration
-
+
--dry-run Print the command line that the start.jar generates,
then exit. This may be used to generate command lines
when the start.ini includes -X or -D arguments.
@@ -38,6 +40,9 @@ Debug and Start Logging:
------------------------
--debug Enable debug output of the startup procedure.
+ Note: this does not setup debug for Jetty itself.
+ If you want debug for Jetty, configure your logging
+ (See bellow)
--start-log-file=<filename>
A filename, relative to ${jetty.base}, where all startup
@@ -119,6 +124,8 @@ Advanced Commands:
location, download it from the given http URI.
Note: location is always relative to ${jetty.base}
+ --lib=<classpath>
+ Add arbitrary classpath entries to the the server classpath.
System Properties:
------------------
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 8484add4c6..04586a0e26 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
@@ -26,6 +26,7 @@ import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.List;
@@ -49,6 +50,7 @@ public class ConfigurationAssert
*/
public static void assertConfiguration(BaseHome baseHome, StartArgs args, String filename) throws FileNotFoundException, IOException
{
+ File testResourcesDir = MavenTestingUtils.getTestResourcesDir();
File file = MavenTestingUtils.getTestResourceFile(filename);
TextFile textFile = new TextFile(file);
@@ -64,12 +66,12 @@ public class ConfigurationAssert
List<String> actualXmls = new ArrayList<>();
for (File xml : args.getXmlFiles())
{
- actualXmls.add(baseHome.toShortForm(xml));
+ actualXmls.add(shorten(baseHome,xml,testResourcesDir));
}
assertOrdered("XML Resolution Order",expectedXmls,actualXmls);
// Validate LIBs (order is not important)
- Set<String> expectedLibs = new HashSet<>();
+ List<String> expectedLibs = new ArrayList<>();
for (String line : textFile)
{
if (line.startsWith("LIB|"))
@@ -77,10 +79,10 @@ public class ConfigurationAssert
expectedLibs.add(getValue(line));
}
}
- Set<String> actualLibs = new HashSet<>();
+ List<String> actualLibs = new ArrayList<>();
for (File path : args.getClasspath())
{
- actualLibs.add(baseHome.toShortForm(path));
+ actualLibs.add(shorten(baseHome,path,testResourcesDir));
}
assertContainsUnordered("Libs",expectedLibs,actualLibs);
@@ -93,7 +95,7 @@ public class ConfigurationAssert
expectedProperties.add(getValue(line));
}
}
- Set<String> actualProperties = new HashSet<>();
+ List<String> actualProperties = new ArrayList<>();
@SuppressWarnings("unchecked")
Enumeration<String> nameEnum = (Enumeration<String>)args.getProperties().propertyNames();
while (nameEnum.hasMoreElements())
@@ -110,7 +112,7 @@ public class ConfigurationAssert
assertContainsUnordered("Properties",expectedProperties,actualProperties);
// Validate Downloads
- Set<String> expectedDownloads = new HashSet<>();
+ List<String> expectedDownloads = new ArrayList<>();
for (String line : textFile)
{
if (line.startsWith("DOWNLOAD|"))
@@ -118,7 +120,7 @@ public class ConfigurationAssert
expectedDownloads.add(getValue(line));
}
}
- Set<String> actualDownloads = new HashSet<>();
+ List<String> actualDownloads = new ArrayList<>();
for (DownloadArg darg : args.getDownloads())
{
actualDownloads.add(String.format("%s:%s",darg.uri,darg.location));
@@ -127,7 +129,18 @@ public class ConfigurationAssert
}
- private static void assertContainsUnordered(String msg, Set<String> expectedSet, Set<String> actualSet)
+ private static String shorten(BaseHome baseHome, File path, File testResourcesDir)
+ {
+ String value = baseHome.toShortForm(path);
+ if (value.startsWith(testResourcesDir.getAbsolutePath()))
+ {
+ int len = testResourcesDir.getAbsolutePath().length();
+ value = "${maven-test-resources}" + value.substring(len);
+ }
+ return value;
+ }
+
+ private static void assertContainsUnordered(String msg, Collection<String> expectedSet, Collection<String> actualSet)
{
// same size?
boolean mismatch = expectedSet.size() != actualSet.size();
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 15f2fab11d..713d5df949 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
@@ -101,6 +101,11 @@ public class MainTest
cmdLineArgs.add("--exec");
cmdLineArgs.add("-Xms1024m");
cmdLineArgs.add("-Xmx1024m");
+
+ // Arbitrary Libs
+ File extraJar = MavenTestingUtils.getTestResourceFile("extra-libs/example.jar");
+ File extraDir = MavenTestingUtils.getTestResourceDir("extra-resources");
+ cmdLineArgs.add(String.format("--lib=%s%s%s",extraJar.getAbsolutePath(),File.pathSeparatorChar,extraDir.getAbsolutePath()));
// Arbitrary XMLs
cmdLineArgs.add("jetty.xml");
diff --git a/jetty-start/src/test/resources/assert-home-with-jvm.txt b/jetty-start/src/test/resources/assert-home-with-jvm.txt
index 165a9e4140..b73061bba4 100644
--- a/jetty-start/src/test/resources/assert-home-with-jvm.txt
+++ b/jetty-start/src/test/resources/assert-home-with-jvm.txt
@@ -33,7 +33,8 @@ LIB|${jetty.home}/lib/websocket/websocket-client-TEST.jar
LIB|${jetty.home}/lib/websocket/websocket-common-TEST.jar
LIB|${jetty.home}/lib/websocket/websocket-server-TEST.jar
LIB|${jetty.home}/lib/websocket/websocket-servlet-TEST.jar
-
+LIB|${maven-test-resources}/extra-resources
+LIB|${maven-test-resources}/extra-libs/example.jar
# The Properties we expect (order is irrelevant)
# PROP|jetty.port=9090
diff --git a/jetty-start/src/test/resources/extra-libs/example.jar b/jetty-start/src/test/resources/extra-libs/example.jar
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/jetty-start/src/test/resources/extra-libs/example.jar
diff --git a/jetty-start/src/test/resources/extra-resources/example.properties b/jetty-start/src/test/resources/extra-resources/example.properties
new file mode 100644
index 0000000000..e7a73e5775
--- /dev/null
+++ b/jetty-start/src/test/resources/extra-resources/example.properties
@@ -0,0 +1 @@
+# Nothing of importance, just used by ConfigTest.java

Back to the top