Skip to content

Commit e549818

Browse files
committed
[bugfix] Store the path of Jar files in each EXPath Package's .exist/classpath.txt file relative to the package's content/ sub-folder.
Closes #4901
1 parent 89c78a8 commit e549818

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

exist-core/src/main/java/org/exist/repo/ClasspathHelper.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,17 @@ private static void scanPackageDir(Package pkg, Classpath classpath, Path module
170170
try (final BufferedReader reader = Files.newBufferedReader(cp)) {
171171
String line;
172172
while ((line = reader.readLine()) != null) {
173-
if (!Files.exists(Paths.get(line))) {
174-
LOG.warn("Unable to add '" + line + "' to the classpath for EXPath package: " + pkg.getName() + ", as the file does not exist!");
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+
LOG.warn("Unable to add '" + p + "' to the classpath for EXPath package: " + pkg.getName() + ", as the file does not exist!");
175182
} else {
176-
classpath.addComponent(line);
183+
classpath.addComponent(p.toString());
177184
}
178185
}
179186
}

exist-core/src/main/java/org/exist/repo/ExistPkgExtension.java

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,12 @@
3232
import javax.xml.stream.XMLStreamConstants;
3333
import javax.xml.stream.XMLStreamException;
3434
import javax.xml.stream.XMLStreamReader;
35-
import javax.xml.transform.stream.StreamSource;
3635
import java.io.IOException;
3736
import java.io.Writer;
3837
import java.net.URI;
3938
import java.net.URISyntaxException;
4039
import java.nio.file.Files;
4140
import java.nio.file.Path;
42-
import java.nio.file.Paths;
43-
import java.util.Set;
4441

4542
/**
4643
* Handle the exist.xml descriptor in an EXPath package.
@@ -158,23 +155,22 @@ private void setupPackage(Package pkg, ExistPkgInfo info)
158155
throw new PackageException("Impossible to create directory: " + exist);
159156
}
160157
}
161-
final Set<String> jars = info.getJars();
158+
162159
try(final Writer out = Files.newBufferedWriter(classpath)) {
163-
for (final String jar : jars) {
164-
StreamSource jar_src;
160+
for (final String jar : info.getJars()) {
161+
165162
try {
166-
jar_src = res.resolveComponent(jar);
163+
res.resolveComponent(jar);
167164
} catch (final NotExistException ex) {
168-
final String msg = "Inconsistent package descriptor, the JAR file is not in the package: ";
165+
final String msg = "Inconsistent package descriptor, the JAR file is not in the EXPath package: ";
169166
throw new PackageException(msg + jar, ex);
170167
}
171-
final URI uri = URI.create(jar_src.getSystemId());
172-
final Path file = Paths.get(uri);
173-
out.write(file.normalize().toString());
174-
out.write("\n");
168+
169+
out.write(jar);
170+
out.write('\n');
175171
}
176172
} catch (final IOException ex) {
177-
throw new PackageException("Error writing the eXist classpath file: " + classpath, ex);
173+
throw new PackageException("Error writing the eXist classpath file '" + classpath + "' for the EXPath package: " + pkg.getName(), ex);
178174
}
179175
}
180176

0 commit comments

Comments
 (0)