|
36 | 36 | import java.util.Map;
|
37 | 37 | import java.util.Properties;
|
38 | 38 | import java.util.Set;
|
| 39 | +import java.util.UUID; |
39 | 40 | import java.util.regex.Pattern;
|
40 | 41 |
|
41 | 42 | import javax.annotation.processing.ProcessingEnvironment;
|
@@ -146,10 +147,18 @@ private List<File> findTranslationFiles(final MessageInterface messageInterface)
|
146 | 147 | if (translationFilesPath != null) {
|
147 | 148 | classTranslationFilesPath = translationFilesPath + packageName.replace('.', File.separatorChar);
|
148 | 149 |
|
149 |
| - //By default use the class output folder |
| 150 | + //By default, use the class output folder |
150 | 151 | } else {
|
151 |
| - FileObject fObj = processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, packageName, interfaceName); |
152 |
| - classTranslationFilesPath = fObj.toUri().getPath().replace(interfaceName, ""); |
| 152 | + // Create some random name: |
| 153 | + String relativeName = interfaceName + UUID.randomUUID(); |
| 154 | + // Eclipse compiler will throw an exception on processingEnv.getFiler().getResource(..) |
| 155 | + // when the resource is missing, while the regular javac will just return a file object that points to |
| 156 | + // a non-existent file. |
| 157 | + // Since we only care about the path here ... we are going to create a dummy resource file |
| 158 | + // that that will be cleaned up right after: |
| 159 | + FileObject fObj = processingEnv.getFiler().createResource( StandardLocation.CLASS_OUTPUT, packageName, relativeName ); |
| 160 | + classTranslationFilesPath = fObj.toUri().getPath().replace(relativeName, ""); |
| 161 | + fObj.delete(); |
153 | 162 | }
|
154 | 163 | final List<File> result;
|
155 | 164 | File[] files = new File(classTranslationFilesPath).listFiles(new TranslationFileFilter(interfaceName));
|
|
0 commit comments