2016-02-15 70 views

回答

1

您必須實現傳感器實現類的構造函數是這樣的:

public class CodeSensor implements Sensor { 
    private final Logger log = LoggerFactory.getLogger(this.getClass()); 
    private final FileSystem filesystem; 
    private final Settings settings; 
    private final ResourcePerspectives perspectives; 

    public CodeSensor(Settings settings, FileSystem filesystem, ResourcePerspectives perspectives) { 
      this.filesystem = filesystem; 
      this.settings = settings; 
      this.perspectives = perspectives; 

      try (DirectoryStream<Path> stream = 
       Files.newDirectoryStream(filesystem.baseDir().toPath().toAbsolutePath(), 
          settings.getString("sonar.sources"))) { 
        for (Path entry : stream) { 
          DirectoryStream<Path> file = 
           Files.newDirectoryStream(entry, "*.q"); 

          for (Path path : file) { 
            path.toFile().delete(); 
          } 
        } 
      } catch (IOException e1) { 
        log.error("Can't clean src dir", e1); 
      } 
     } 
    } 

這裏是通向你的設置PARAM:settings.getString(「sonar.sources」)

這裏的路徑您的基本文件夾:filesystem.baseDir()。toPath()。toAbsolutePath()