Chromium Code Reviews| Index: third_party/robolectric/template_processor/src/org/chromium/testing/robolectric/template/ProcessRobolectricTemplate.java |
| diff --git a/third_party/robolectric/template_processor/src/org/chromium/testing/robolectric/template/ProcessRobolectricTemplate.java b/third_party/robolectric/template_processor/src/org/chromium/testing/robolectric/template/ProcessRobolectricTemplate.java |
| index c4e054f1428d2d9ab03b7f5ebfaecc41c8a0cd13..3b23fa0fc6f684dd33e9d2958b29f0f11eca263e 100644 |
| --- a/third_party/robolectric/template_processor/src/org/chromium/testing/robolectric/template/ProcessRobolectricTemplate.java |
| +++ b/third_party/robolectric/template_processor/src/org/chromium/testing/robolectric/template/ProcessRobolectricTemplate.java |
| @@ -34,6 +34,7 @@ public final class ProcessRobolectricTemplate { |
| } |
| public static void main(String[] args) { |
| + |
| final ProcessTemplateArgParser parser = ProcessTemplateArgParser.parse(args); |
| Velocity.setProperty(RuntimeConstants.RESOURCE_LOADER, "file"); |
| @@ -51,39 +52,20 @@ public final class ProcessRobolectricTemplate { |
| context.put("ptrClass", "int"); |
| context.put("ptrClassBoxed", "Integer"); |
| } |
| - |
| try { |
| - final PathMatcher templatePathMatcher = |
| - FileSystems.getDefault().getPathMatcher("glob:" + "**/*.vm"); |
| - Files.walkFileTree(parser.getBaseTemplateDir(), new SimpleFileVisitor<Path>() { |
|
mikecase (-- gone --)
2016/08/03 20:04:27
This walkFileTree line isnt working on the WebRTC
jbudorick
2016/08/03 22:24:03
Java version?
mikecase (-- gone --)
2016/08/03 22:29:55
Maybe. Also, they mentioned they set up some symli
|
| - @Override |
| - public FileVisitResult visitFile( |
| - Path path, BasicFileAttributes attrs) throws IOException { |
| - if (templatePathMatcher.matches(path)) { |
| - processTemplate(context, path, parser.getBaseTemplateDir(), parser.getOutputDir(), api); |
| - } |
| - return FileVisitResult.CONTINUE; |
| - } |
| - }); |
| + for(TemplateFileInfo templateFileInfo: parser.getTemplateFileInfoList()) { |
| + processTemplate(context, templateFileInfo.getTemplateFile(), |
| + templateFileInfo.getOutputFile(), api); |
| + } |
| } catch (IOException e) { |
| System.err.println("Error processing template files for Robolectric! " + e.toString()); |
| } |
| } |
| - private static void processTemplate(VelocityContext context, Path templateFile, Path baseTemplateDir, Path outputDir, int api_level) throws IOException { |
| + private static void processTemplate(VelocityContext context, Path templateFile, Path outputFile, int api_level) throws IOException { |
|
jbudorick
2016/08/03 22:24:03
line length
mikecase (-- gone --)
2016/08/03 22:29:55
Done
|
| final StringWriter stringWriter = new StringWriter(); |
| - Template template = Velocity.getTemplate(baseTemplateDir.relativize(templateFile).toString(), "UTF-8"); |
| + Template template = Velocity.getTemplate(templateFile.toString(), "UTF-8"); |
| template.merge(context, stringWriter); |
| - |
| - String templateFilename = templateFile.getFileName().toString(); |
| - String processedFilename = "" + api_level + File.separator + templateFilename.replace(".vm", ""); |
| - |
| - String relativeOutputFile = templateFile.toString().replace(baseTemplateDir.toString(), "").replace(templateFilename, processedFilename); |
| - |
| - if (relativeOutputFile.startsWith("/")) { |
| - relativeOutputFile = relativeOutputFile.substring(1); |
| - } |
| - Path outputFile = outputDir.resolve(relativeOutputFile); |
| if (!Files.exists(outputFile.getParent())) { |
| Files.createDirectories(outputFile.getParent()); |
| } |