diff --git a/src/main/java/com/merkle/oss/magnolia/testing/properties/ReferencingClasspathPropertySource.java b/src/main/java/com/merkle/oss/magnolia/testing/properties/ReferencingClasspathPropertySource.java index a0abfe6..81bd7fe 100644 --- a/src/main/java/com/merkle/oss/magnolia/testing/properties/ReferencingClasspathPropertySource.java +++ b/src/main/java/com/merkle/oss/magnolia/testing/properties/ReferencingClasspathPropertySource.java @@ -4,7 +4,6 @@ import java.io.File; import java.io.IOException; -import java.nio.file.Files; import java.nio.file.Path; import org.apache.commons.io.FileUtils; @@ -25,11 +24,12 @@ public String getProperty(final String key) { if(value != null && value.startsWith("classpath:")) { try { final String classpathResource = StringUtils.removeStart(value, "classpath:"); - final String extension = FilenameUtils.getExtension(classpathResource); - final String baseName = FilenameUtils.getBaseName(classpathResource); - final File tempFile = Files.createTempFile(appRootDir, baseName, "."+extension).toFile(); - FileUtils.copyURLToFile(getClass().getResource(classpathResource), tempFile); - return tempFile.getAbsolutePath(); + final String name = FilenameUtils.getName(classpathResource); + final File file = appRootDir.resolve(name).toFile(); + if(!file.exists()) { + FileUtils.copyURLToFile(getClass().getResource(classpathResource), file); + } + return file.getAbsolutePath(); } catch (Exception e) { throw new RuntimeException(e); }