Ok. I share my last solution. May-be there's one smarter. And I'll be pleased to learn...
3 actions :
- I'll use placeholders to process my annotation at runtime.
The declaration of my annotation is parameterized with a file separator placeholder.
@RunWith(SpringRunner.class)
@SpringBootTest
@TestPropertySource(properties = { "cache.working.dir=." +
"${file_separator}" + "src" +
"${file_separator}" + "test" +
"${file_separator}" + "resources" +
"${file_separator}" + "cacheDirRepository" +
"${file_separator}", ...
- I declare a specific bean in my container to process these placeholders.
@Bean
public static PropertySourcesPlaceholderConfigurer propertiesResolver() {
return new PropertySourcesPlaceholderConfigurer();
}
- Finally, I pass my os-dependent file separator char at runtime as a JVM parameter
For Unix/MacOsX
mvn clean install -DargLine="-Dfile_separator=/"
For Windows
mvn clean install -DargLine="-Dfile_separator=\\"