From 1727b680504acdc2a8cc8f0cb0a891483f05172e Mon Sep 17 00:00:00 2001 From: Erich Douglass Date: Fri, 17 Apr 2015 12:22:46 -0700 Subject: [PATCH] Use absolute paths when scanning for files. --- .../templates/ProcessTemplatesMojo.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/robolectric/templates/ProcessTemplatesMojo.java b/src/main/java/org/robolectric/templates/ProcessTemplatesMojo.java index 2a23bfa..bb13cac 100644 --- a/src/main/java/org/robolectric/templates/ProcessTemplatesMojo.java +++ b/src/main/java/org/robolectric/templates/ProcessTemplatesMojo.java @@ -31,23 +31,23 @@ public class ProcessTemplatesMojo extends AbstractMojo { private MavenProject project; @Parameter(defaultValue = "${project.build.directory}") - private File outputDirectory; + private File output; @Parameter(required = true, readonly = true) - private Integer apiLevel; + private Integer api; @Parameter(required = true, readonly = true) - private FileSet templateFiles; + private FileSet fileset; public void execute() throws MojoExecutionException { try { Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM, new LogHandler(this)); - Velocity.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, project.getBasedir().getAbsolutePath()); + Velocity.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, fileset.getDirectory()); Velocity.init(); VelocityContext context = new VelocityContext(); - context.put("apiLevel", apiLevel); - if (apiLevel >= 21) { + context.put("api", api); + if (api >= 21) { context.put("ptrClass", "long"); context.put("ptrClassBoxed", "Long"); } else { @@ -68,7 +68,7 @@ private List getFiles() throws IOException { final FileSetManager manager = new FileSetManager(); final List files = new ArrayList<>(); - for (String file : manager.getIncludedFiles(templateFiles)) { + for (String file : manager.getIncludedFiles(fileset)) { files.add(new File(file)); } @@ -77,14 +77,14 @@ private List getFiles() throws IOException { private void processTemplate(VelocityContext context, File file) throws VelocityException, MojoExecutionException, IOException { try { - final File inputFile = new File(templateFiles.getDirectory(), file.getPath()); + final File inputFile = new File(file.getPath()); getLog().debug("Input file: " + inputFile.getPath()); final StringWriter sw = new StringWriter(); Template template = Velocity.getTemplate(inputFile.getPath(), "UTF-8"); template.merge(context, sw); - final File outputFile = new File(outputDirectory.getAbsoluteFile(), file.getPath().replace(templateFiles.getDirectory(), "").replace(".vm", "")); + final File outputFile = new File(output.getAbsoluteFile(), file.getPath().replace(fileset.getDirectory(), "").replace(".vm", "")); getLog().debug("Output file: " + outputFile.getPath()); outputFile.getParentFile().mkdirs();