Skip to content

Commit dfb2bd3

Browse files
committed
WW-4055 Includes all jars by default
1 parent f1861ad commit dfb2bd3

File tree

1 file changed

+23
-30
lines changed

1 file changed

+23
-30
lines changed

plugins/convention/src/main/java/org/apache/struts2/convention/PackageBasedActionConfigBuilder.java

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public class PackageBasedActionConfigBuilder implements ActionConfigBuilder {
9393
private String[] actionPackages;
9494
private String[] excludePackages;
9595
private String[] packageLocators;
96-
private String[] includeJars;
96+
private String[] includeJars = new String[] { ".*?\\.jar(!/|/)?" };
9797
private String packageLocatorsBasePackage;
9898
private boolean disableActionScanning = false;
9999
private boolean disablePackageLocatorsScanning = false;
@@ -458,42 +458,35 @@ public URL normalizeToFileProtocol(URL url) {
458458
urlSet = urlSet.excludePaths(System.getProperty("sun.boot.class.path", ""));
459459
urlSet = urlSet.exclude(".*/JavaVM.framework/.*");
460460

461-
if (includeJars == null) {
462-
urlSet = urlSet.exclude(".*?\\.jar(!/|/)?");
463-
} else {
464-
//jar urls regexes were specified
465-
List<URL> rawIncludedUrls = urlSet.getUrls();
466-
Set<URL> includeUrls = new HashSet<URL>();
467-
boolean[] patternUsed = new boolean[includeJars.length];
468-
469-
for (URL url : rawIncludedUrls) {
470-
if (fileProtocols.contains(url.getProtocol())) {
471-
//it is a jar file, make sure it macthes at least a url regex
472-
for (int i = 0; i < includeJars.length; i++) {
473-
String includeJar = includeJars[i];
474-
if (Pattern.matches(includeJar, url.toExternalForm())) {
475-
includeUrls.add(url);
476-
patternUsed[i] = true;
477-
break;
478-
}
461+
List<URL> rawIncludedUrls = urlSet.getUrls();
462+
Set<URL> includeUrls = new HashSet<URL>();
463+
boolean[] patternUsed = new boolean[includeJars.length];
464+
465+
for (URL url : rawIncludedUrls) {
466+
if (fileProtocols.contains(url.getProtocol())) {
467+
//it is a jar file, make sure it macthes at least a url regex
468+
for (int i = 0; i < includeJars.length; i++) {
469+
String includeJar = includeJars[i];
470+
if (Pattern.matches(includeJar, url.toExternalForm())) {
471+
includeUrls.add(url);
472+
patternUsed[i] = true;
473+
break;
479474
}
480-
} else {
481-
//it is not a jar
482-
includeUrls.add(url);
483475
}
476+
} else {
477+
//it is not a jar
478+
includeUrls.add(url);
484479
}
480+
}
485481

486-
if (LOG.isWarnEnabled()) {
487-
for (int i = 0; i < patternUsed.length; i++) {
488-
if (!patternUsed[i]) {
489-
LOG.warn("The includeJars pattern [#0] did not match any jars in the classpath", includeJars[i]);
490-
}
482+
if (LOG.isWarnEnabled()) {
483+
for (int i = 0; i < patternUsed.length; i++) {
484+
if (!patternUsed[i]) {
485+
LOG.warn("The includeJars pattern [#0] did not match any jars in the classpath", includeJars[i]);
491486
}
492487
}
493-
return new UrlSet(includeUrls);
494488
}
495-
496-
return urlSet;
489+
return new UrlSet(includeUrls);
497490
}
498491

499492
/**

0 commit comments

Comments
 (0)