Package com.cj.jshintmojo.cache

Examples of com.cj.jshintmojo.cache.Cache


    try {
      final File targetPath = new File(basedir, "target");
      mkdirs(targetPath);
      final File cachePath = new File(targetPath, "lint.cache");
     
      final Cache cache = readCache(cachePath, new Cache(this.options, this.globals));
     
      if(!nullSafeEquals(options, cache.options)){
        getLog().warn("Options changed ... clearing cache");
        cache.previousResults.clear();
      }
     
      if(!nullSafeEquals(globals, cache.globals)){
        getLog().warn("Globals changed ... clearing cache");
        cache.previousResults.clear();
      }
     
      List<File> javascriptFiles = new ArrayList<File>();

      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);
        }
      }

      List<File> matches = FunctionalJava.filter(javascriptFiles, new Fn<File, Boolean>(){
        public Boolean apply(File i) {
          for(String exclude : excludes){
            File e = new File(basedir, exclude);
            if(i.getAbsolutePath().startsWith(e.getAbsolutePath())){
              getLog().warn("Excluding " + i);
             
              return Boolean.FALSE;
            }
          }

          return Boolean.TRUE;
        }
      });

      JSHint jshint = new JSHint();

      final Map<String, Result> currentResults = new HashMap<String, Result>();
      for(File file : matches){
        Result previousResult = cache.previousResults.get(file.getAbsolutePath());
        Result theResult;
        if(previousResult==null || (previousResult.lastModified.longValue()!=file.lastModified())){
          getLog().info("  " + file );
          List<Error> errors = jshint.run(new FileInputStream(file), options, globals);
          theResult = new Result(file.getAbsolutePath(), file.lastModified(), errors);
        }else{
          getLog().info("  " + file + " [no change]");
          theResult = previousResult;
        }
       
        if(theResult!=null){
          currentResults.put(theResult.path, theResult);
          Result r = theResult;
          currentResults.put(r.path, r);
          for(Error error: r.errors){
            getLog().error("   " + error.line.intValue() + "," + error.character.intValue() + ": " + error.reason);
          }
        }
      }
     
      Util.writeObject(new Cache(options, this.globals, currentResults), cachePath);
     
     
      int numProblematicFiles = 0;
      for(Result r : currentResults.values()){
        if(!r.errors.isEmpty()){
View Full Code Here


   
    try {
      final File targetPath = new File(basedir, "target");
      mkdirs(targetPath);
      final File cachePath = new File(targetPath, "lint.cache");
      final Cache cache = readCache(cachePath, cacheHash);
     
      final List<File> files = findFilesToCheck();

      final Map<String, Result> currentResults = lintTheFiles(jshint, cache, files, config, log);
     
      Util.writeObject(new Cache(cacheHash, currentResults), cachePath);
     
            handleResults(currentResults, this.reporter, this.reportFile);
           
    } catch (FileNotFoundException e) {
      throw new MojoExecutionException("Something bad happened", e);
View Full Code Here

  }

  private Cache readCache(File path, Cache.Hash hash){
    try {
      if(path.exists()){
        Cache cache = Util.readObject(path);
            if(EqualsBuilder.reflectionEquals(cache.hash, hash)){
                return cache;
            }else{
                log.warn("Something changed ... clearing cache");
                return new Cache(hash);
            }
           
      }
    } catch (Throwable e) {
      super.getLog().warn("I was unable to read the cache.  This may be because of an upgrade to the plugin.");
    }
   
    return new Cache(hash);
  }
View Full Code Here

    try {
      final File targetPath = new File(basedir, "target");
      mkdirs(targetPath);
      final File cachePath = new File(targetPath, "lint.cache");
     
      final Cache cache = readCache(cachePath, new Cache(this.options, this.globals));
     
      if(!nullSafeEquals(options, cache.options)){
        getLog().warn("Options changed ... clearing cache");
        cache.previousResults.clear();
      }
     
      if(!nullSafeEquals(globals, cache.globals)){
        getLog().warn("Globals changed ... clearing cache");
        cache.previousResults.clear();
      }
     
      List<File> javascriptFiles = new ArrayList<File>();

      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);
        }
      }

      List<File> matches = FunctionalJava.filter(javascriptFiles, new Fn<File, Boolean>(){
        public Boolean apply(File i) {
          for(String exclude : excludes){
            File e = new File(basedir, exclude);
            if(i.getAbsolutePath().startsWith(e.getAbsolutePath())){
              getLog().warn("Excluding " + i);
             
              return Boolean.FALSE;
            }
          }

          return Boolean.TRUE;
        }
      });


      final Map<String, Result> currentResults = new HashMap<String, Result>();
      for(File file : matches){
        Result previousResult = cache.previousResults.get(file.getAbsolutePath());
        Result theResult;
        if(previousResult==null || (previousResult.lastModified.longValue()!=file.lastModified())){
          getLog().info("  " + file );
          List<Error> errors = jshint.run(new FileInputStream(file), options, globals);
          theResult = new Result(file.getAbsolutePath(), file.lastModified(), errors);
        }else{
          getLog().info("  " + file + " [no change]");
          theResult = previousResult;
        }
       
        if(theResult!=null){
          currentResults.put(theResult.path, theResult);
          Result r = theResult;
          currentResults.put(r.path, r);
          for(Error error: r.errors){
            getLog().error("   " + error.line.intValue() + "," + error.character.intValue() + ": " + error.reason);
          }
        }
      }
     
      Util.writeObject(new Cache(options, this.globals, currentResults), cachePath);
     
            char NEWLINE = '\n';
            StringBuilder errorRecap = new StringBuilder(NEWLINE);
     
      int numProblematicFiles = 0;
View Full Code Here

   
    try {
      final File targetPath = new File(basedir, "target");
      mkdirs(targetPath);
      final File cachePath = new File(targetPath, "lint.cache");
      final Cache cache = readCache(cachePath, cacheHash);
     
      final List<File> files = findFilesToCheck();

      final Map<String, Result> currentResults = lintTheFiles(jshint, cache, files, config, getLog());
     
      Util.writeObject(new Cache(cacheHash, currentResults), cachePath);
     
            handleResults(currentResults, this.reporter, this.reportFile);
           
    } catch (FileNotFoundException e) {
      throw new MojoExecutionException("Something bad happened", e);
View Full Code Here

  }

  private Cache readCache(File path, Cache.Hash hash){
    try {
      if(path.exists()){
        Cache cache = Util.readObject(path);
            if(EqualsBuilder.reflectionEquals(cache.hash, hash)){
                return cache;
            }else{
              getLog().warn("Something changed ... clearing cache");
                return new Cache(hash);
            }
           
      }
    } catch (Throwable e) {
      super.getLog().warn("I was unable to read the cache.  This may be because of an upgrade to the plugin.");
    }
   
    return new Cache(hash);
  }
View Full Code Here

    try {
      final File targetPath = new File(basedir, "target");
      mkdirs(targetPath);
      final File cachePath = new File(targetPath, "lint.cache");
     
      final Cache cache = readCache(cachePath, new Cache(this.options, this.globals));
     
      if(!nullSafeEquals(options, cache.options)){
        getLog().warn("Options changed ... clearing cache");
        cache.previousResults.clear();
      }
     
      if(!nullSafeEquals(globals, cache.globals)){
        getLog().warn("Globals changed ... clearing cache");
        cache.previousResults.clear();
      }
     
      List<File> javascriptFiles = new ArrayList<File>();

      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);
        }
      }

      List<File> matches = FunctionalJava.filter(javascriptFiles, new Fn<File, Boolean>(){
        public Boolean apply(File i) {
          for(String exclude : excludes){
            File e = new File(basedir, exclude);
            if(i.getAbsolutePath().startsWith(e.getAbsolutePath())){
              getLog().warn("Excluding " + i);
             
              return Boolean.FALSE;
            }
          }

          return Boolean.TRUE;
        }
      });

      JSHint jshint = new JSHint();

      final Map<String, Result> currentResults = new HashMap<String, Result>();
      for(File file : matches){
        Result previousResult = cache.previousResults.get(file.getAbsolutePath());
        Result theResult;
        if(previousResult==null || (previousResult.lastModified.longValue()!=file.lastModified())){
          getLog().info("  " + file );
          List<Error> errors = jshint.run(new FileInputStream(file), options, globals);
          theResult = new Result(file.getAbsolutePath(), file.lastModified(), errors);
        }else{
          getLog().info("  " + file + " [no change]");
          theResult = previousResult;
        }
       
        if(theResult!=null){
          currentResults.put(theResult.path, theResult);
          Result r = theResult;
          currentResults.put(r.path, r);
          for(Error error: r.errors){
            getLog().error("   " + error.line.intValue() + "," + error.character.intValue() + ": " + error.reason);
          }
        }
      }
     
      Util.writeObject(new Cache(options, this.globals, currentResults), cachePath);
     
      int numProblems = 0;
     
      for(Result r : currentResults.values()){
        if(!r.errors.isEmpty()){
View Full Code Here

   
    try {
      final File targetPath = new File(basedir, "target");
      mkdirs(targetPath);
      final File cachePath = new File(targetPath, "lint.cache");
      final Cache cache = readCache(cachePath, cacheHash);
     
      final List<File> files = findFilesToCheck();

      final Map<String, Result> currentResults = lintTheFiles(jshint, cache, files, config, log);
     
      Util.writeObject(new Cache(cacheHash, currentResults), cachePath);
     
            handleResults(currentResults, this.reporter, this.reportFile);
           
    } catch (FileNotFoundException e) {
      throw new MojoExecutionException("Something bad happened", e);
View Full Code Here

  }

  private Cache readCache(File path, Cache.Hash hash){
    try {
      if(path.exists()){
        Cache cache = Util.readObject(path);
            if(EqualsBuilder.reflectionEquals(cache.hash, hash)){
                return cache;
            }else{
                log.warn("Something changed ... clearing cache");
                return new Cache(hash);
            }
           
      }
    } catch (Throwable e) {
      super.getLog().warn("I was unable to read the cache.  This may be because of an upgrade to the plugin.");
    }
   
    return new Cache(hash);
  }
View Full Code Here

    try {
      final File targetPath = new File(basedir, "target");
      mkdirs(targetPath);
      final File cachePath = new File(targetPath, "lint.cache");
     
      final Cache cache = readCache(cachePath, new Cache(this.options, this.globals));
     
      if(!nullSafeEquals(options, cache.options)){
        getLog().warn("Options changed ... clearing cache");
        cache.previousResults.clear();
      }
     
      if(!nullSafeEquals(globals, cache.globals)){
        getLog().warn("Globals changed ... clearing cache");
        cache.previousResults.clear();
      }
     
      List<File> javascriptFiles = new ArrayList<File>();

      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);
        }
      }

      List<File> matches = FunctionalJava.filter(javascriptFiles, new Fn<File, Boolean>(){
        public Boolean apply(File i) {
          for(String exclude : excludes){
            File e = new File(basedir, exclude);
            if(i.getAbsolutePath().startsWith(e.getAbsolutePath())){
              getLog().warn("Excluding " + i);
             
              return Boolean.FALSE;
            }
          }

          return Boolean.TRUE;
        }
      });

      JSHint jshint = new JSHint();

      final Map<String, Result> currentResults = new HashMap<String, Result>();
      for(File file : matches){
        Result previousResult = cache.previousResults.get(file.getAbsolutePath());
        Result theResult;
        if(previousResult==null || (previousResult.lastModified.longValue()!=file.lastModified())){
          getLog().info("  " + file );
          List<Error> errors = jshint.run(new FileInputStream(file), options, globals);
          theResult = new Result(file.getAbsolutePath(), file.lastModified(), errors);
        }else{
          getLog().info("  " + file + " [no change]");
          theResult = previousResult;
        }
       
        if(theResult!=null){
          currentResults.put(theResult.path, theResult);
          Result r = theResult;
          currentResults.put(r.path, r);
          for(Error error: r.errors){
            getLog().error("   " + error.line.intValue() + "," + error.character.intValue() + ": " + error.reason);
          }
        }
      }
     
      Util.writeObject(new Cache(options, this.globals, currentResults), cachePath);
     
            char NEWLINE = '\n';
            StringBuilder errorRecap = new StringBuilder(NEWLINE);
     
      int numProblematicFiles = 0;
View Full Code Here

TOP

Related Classes of com.cj.jshintmojo.cache.Cache

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.