39
39
import java .net .URI ;
40
40
import java .nio .file .Files ;
41
41
import java .nio .file .Path ;
42
+ import java .nio .file .Paths ;
42
43
import java .util .Collection ;
43
44
import java .util .Optional ;
44
45
import java .util .Set ;
@@ -74,7 +75,7 @@ public static void updateClasspath(BrokerPool pool, org.expath.pkg.repo.Package
74
75
final Path packageDir = resolver .resolveResourceAsFile ("." );
75
76
final Classpath cp = new Classpath ();
76
77
try {
77
- scanPackageDir (cp , packageDir );
78
+ scanPackageDir (pkg , cp , packageDir );
78
79
((EXistClassLoader )loader ).addURLs (cp );
79
80
} catch (final IOException e ) {
80
81
LOG .warn ("An error occurred while updating classpath for package {}" , pkg .getName (), e );
@@ -93,7 +94,7 @@ private static void scanPackages(BrokerPool pool, Classpath classpath) {
93
94
try {
94
95
final FileSystemStorage .FileSystemResolver resolver = (FileSystemStorage .FileSystemResolver ) pkg .getResolver ();
95
96
final Path packageDir = resolver .resolveResourceAsFile ("." );
96
- scanPackageDir (classpath , packageDir );
97
+ scanPackageDir (pkg , classpath , packageDir );
97
98
} catch (final IOException e ) {
98
99
LOG .warn ("An error occurred while updating classpath for package {}" , pkg .getName (), e );
99
100
}
@@ -157,7 +158,7 @@ private static boolean isCompatible(final Package pkg) throws PackageException {
157
158
}
158
159
}
159
160
160
- private static void scanPackageDir (Classpath classpath , Path module ) throws IOException {
161
+ private static void scanPackageDir (Package pkg , Classpath classpath , Path module ) throws IOException {
161
162
final Path dotExist = module .resolve (".exist" );
162
163
if (Files .exists (dotExist )) {
163
164
if (!Files .isDirectory (dotExist )) {
@@ -169,7 +170,18 @@ private static void scanPackageDir(Classpath classpath, Path module) throws IOEx
169
170
try (final BufferedReader reader = Files .newBufferedReader (cp )) {
170
171
String line ;
171
172
while ((line = reader .readLine ()) != null ) {
172
- classpath .addComponent (line );
173
+ Path p = Paths .get (line );
174
+ if (!p .isAbsolute ()) {
175
+ final FileSystemStorage .FileSystemResolver res = (FileSystemStorage .FileSystemResolver ) pkg .getResolver ();
176
+ p = res .resolveComponentAsFile (line );
177
+ }
178
+ p = p .normalize ().toAbsolutePath ();
179
+
180
+ if (Files .exists (p )) {
181
+ classpath .addComponent (p .toString ());
182
+ } else {
183
+ LOG .warn ("Unable to add '" + p + "' to the classpath for EXPath package: " + pkg .getName () + ", as the file does not exist!" );
184
+ }
173
185
}
174
186
}
175
187
}
0 commit comments