private static void gatherSourceFiles(final File directory, final Set<File> files) { for (File child : directory.listFiles()) { if (child.isDirectory()) { gatherSourceFiles(child, files); } else if (StringResourcesExtractor.check(child)) { files.add(child); } } }
public void execute() { if (this.src == null) { throw new BuildException("Attribute src not set!"); } if (this.dest == null) { throw new BuildException("Attribute dest not set!"); } final Set<File> files = new HashSet<File>(); gatherSourceFiles(this.src, files); for (File sourceFile : files) { try { final String resourceFileContent = StringResourcesExtractor.extract(sourceFile); if (resourceFileContent != null) { File resourceFile = new File(this.dest, getRelativePath(sourceFile.getParentFile(), this.src)); resourceFile = new File(resourceFile, getNameWithoutExtension(sourceFile) + ".properties"); resourceFile.getParentFile().mkdirs(); final OutputStream out = new FileOutputStream(resourceFile); try { final Writer writer = new OutputStreamWriter(out); writer.write(resourceFileContent); writer.flush(); } finally { try { out.close(); } catch (IOException e) { } } } } catch (Exception e) { throw new BuildException(e); } } }