0
如何在分析項目時訪問聲納屬性文件。我需要在sonar-project屬性文件中提到的基礎文件夾。如何在分析項目時訪問聲納屬性文件
如何在分析項目時訪問聲納屬性文件。我需要在sonar-project屬性文件中提到的基礎文件夾。如何在分析項目時訪問聲納屬性文件
您必須實現傳感器實現類的構造函數是這樣的:
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()