Skip to content

Commit 042cb46

Browse files
committed
Change how the default class translation files path is constructed
1 parent 6a8bdf9 commit 042cb46

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

processor/src/main/java/org/jboss/logging/processor/apt/TranslationClassGenerator.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import java.util.Map;
3737
import java.util.Properties;
3838
import java.util.Set;
39+
import java.util.UUID;
3940
import java.util.regex.Pattern;
4041

4142
import javax.annotation.processing.ProcessingEnvironment;
@@ -146,10 +147,18 @@ private List<File> findTranslationFiles(final MessageInterface messageInterface)
146147
if (translationFilesPath != null) {
147148
classTranslationFilesPath = translationFilesPath + packageName.replace('.', File.separatorChar);
148149

149-
//By default use the class output folder
150+
//By default, use the class output folder
150151
} 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();
153162
}
154163
final List<File> result;
155164
File[] files = new File(classTranslationFilesPath).listFiles(new TranslationFileFilter(interfaceName));

0 commit comments

Comments
 (0)