If a stringmap is requested and there is none, create an empty file instead.
@@ -1783,10 +1783,18 @@ public abstract class AbstractCommandLineRunner<A extends Compiler,
* Outputs the string map generated by the {@link ReplaceStrings} pass if an output path exists.
*/
private void outputStringMap() throws IOException {
- if (!config.stringMapOutputPath.isEmpty() && compiler.getStringMap() != null) {
+ if (!config.stringMapOutputPath.isEmpty()) {
+ if (compiler.getStringMap() == null) {
+ // Ensure an empty file is created if there is no string map.
+ // This avoids confusing some build tools that expect to see the file, even if it is empty.
+ if (!(new File(config.stringMapOutputPath).createNewFile())) {
+ throw new IOException("Could not create file: " + config.stringMapOutputPath);
+ }
+ } else {
compiler.getStringMap().save(config.stringMapOutputPath);
}
}
+ }
/**
* Create a map of constant names to constant values from a textual
