Skip to content

Commit

Permalink
[Bug #63] Support Spring Boot 3.2.x JAR structure.
Browse files Browse the repository at this point in the history
  • Loading branch information
ledsoft committed Mar 13, 2024
1 parent 9087792 commit 48fb1ce
Showing 1 changed file with 8 additions and 4 deletions.
Expand Up @@ -58,7 +58,8 @@ public ClasspathScanner(Consumer<Class<?>> listener) {
* This parameter is optional, but it is highly recommended to specify it, as it can speed up the process
* dramatically.
* <p>
* Inspired by https://github.com/ddopson/java-class-enumerator
* Inspired by <a
* href="https://github.com/ddopson/java-class-enumerator">https://github.com/ddopson/java-class-enumerator</a>
*
* @param scanPath Package narrowing down the scan space. Optional
*/
Expand All @@ -81,7 +82,9 @@ public void processClasses(String scanPath) {
Enumeration<URL> resources = loader.getResources(".");
while (resources.hasMoreElements()) {
URL resourceURL = resources.nextElement();
if (isJar(resourceURL.toString())) {processJarFile(resourceURL, scanPath);}
if (isJar(resourceURL.toString())) {
processJarFile(resourceURL, scanPath);
}
}
} catch (IOException e) {
throw new JsonLdException("Unable to scan packages.", e);
Expand All @@ -103,8 +106,9 @@ private static URI getUrlAsUri(URL url) {

protected void processJarFile(URL jarResource, String packageName) {
final String relPath = packageName.replace('.', '/');
final String jarPath = jarResource.getPath().replaceFirst("[.]jar[!].*", JAR_FILE_SUFFIX)
.replaceFirst("file:", "");
final String jarPath = jarResource.getPath().replaceFirst("[.]jar/?!.*", JAR_FILE_SUFFIX)
.replaceFirst("file:", "")
.replaceFirst("nested:", "");

LOG.trace("Scanning jar file {} for classes.", jarPath);
try (final JarFile jarFile = new JarFile(jarPath)) {
Expand Down

0 comments on commit 48fb1ce

Please sign in to comment.