Skip to content

Commit

Permalink
Further improved #5511
Browse files Browse the repository at this point in the history
  • Loading branch information
BalusC committed Oct 19, 2024
1 parent c5319f0 commit 7cc2bd1
Showing 1 changed file with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@

public final class ProvideMetadataToAnnotationScanTask {

private static final Pattern JAR_PATTERN = Pattern.compile("(.*/(\\S*\\.jar)).*(/faces-config.xml|/*.\\.faces-config.xml)");
private static final Pattern FACES_CONFIG_XML_IN_JAR_PATTERN = Pattern.compile("(.*/(\\S*\\.jar)).*(/faces-config.xml|/*.\\.faces-config.xml)");
private static final Pattern CURRENT_RESOURCE_IN_JAR_PATTERN = Pattern.compile("(?<=\\.jar)[!/].*");

private final DocumentInfo[] documentInfos;
private final InjectionProvider containerConnector;
Expand All @@ -55,7 +56,7 @@ private void initializeIvars(Set<Class<?>> annotatedSet) {
for (DocumentInfo docInfo : documentInfos) {

URI sourceURI = docInfo.getSourceURI();
Matcher jarMatcher = JAR_PATTERN.matcher(sourceURI == null ? "" : sourceURI.toString());
Matcher jarMatcher = FACES_CONFIG_XML_IN_JAR_PATTERN.matcher(sourceURI == null ? "" : sourceURI.toString());

if (jarMatcher.matches()) {
String jarName = jarMatcher.group(2);
Expand All @@ -76,14 +77,10 @@ private void initializeIvars(Set<Class<?>> annotatedSet) {
String sourceURIString = sourceURI.toString();
if (annotatedSet != null) {
for (Class<?> clazz : annotatedSet) {
URL resource = clazz.getClassLoader().getResource(clazz.getName().replace(".", "/") + ".class");
String location = CURRENT_RESOURCE_IN_JAR_PATTERN.split(clazz.getResource(".").toString(), 2)[0];

if (resource != null) {
String location = resource.toString().split("(?<=\\.jar)[!/].*", 2)[0];

if (sourceURIString.startsWith(location)) {
toRemove.add(clazz);
}
if (sourceURIString.startsWith(location)) {
toRemove.add(clazz);
}
}
annotatedSet.removeAll(toRemove);
Expand Down

0 comments on commit 7cc2bd1

Please sign in to comment.