Skip to content

Commit

Permalink
Merge pull request quarkusio#39136 from w0pp/fix_wrong_devservices_cl…
Browse files Browse the repository at this point in the history
…asspath_volume_path

Fix wrong volume host path being used on Windows
  • Loading branch information
geoand authored Mar 4, 2024
2 parents d39bccd + 07bfe63 commit d63aecd
Showing 1 changed file with 4 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.quarkus.devservices.common;

import java.net.URL;
import java.util.Map;

import org.testcontainers.containers.BindMode;
Expand All @@ -18,19 +17,12 @@ private Volumes() {
public static void addVolumes(GenericContainer<?> container, Map<String, String> volumes) {
for (Map.Entry<String, String> volume : volumes.entrySet()) {
String hostLocation = volume.getKey();
BindMode bindMode = BindMode.READ_WRITE;
if (volume.getKey().startsWith(CLASSPATH)) {
URL url = Thread.currentThread().getContextClassLoader()
.getResource(hostLocation.replaceFirst(CLASSPATH, EMPTY));
if (url == null) {
throw new IllegalStateException("Classpath resource at '" + hostLocation + "' not found!");
}

hostLocation = url.getPath();
bindMode = BindMode.READ_ONLY;
container.withClasspathResourceMapping(hostLocation.replaceFirst(CLASSPATH, EMPTY), volume.getValue(),
BindMode.READ_ONLY);
} else {
container.withFileSystemBind(hostLocation, volume.getValue(), BindMode.READ_WRITE);
}

container.withFileSystemBind(hostLocation, volume.getValue(), bindMode);
}
}
}

0 comments on commit d63aecd

Please sign in to comment.