Skip to content

Commit

Permalink
Change how the default class translation files path is constructed
Browse files Browse the repository at this point in the history
  • Loading branch information
marko-bekhta committed Mar 13, 2024
1 parent 6a8bdf9 commit 753db13
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.UUID;
import java.util.regex.Pattern;

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

//By default use the class output folder
//By default, use the class output folder
} else {
FileObject fObj = processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, packageName, interfaceName);
classTranslationFilesPath = fObj.toUri().getPath().replace(interfaceName, "");
// Create some random name:
String relativeName = interfaceName + UUID.randomUUID();
// Eclipse compiler will throw an exception on processingEnv.getFiler().getResource(..)
// when the resource is missing, while the regular javac will just return a file object that points to
// a non-existent file.
// Since we only care about the path here ... we are going to create a dummy resource file
// that that will be cleaned up right after:
FileObject fObj = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, packageName, relativeName);
classTranslationFilesPath = fObj.toUri().getPath().replace(relativeName, "");
fObj.delete();
}
final List<File> result;
File[] files = new File(classTranslationFilesPath).listFiles(new TranslationFileFilter(interfaceName));
Expand Down

0 comments on commit 753db13

Please sign in to comment.