Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(258)

Unified Diff: third_party/robolectric/template_processor/src/org/chromium/testing/robolectric/template/ProcessRobolectricTemplate.java

Issue 2200413004: Pass template files explicitly to Robolectric template processor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Jbudoricks commnets Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..3858e4d4db9d3f2e90a3c668f651ba06b5ea15ce 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
@@ -51,39 +51,21 @@ 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>() {
- @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 {
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());
}

Powered by Google App Engine
This is Rietveld 408576698