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

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

Issue 2197403003: [Android] Add shadows-core targets for multiple apis. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: agrieve's nits Created 4 years, 5 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
« no previous file with comments | « third_party/robolectric/README.chromium ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 db72e49a42119703e43114e1b9d3eb8671b4d864..c4e054f1428d2d9ab03b7f5ebfaecc41c8a0cd13 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
@@ -42,7 +42,7 @@ public final class ProcessRobolectricTemplate {
Velocity.init();
final VelocityContext context = new VelocityContext();
- int api = parser.getApiLevel();
+ final int api = parser.getApiLevel();
context.put("api", api);
if (api >= 21) {
context.put("ptrClass", "long");
@@ -60,7 +60,7 @@ public final class ProcessRobolectricTemplate {
public FileVisitResult visitFile(
Path path, BasicFileAttributes attrs) throws IOException {
if (templatePathMatcher.matches(path)) {
- processTemplate(context, path, parser.getBaseTemplateDir(), parser.getOutputDir());
+ processTemplate(context, path, parser.getBaseTemplateDir(), parser.getOutputDir(), api);
}
return FileVisitResult.CONTINUE;
}
@@ -70,12 +70,16 @@ public final class ProcessRobolectricTemplate {
}
}
- private static void processTemplate(VelocityContext context, Path templateFile, Path baseTemplateDir, Path outputDir) throws IOException {
+ private static void processTemplate(VelocityContext context, Path templateFile, Path baseTemplateDir, Path outputDir, int api_level) throws IOException {
final StringWriter stringWriter = new StringWriter();
Template template = Velocity.getTemplate(baseTemplateDir.relativize(templateFile).toString(), "UTF-8");
template.merge(context, stringWriter);
- String relativeOutputFile = templateFile.toString().replace(baseTemplateDir.toString(), "").replace(".vm", "");
+ 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);
}
« no previous file with comments | « third_party/robolectric/README.chromium ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698