Skip to content

Commit

Permalink
chore: improve class scanning filter (#20978)
Browse files Browse the repository at this point in the history
Ignores additional well known packages when scanning classes
to find frontend resources.
  • Loading branch information
mcollovati authored Feb 12, 2025
1 parent c8811e5 commit 6fe93c4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,14 @@
public class FrontendDependencies extends AbstractDependenciesScanner {

//@formatter:off
private static final Pattern VISITABLE_CLASS_PATTERN = Pattern.compile("(^$|"
private static final Pattern NOT_VISITABLE_CLASS_PATTERN = Pattern.compile("(^$|"
+ ".*(slf4j).*|"
// #5803
+ "^(java|sun|oracle|elemental|javax|jakarta|oshi|"
+ "org\\.(apache|atmosphere|jsoup|jboss|w3c|spring|joda|hibernate|glassfish|hsqldb|osgi|jooq)\\b|"
+ "com\\.(helger|spring|gwt|lowagie|fasterxml|sun|nimbusds|googlecode)\\b|"
+ "^(java|sun|oracle|elemental|javax|javafx|jakarta|oshi|cglib|"
+ "org\\.(apache|antlr|atmosphere|aspectj|jsoup|jboss|w3c|spring|joda|hibernate|glassfish|hsqldb|osgi|jooq|springframework|bouncycastle|snakeyaml|keycloak|flywaydb)\\b|"
+ "com\\.(helger|spring|gwt|lowagie|fasterxml|sun|nimbusds|googlecode|ibm)\\b|"
+ "ch\\.quos\\.logback\\b|"
+ "io\\.(fabric8\\.kubernetes)\\b|"
+ "net\\.(sf|bytebuddy)\\b"
+ ").*|"
+ ".*(Exception)$"
Expand Down Expand Up @@ -903,7 +905,7 @@ protected boolean shouldVisit(String className) {
// common name-spaces that would not have components.
// We also exclude Feature-Flag classes
return className != null && !isExperimental(className)
&& !VISITABLE_CLASS_PATTERN.matcher(className).matches();
&& !NOT_VISITABLE_CLASS_PATTERN.matcher(className).matches();
}

private URL getUrl(String className) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,11 +327,11 @@ public void shouldVisit_shouldNotMatchOnPartOfPackage() {
classFinder, true);

Assert.assertTrue(
"second package should match fully not as starts with 'spring != springframework'",
dependencies.shouldVisit("org.springframework.samples"));
"second package should match fully not as starts with 'spring != springseason'",
dependencies.shouldVisit("org.springseason.samples"));
Assert.assertTrue(
"second package should match fully not as starts with 'spring != springframework'",
dependencies.shouldVisit("org.springframework"));
"second package should match fully not as starts with 'spring != springseason'",
dependencies.shouldVisit("org.springseason"));
Assert.assertFalse("should not visit with only 2 packages 'org.spring'",
dependencies.shouldVisit("org.spring"));

Expand Down

0 comments on commit 6fe93c4

Please sign in to comment.