From d624e32e31aa2b94a6df05350b70f32995ff0eeb Mon Sep 17 00:00:00 2001 From: Kristof Neirynck Date: Wed, 19 Feb 2014 18:10:38 +0100 Subject: [PATCH] fix #32 Accept directories outside basedir if absolute --- src/main/java/com/cj/jshintmojo/Mojo.java | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/cj/jshintmojo/Mojo.java b/src/main/java/com/cj/jshintmojo/Mojo.java index 8693197..102b6fe 100644 --- a/src/main/java/com/cj/jshintmojo/Mojo.java +++ b/src/main/java/com/cj/jshintmojo/Mojo.java @@ -181,12 +181,22 @@ private List findFilesToCheck() { List javascriptFiles = new ArrayList(); for(String next: directories){ - File path = new File(basedir, next); - if(!path.exists() && !path.isDirectory()){ - getLog().warn("You told me to find tests in " + next + ", but there is nothing there (" + path.getAbsolutePath() + ")"); - }else{ - collect(path, javascriptFiles); - } + File path = new File(basedir, next); + if(path.exists() && path.isDirectory()){ + getLog().debug("You told me to find tests in " + next + ", which resolves to (" + path.getAbsolutePath() + ")"); + }else{ + File alternativePath = new File(next); + if(alternativePath.isAbsolute() && alternativePath.exists() && alternativePath.isDirectory()){ + path = alternativePath; + getLog().debug("You told me to find tests in " + next + ", which resolves to (" + path.getAbsolutePath() + ")"); + }else{ + getLog().warn("You told me to find tests in " + next + ", but there is nothing there (" + path.getAbsolutePath() + ")"); + path = null; + } + } + if(path != null){ + collect(path, javascriptFiles); + } } List matches = FunctionalJava.filter(javascriptFiles, new Fn(){