Issue #1505
* minor cleanups of ClasspathPattern * defined jetty.home.uri and jetty.base.uri in start.jar and webapp configuration properties * minor cleanup of start.jar property handling (more needed) * updated location classpathpatterns in modules
This commit is contained in:
parent
a3ace98a8d
commit
9e65d1ebcb
|
@ -18,6 +18,7 @@
|
|||
|
||||
package org.eclipse.jetty.deploy;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
@ -45,6 +46,8 @@ import org.eclipse.jetty.util.annotation.Name;
|
|||
import org.eclipse.jetty.util.component.ContainerLifeCycle;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.xml.XmlConfiguration;
|
||||
|
||||
/**
|
||||
* The Deployment Manager.
|
||||
|
@ -595,4 +598,20 @@ public class DeploymentManager extends ContainerLifeCycle
|
|||
{
|
||||
return getApps(_lifecycle.getNodeByName(nodeName));
|
||||
}
|
||||
|
||||
public void scope(XmlConfiguration xmlc, Resource webapp)
|
||||
throws IOException
|
||||
{
|
||||
xmlc.getIdMap().put("Server", getServer());
|
||||
Resource home = Resource.newResource(System.getProperty("jetty.home","."));
|
||||
xmlc.getProperties().put("jetty.home",home.toString());
|
||||
xmlc.getProperties().put("jetty.home.uri",home.getURI().toString());
|
||||
|
||||
Resource base = Resource.newResource(System.getProperty("jetty.base",home.toString()));
|
||||
xmlc.getProperties().put("jetty.base",base.toString());
|
||||
xmlc.getProperties().put("jetty.base.uri",base.getURI().toString());
|
||||
|
||||
xmlc.getProperties().put("jetty.webapp",webapp.toString());
|
||||
xmlc.getProperties().put("jetty.webapps",webapp.getFile().toPath().getParent().toString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,15 +93,8 @@ public class GlobalWebappConfigBinding implements AppLifeCycle.Binding
|
|||
if (globalContextSettings.exists())
|
||||
{
|
||||
XmlConfiguration jettyXmlConfig = new XmlConfiguration(globalContextSettings.getInputStream());
|
||||
|
||||
Resource resource = Resource.newResource(app.getOriginId());
|
||||
File file = resource.getFile();
|
||||
jettyXmlConfig.getIdMap().put("Server",app.getDeploymentManager().getServer());
|
||||
jettyXmlConfig.getProperties().put("jetty.home",System.getProperty("jetty.home","."));
|
||||
jettyXmlConfig.getProperties().put("jetty.base",System.getProperty("jetty.base","."));
|
||||
jettyXmlConfig.getProperties().put("jetty.webapp",file.getCanonicalPath());
|
||||
jettyXmlConfig.getProperties().put("jetty.webapps",file.getParentFile().getCanonicalPath());
|
||||
|
||||
app.getDeploymentManager().scope(jettyXmlConfig,resource);
|
||||
jettyXmlConfig.configure(context);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -294,11 +294,7 @@ public class WebAppProvider extends ScanningAppProvider
|
|||
}
|
||||
};
|
||||
|
||||
xmlc.getIdMap().put("Server", getDeploymentManager().getServer());
|
||||
xmlc.getProperties().put("jetty.home",System.getProperty("jetty.home","."));
|
||||
xmlc.getProperties().put("jetty.base",System.getProperty("jetty.base","."));
|
||||
xmlc.getProperties().put("jetty.webapp",file.getCanonicalPath());
|
||||
xmlc.getProperties().put("jetty.webapps",file.getParentFile().getCanonicalPath());
|
||||
getDeploymentManager().scope(xmlc,resource);
|
||||
|
||||
if (getConfigurationManager() != null)
|
||||
xmlc.getProperties().putAll(getConfigurationManager().getProperties());
|
||||
|
@ -354,7 +350,6 @@ public class WebAppProvider extends ScanningAppProvider
|
|||
return webAppContext;
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
protected void fileChanged(String filename) throws Exception
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty.start;
|
||||
|
||||
import static org.eclipse.jetty.start.UsageException.ERR_BAD_GRAPH;
|
||||
import static org.eclipse.jetty.start.UsageException.ERR_BAD_STOP_PROPS;
|
||||
import static org.eclipse.jetty.start.UsageException.ERR_INVOKE_MAIN;
|
||||
import static org.eclipse.jetty.start.UsageException.ERR_NOT_STOPPED;
|
||||
|
@ -295,6 +294,20 @@ public class Main
|
|||
StartArgs args = new StartArgs(baseHome);
|
||||
args.parse(baseHome.getConfigSources());
|
||||
|
||||
Props props = baseHome.getConfigSources().getProps();
|
||||
Props.Prop home = props.getProp(BaseHome.JETTY_HOME);
|
||||
if (!args.getProperties().containsKey(BaseHome.JETTY_HOME))
|
||||
args.getProperties().setProperty(home);
|
||||
args.getProperties().setProperty(BaseHome.JETTY_HOME+".uri",
|
||||
baseHome.getHomePath().toUri().toString(),
|
||||
home.origin);
|
||||
Props.Prop base = props.getProp(BaseHome.JETTY_BASE);
|
||||
if (!args.getProperties().containsKey(BaseHome.JETTY_BASE))
|
||||
args.getProperties().setProperty(base);
|
||||
args.getProperties().setProperty(BaseHome.JETTY_BASE+".uri",
|
||||
baseHome.getBasePath().toUri().toString(),
|
||||
base.origin);
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// 3) Module Registration
|
||||
Modules modules = new Modules(baseHome,args);
|
||||
|
|
|
@ -120,7 +120,7 @@ public class StartArgs
|
|||
private Set<String> skipFileValidationModules = new HashSet<>();
|
||||
|
||||
/** Map of enabled modules to the source of where that activation occurred */
|
||||
private Map<String, List<String>> sources = new HashMap<>();
|
||||
Map<String, List<String>> sources = new HashMap<>();
|
||||
|
||||
/** Map of properties to where that property was declared */
|
||||
private Map<String, String> propertySource = new HashMap<>();
|
||||
|
|
|
@ -41,6 +41,7 @@ public class CommandLineConfigSource implements ConfigSource
|
|||
{
|
||||
public static final String ORIGIN_INTERNAL_FALLBACK = "<internal-fallback>";
|
||||
public static final String ORIGIN_CMD_LINE = "<command-line>";
|
||||
public static final String ORIGIN_SYSTEM_PROPERTY = "<system-property>";
|
||||
|
||||
private final RawArgs args;
|
||||
private final Props props;
|
||||
|
@ -79,6 +80,7 @@ public class CommandLineConfigSource implements ConfigSource
|
|||
String val = System.getProperty(BaseHome.JETTY_BASE);
|
||||
if (!Utils.isBlank(val))
|
||||
{
|
||||
setProperty(BaseHome.JETTY_BASE,val,ORIGIN_SYSTEM_PROPERTY);
|
||||
return FS.toPath(val);
|
||||
}
|
||||
|
||||
|
@ -101,6 +103,7 @@ public class CommandLineConfigSource implements ConfigSource
|
|||
String val = System.getProperty(BaseHome.JETTY_HOME);
|
||||
if (!Utils.isBlank(val))
|
||||
{
|
||||
setProperty(BaseHome.JETTY_HOME,val,ORIGIN_SYSTEM_PROPERTY);
|
||||
return FS.toPath(val);
|
||||
}
|
||||
|
||||
|
@ -116,7 +119,9 @@ public class CommandLineConfigSource implements ConfigSource
|
|||
// ${jetty.home} is relative to found BaseHome class
|
||||
try
|
||||
{
|
||||
return new File(new URI(m.group(1))).getParentFile().toPath();
|
||||
Path home = new File(new URI(m.group(1))).getParentFile().toPath();
|
||||
setProperty(BaseHome.JETTY_HOME,home.toString(),ORIGIN_INTERNAL_FALLBACK);
|
||||
return home;
|
||||
}
|
||||
catch (URISyntaxException e)
|
||||
{
|
||||
|
@ -127,7 +132,7 @@ public class CommandLineConfigSource implements ConfigSource
|
|||
|
||||
// Lastly, fall back to ${user.dir} default
|
||||
Path home = FS.toPath(System.getProperty("user.dir","."));
|
||||
setProperty(BaseHome.JETTY_HOME,home.toString(),ORIGIN_INTERNAL_FALLBACK);
|
||||
setProperty(BaseHome.JETTY_HOME,home.toString(),"<user.dir>");
|
||||
return home;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,6 @@ public class ConfigSources implements Iterable<ConfigSource>
|
|||
}
|
||||
|
||||
private LinkedList<ConfigSource> sources = new LinkedList<>();
|
||||
private Props props = new Props();
|
||||
private AtomicInteger sourceWeight = new AtomicInteger(1);
|
||||
|
||||
public void add(ConfigSource source) throws IOException
|
||||
|
@ -61,18 +60,15 @@ public class ConfigSources implements Iterable<ConfigSource>
|
|||
throw new UsageException(ERR_BAD_ARG,"Duplicate Configuration Source Reference: " + source);
|
||||
}
|
||||
sources.add(source);
|
||||
|
||||
Collections.sort(sources,new WeightedConfigSourceComparator());
|
||||
|
||||
updateProps();
|
||||
|
||||
// look for --include-jetty-dir entries
|
||||
for (RawArgs.Entry arg : source.getArgs())
|
||||
{
|
||||
if (arg.startsWith("--include-jetty-dir"))
|
||||
{
|
||||
String ref = getValue(arg.getLine());
|
||||
String dirName = props.expand(ref);
|
||||
String dirName = getProps().expand(ref);
|
||||
Path dir = FS.toPath(dirName).normalize().toAbsolutePath();
|
||||
DirConfigSource dirsource = new DirConfigSource(ref,dir,sourceWeight.incrementAndGet(),true);
|
||||
add(dirsource);
|
||||
|
@ -94,11 +90,20 @@ public class ConfigSources implements Iterable<ConfigSource>
|
|||
|
||||
public Prop getProp(String key)
|
||||
{
|
||||
return props.getProp(key);
|
||||
return getProps().getProp(key);
|
||||
}
|
||||
|
||||
|
||||
public Props getProps()
|
||||
{
|
||||
Props props = new Props();
|
||||
|
||||
// add all properties from config sources (in reverse order)
|
||||
ListIterator<ConfigSource> iter = sources.listIterator(sources.size());
|
||||
while (iter.hasPrevious())
|
||||
{
|
||||
ConfigSource source = iter.previous();
|
||||
props.addAll(source.getProps());
|
||||
}
|
||||
return props;
|
||||
}
|
||||
|
||||
|
@ -147,17 +152,4 @@ public class ConfigSources implements Iterable<ConfigSource>
|
|||
str.append(']');
|
||||
return str.toString();
|
||||
}
|
||||
|
||||
private void updateProps()
|
||||
{
|
||||
props.reset();
|
||||
|
||||
// add all properties from config sources (in reverse order)
|
||||
ListIterator<ConfigSource> iter = sources.listIterator(sources.size());
|
||||
while (iter.hasPrevious())
|
||||
{
|
||||
ConfigSource source = iter.previous();
|
||||
props.addAll(source.getProps());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -137,9 +137,13 @@ public class ConfigurationAssert
|
|||
for (Prop prop : args.getProperties())
|
||||
{
|
||||
String name = prop.key;
|
||||
if ("jetty.home".equals(name) || "jetty.base".equals(name) ||
|
||||
"user.dir".equals(name) || prop.origin.equals(Props.ORIGIN_SYSPROP) ||
|
||||
name.startsWith("java."))
|
||||
if ("jetty.home".equals(name) ||
|
||||
"jetty.base".equals(name) ||
|
||||
"jetty.home.uri".equals(name) ||
|
||||
"jetty.base.uri".equals(name) ||
|
||||
"user.dir".equals(name) ||
|
||||
prop.origin.equals(Props.ORIGIN_SYSPROP) ||
|
||||
name.startsWith("java."))
|
||||
{
|
||||
// strip these out from assertion, to make assertions easier.
|
||||
continue;
|
||||
|
|
|
@ -60,9 +60,19 @@ public class MainTest
|
|||
Main main = new Main();
|
||||
StartArgs args = main.processCommandLine(cmdLineArgs.toArray(new String[cmdLineArgs.size()]));
|
||||
BaseHome baseHome = main.getBaseHome();
|
||||
System.err.println(args);
|
||||
// System.err.println(args);
|
||||
|
||||
ConfigurationAssert.assertConfiguration(baseHome,args,"assert-home.txt");
|
||||
|
||||
// System.err.println("StartArgs.props:");
|
||||
// args.getProperties().forEach(p->System.err.println(p));
|
||||
// System.err.println("BaseHome.props:");
|
||||
// baseHome.getConfigSources().getProps().forEach(p->System.err.println(p));
|
||||
|
||||
assertThat(args.getProperties().getString("jetty.home"),is(baseHome.getHome()));
|
||||
assertThat(args.getProperties().getString("jetty.home.uri"),is(baseHome.getHomePath().toUri().toString()));
|
||||
assertThat(args.getProperties().getString("jetty.base"),is(baseHome.getBase()));
|
||||
assertThat(args.getProperties().getString("jetty.base.uri"),is(baseHome.getBasePath().toUri().toString()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -76,7 +86,7 @@ public class MainTest
|
|||
|
||||
Main main = new Main();
|
||||
StartArgs args = main.processCommandLine(cmdLineArgs.toArray(new String[cmdLineArgs.size()]));
|
||||
System.err.println(args);
|
||||
// System.err.println(args);
|
||||
|
||||
// Assert.assertEquals("--stop should not build module tree", 0, args.getEnabledModules().size());
|
||||
assertEquals("--stop missing port","10000",args.getProperties().getString("STOP.PORT"));
|
||||
|
|
|
@ -27,4 +27,4 @@ http://www.apache.org/licenses/LICENSE-2.0.html
|
|||
|
||||
[ini]
|
||||
log4j.version?=1.2.17
|
||||
|
||||
jetty.webapp.addServerClasses+=,${jetty.base.uri}/lib/log4j/
|
||||
|
|
|
@ -22,4 +22,4 @@ http://www.apache.org/licenses/LICENSE-2.0.html
|
|||
|
||||
[ini]
|
||||
log4j2.version?=2.6.1
|
||||
|
||||
jetty.webapp.addServerClasses+=,${jetty.base.uri}/lib/log4j2/
|
||||
|
|
|
@ -35,4 +35,4 @@ or (per the licensee's choosing) under
|
|||
|
||||
[ini]
|
||||
logback.version?=1.1.7
|
||||
|
||||
jetty.webapp.addServerClasses+=,${jetty.base.uri}/lib/logback/
|
||||
|
|
|
@ -14,6 +14,3 @@ logging
|
|||
|
||||
[exec]
|
||||
-Dorg.eclipse.jetty.util.log.class?=org.eclipse.jetty.util.log.Slf4jLog
|
||||
|
||||
[ini]
|
||||
jetty.webapp.addServerClasses+=,${jetty.base.uri}/lib/slf4j/
|
||||
|
|
|
@ -14,6 +14,3 @@ logging
|
|||
|
||||
[exec]
|
||||
-Dorg.eclipse.jetty.util.log.class?=org.eclipse.jetty.util.log.Slf4jLog
|
||||
|
||||
[ini]
|
||||
jetty.webapp.addServerClasses+=,${jetty.base.uri}/lib/slf4j/,${jetty.base.uri}/lib/log4j/
|
||||
|
|
|
@ -14,6 +14,3 @@ logging
|
|||
|
||||
[exec]
|
||||
-Dorg.eclipse.jetty.util.log.class?=org.eclipse.jetty.util.log.Slf4jLog
|
||||
|
||||
[ini]
|
||||
jetty.webapp.addServerClasses+=,${jetty.base.uri}/lib/slf4j/,${jetty.base.uri}/lib/log4j2/
|
||||
|
|
|
@ -14,6 +14,3 @@ logging
|
|||
|
||||
[exec]
|
||||
-Dorg.eclipse.jetty.util.log.class?=org.eclipse.jetty.util.log.Slf4jLog
|
||||
|
||||
[ini]
|
||||
jetty.webapp.addServerClasses+=,${jetty.base.uri}/lib/slf4j/,${jetty.base.uri}/lib/logback/
|
||||
|
|
|
@ -14,6 +14,3 @@ logging
|
|||
|
||||
[exec]
|
||||
-Dorg.eclipse.jetty.util.log.class?=org.eclipse.jetty.util.log.Slf4jLog
|
||||
|
||||
[ini]
|
||||
jetty.webapp.addServerClasses+=,${jetty.base.uri}/lib/slf4j/
|
||||
|
|
|
@ -15,6 +15,7 @@ lib/slf4j/slf4j-api-${slf4j.version}.jar
|
|||
|
||||
[ini]
|
||||
slf4j.version?=1.7.21
|
||||
jetty.webapp.addServerClasses+=,${jetty.base.uri}/lib/slf4j/
|
||||
|
||||
[license]
|
||||
SLF4J is distributed under the MIT License.
|
||||
|
|
|
@ -732,17 +732,4 @@ public class TypeUtil
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public static File getLocationOfClassAsFile(Class<?> clazz)
|
||||
{
|
||||
URI uri = getLocationOfClass(clazz);
|
||||
|
||||
if (uri != null && "file".equalsIgnoreCase(uri.getScheme()))
|
||||
{
|
||||
return new File(uri);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.io.File;
|
|||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.AbstractSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -47,12 +48,14 @@ import org.eclipse.jetty.util.resource.Resource;
|
|||
* A class pattern is a string of one of the forms:<ul>
|
||||
* <li>'org.package.SomeClass' will match a specific class
|
||||
* <li>'org.package.' will match a specific package hierarchy
|
||||
* <li>'-org.package.Classname' excludes a specific class
|
||||
* <li>'-org.package.' excludes a specific package hierarchy
|
||||
* <li>Nested classes must be specified with the '$' separator if they
|
||||
* are to be explicitly included or excluded (eg. org.example.MyClass$NestedClass).
|
||||
* <li>Nested classes are matched by their containing class. (eg. -org.example.MyClass
|
||||
* would exclude org.example.MyClass$AnyNestedClass)
|
||||
* <li>'org.package.SomeClass$NestedClass ' will match a nested class exactly otherwise.
|
||||
* Nested classes are matched by their containing class. (eg. org.example.MyClass
|
||||
* matches org.example.MyClass$AnyNestedClass)
|
||||
* <li>'file:///some/location/' - A file system directory from which
|
||||
* the class was loaded
|
||||
* <li>'file:///some/location.jar' - The URI of a jar file from which
|
||||
* the class was loaded
|
||||
* <li>Any of the above patterns preceeded by '-' will exclude rather than include the match.
|
||||
* </ul>
|
||||
* When class is initialized from a classpath pattern string, entries
|
||||
* in this string should be separated by ':' (semicolon) or ',' (comma).
|
||||
|
@ -76,7 +79,7 @@ public class ClasspathPattern extends AbstractSet<String>
|
|||
_pattern=pattern;
|
||||
_inclusive = !pattern.startsWith("-");
|
||||
_name = _inclusive ? pattern : pattern.substring(1).trim();
|
||||
_type = (_name.startsWith("file:"))?Type.LOCATION:(_name.endsWith(".")?Type.PACKAGE:Type.CLASSNAME);
|
||||
_type = _name.startsWith("file:")?Type.LOCATION:(_name.endsWith(".")?Type.PACKAGE:Type.CLASSNAME);
|
||||
}
|
||||
|
||||
Entry(String name, boolean include)
|
||||
|
@ -84,7 +87,7 @@ public class ClasspathPattern extends AbstractSet<String>
|
|||
_pattern=include?name:("-"+name);
|
||||
_inclusive = include;
|
||||
_name = name;
|
||||
_type = (_name.startsWith("file:"))?Type.LOCATION:(_name.endsWith(".")?Type.PACKAGE:Type.CLASSNAME);
|
||||
_type = _name.startsWith("file:")?Type.LOCATION:(_name.endsWith(".")?Type.PACKAGE:Type.CLASSNAME);
|
||||
}
|
||||
|
||||
|
||||
|
@ -315,12 +318,16 @@ public class ClasspathPattern extends AbstractSet<String>
|
|||
if (file.isDirectory())
|
||||
{
|
||||
if (path.startsWith(file.toPath()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (path.equals(file.toPath()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -328,7 +335,6 @@ public class ClasspathPattern extends AbstractSet<String>
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
Map<String,Entry> _entries = new HashMap<>();
|
||||
IncludeExcludeSet<Entry,String> _patterns = new IncludeExcludeSet<>(ByPackageOrName.class);
|
||||
IncludeExcludeSet<File,Path> _locations = new IncludeExcludeSet<>(ByLocation.class);
|
||||
|
@ -518,10 +524,13 @@ public class ClasspathPattern extends AbstractSet<String>
|
|||
Boolean byName = _patterns.isIncludedAndNotExcluded(clazz.getName());
|
||||
if (Boolean.FALSE.equals(byName))
|
||||
return byName; // Already excluded so no need to check location.
|
||||
File locationFile = TypeUtil.getLocationOfClassAsFile(clazz);
|
||||
Boolean byLocation = locationFile == null ? null
|
||||
: _locations.isIncludedAndNotExcluded(locationFile.toPath());
|
||||
|
||||
URI location = TypeUtil.getLocationOfClass(clazz);
|
||||
Boolean byLocation = location == null ? null
|
||||
: _locations.isIncludedAndNotExcluded(Paths.get(location));
|
||||
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("match {} from {} byName={} byLocation={} in {}",clazz,location,byName,byLocation,this);
|
||||
|
||||
// Combine the tri-state match of both IncludeExclude Sets
|
||||
boolean included = byName==Boolean.TRUE || byLocation==Boolean.TRUE
|
||||
|| (byName==null && !_patterns.hasIncludes() && byLocation==null && !_locations.hasIncludes());
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
|
||||
package org.eclipse.jetty.webapp;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URI;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.eclipse.jetty.toolchain.test.JDK;
|
||||
|
@ -119,23 +120,15 @@ public class ClasspathPatternTest
|
|||
Assume.assumeFalse(JDK.IS_9);
|
||||
|
||||
// jar from JVM classloader
|
||||
File loc_string = TypeUtil.getLocationOfClassAsFile(String.class);
|
||||
URI loc_string = TypeUtil.getLocationOfClass(String.class);
|
||||
// System.err.println(loc_string);
|
||||
|
||||
// another jar from JVM classloader
|
||||
File loc_jsse = TypeUtil.getLocationOfClassAsFile(Sun.class);
|
||||
// System.err.println(loc_jsse);
|
||||
|
||||
// a jar from maven repo jar
|
||||
File loc_junit = TypeUtil.getLocationOfClassAsFile(Test.class);
|
||||
URI loc_junit = TypeUtil.getLocationOfClass(Test.class);
|
||||
// System.err.println(loc_junit);
|
||||
|
||||
// a jar from another maven repo jar
|
||||
File loc_tool = TypeUtil.getLocationOfClassAsFile(JDK.class);
|
||||
// System.err.println(loc_tool);
|
||||
|
||||
// class file
|
||||
File loc_test = TypeUtil.getLocationOfClassAsFile(ClasspathPatternTest.class);
|
||||
URI loc_test = TypeUtil.getLocationOfClass(ClasspathPatternTest.class);
|
||||
// System.err.println(loc_test);
|
||||
|
||||
ClasspathPattern pattern = new ClasspathPattern();
|
||||
|
@ -147,7 +140,7 @@ public class ClasspathPatternTest
|
|||
Assert.assertThat(pattern.match(ClasspathPatternTest.class), Matchers.is(false));
|
||||
|
||||
// Add directory for both JVM classes
|
||||
pattern.include(loc_string.getParentFile().toURI().toString());
|
||||
pattern.include(Paths.get(loc_string).getParent().toUri().toString());
|
||||
|
||||
// Add jar for individual class and classes directory
|
||||
pattern.include(loc_junit.toString(), loc_test.toString());
|
||||
|
@ -174,23 +167,15 @@ public class ClasspathPatternTest
|
|||
Assume.assumeFalse(JDK.IS_9);
|
||||
|
||||
// jar from JVM classloader
|
||||
File loc_string = TypeUtil.getLocationOfClassAsFile(String.class);
|
||||
URI loc_string = TypeUtil.getLocationOfClass(String.class);
|
||||
// System.err.println(loc_string);
|
||||
|
||||
// another jar from JVM classloader
|
||||
File loc_jsse = TypeUtil.getLocationOfClassAsFile(Sun.class);
|
||||
// System.err.println(loc_jsse);
|
||||
|
||||
// a jar from maven repo jar
|
||||
File loc_junit = TypeUtil.getLocationOfClassAsFile(Test.class);
|
||||
URI loc_junit = TypeUtil.getLocationOfClass(Test.class);
|
||||
// System.err.println(loc_junit);
|
||||
|
||||
// a jar from another maven repo jar
|
||||
File loc_tool = TypeUtil.getLocationOfClassAsFile(JDK.class);
|
||||
// System.err.println(loc_tool);
|
||||
|
||||
// class file
|
||||
File loc_test = TypeUtil.getLocationOfClassAsFile(ClasspathPatternTest.class);
|
||||
URI loc_test = TypeUtil.getLocationOfClass(ClasspathPatternTest.class);
|
||||
// System.err.println(loc_test);
|
||||
|
||||
ClasspathPattern pattern = new ClasspathPattern();
|
||||
|
@ -205,7 +190,7 @@ public class ClasspathPatternTest
|
|||
Assert.assertThat(pattern.match(ClasspathPatternTest.class), Matchers.is(true));
|
||||
|
||||
// Add directory for both JVM classes
|
||||
pattern.exclude(loc_string.getParentFile().toURI().toString());
|
||||
pattern.exclude(Paths.get(loc_string).getParent().toUri().toString());
|
||||
|
||||
// Add jar for individual class and classes directory
|
||||
pattern.exclude(loc_junit.toString(), loc_test.toString());
|
||||
|
|
Loading…
Reference in New Issue