diff --git a/src/main/java/io/wcm/maven/plugins/i18n/TransformMojo.java b/src/main/java/io/wcm/maven/plugins/i18n/TransformMojo.java index 476279e..2910b5d 100644 --- a/src/main/java/io/wcm/maven/plugins/i18n/TransformMojo.java +++ b/src/main/java/io/wcm/maven/plugins/i18n/TransformMojo.java @@ -56,10 +56,11 @@ public class TransformMojo extends AbstractMojo { private static final String FILE_EXTENSION_XML = "xml"; private static final String FILE_EXTENSION_PROPERTIES = "properties"; + private static final String ALL_FILES = "**/*."; private static final String[] SOURCE_FILES_INCLUDES = new String[] { - "**/*." + FILE_EXTENSION_PROPERTIES, - "**/*." + FILE_EXTENSION_XML, - "**/*." + FILE_EXTENSION_JSON + ALL_FILES + FILE_EXTENSION_PROPERTIES, + ALL_FILES + FILE_EXTENSION_XML, + ALL_FILES + FILE_EXTENSION_JSON }; /** @@ -112,21 +113,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { List sourceFiles = getI18nSourceFiles(sourceDirectory); for (File file : sourceFiles) { - try { - // transform i18n files - String languageKey = FileUtils.removeExtension(file.getName()); - I18nReader reader = getI18nReader(file); - SlingI18nMap i18nMap = new SlingI18nMap(languageKey, reader.read(file)); - - // write mappings to target file - File targetFile = getTargetFile(file, selectedOutputFormat); - writeTargetI18nFile(i18nMap, targetFile, selectedOutputFormat); - - getLog().info("Transformed " + file.getPath() + " to " + targetFile.getPath()); - } - catch (IOException ex) { - throw new MojoFailureException("Unable to transform i18n resource: " + file.getPath(), ex); - } + transformFile(file, selectedOutputFormat); } } catch (IOException ex) { @@ -134,6 +121,24 @@ public void execute() throws MojoExecutionException, MojoFailureException { } } + private void transformFile(File file, OutputFormat selectedOutputFormat) throws MojoFailureException { + try { + // transform i18n files + String languageKey = FileUtils.removeExtension(file.getName()); + I18nReader reader = getI18nReader(file); + SlingI18nMap i18nMap = new SlingI18nMap(languageKey, reader.read(file)); + + // write mappings to target file + File targetFile = getTargetFile(file, selectedOutputFormat); + writeTargetI18nFile(i18nMap, targetFile, selectedOutputFormat); + + getLog().info("Transformed " + file.getPath() + " to " + targetFile.getPath()); + } + catch (IOException ex) { + throw new MojoFailureException("Unable to transform i18n resource: " + file.getPath(), ex); + } + } + /** * Checks if and i18n source file was changes in incremental build. * @param sourceDirectory Source directory @@ -271,8 +276,7 @@ private File getTargetFile(File sourceFile, OutputFormat selectedOutputFormat) t private File getGeneratedResourcesFolder() throws IOException { if (generatedResourcesFolder == null) { - String generatedResourcesFolderAbsolutePath = this.project.getBuild().getDirectory() + "/" + generatedResourcesFolderPath; - generatedResourcesFolder = new File(generatedResourcesFolderAbsolutePath); + generatedResourcesFolder = new File(this.project.getBuild().getDirectory(), generatedResourcesFolderPath); if (!generatedResourcesFolder.exists()) { if (!generatedResourcesFolder.mkdirs()) { throw new IOException("Unable to create directory: " + generatedResourcesFolder.getPath());