@@ -112,14 +112,31 @@ class FoundModule(
112112 if (modulePath.isFile) modulePath = modulePath.parentFile
113113 val moduleMacro = " module" to modulePath.toPath()
114114 val marcosWithModule = macros.with (moduleMacro)
115- result + = moduleDescriptor.resolveJavaLibs(marcosWithModule)
116- .map { it.normalize().toFile() }.filter {
117- val exists = it.exists()
118- if (! exists && it.name != " classes" && deploymentDescriptor == null ) {
119- println (" File not found: $it , usedBy: $name " )
115+ result + = moduleDescriptor.javaLibPaths.mapNotNull { javaLibPath ->
116+ val resolvedPath = marcosWithModule.resolve(javaLibPath).normalize()
117+ if (resolvedPath.toFile().exists()) return @mapNotNull resolvedPath.toFile()
118+
119+ if (deploymentDescriptor == null ) {
120+ // If the module is packaged inside a jar without a deployment descriptor then the paths may not be
121+ // correct. Try to fix the path.
122+ if (javaLibPath.startsWith(" \$ {module}/" )) {
123+ val tail = javaLibPath.substringAfter(" \$ {module}/" ).replace(" ../" , " " ).trimStart(' /' )
124+ var currentParent: File ? = modulePath
125+ while (currentParent != null ) {
126+ val candidate = currentParent.resolve(tail)
127+ if (candidate.exists()) {
128+ return @mapNotNull candidate
129+ }
130+ currentParent = currentParent.parentFile.takeIf { it != currentParent }
131+ }
132+ }
133+ if (! javaLibPath.endsWith(" classes" )) {
134+ println (" File not found: $javaLibPath , usedBy: $name , modulePath: $modulePath " )
120135 }
121- exists
122136 }
137+
138+ null
139+ }
123140 }
124141 val deploymentDescriptor = deploymentDescriptor
125142 if (deploymentDescriptor != null ) {
@@ -130,7 +147,7 @@ class FoundModule(
130147 .map { it.normalize().toFile() }.filter {
131148 val exists = it.exists()
132149 if (! exists) {
133- println (" File not found: $it , usedBy: $name " )
150+ println (" File not found: $it , usedBy: $name , modulePath: $moduleHome " )
134151 }
135152 exists
136153 }
0 commit comments