为sonar-maven-plugin设置SCM Activity插件的编码?

时间:2014-04-10 13:00:15

标签: maven sonarqube

我使用SonarQube 4.2 与SCM活动[scmactivity] 1.7 与sonar-maven-plugin 4.2

执行mvn sonar:sonar后,我看到以下内容:

[INFO] --- sonar-maven-plugin:4.2:sonar (default-cli) @ ... ---
INFO: Default locale: "en_US", source code encoding: "UTF-8"
INFO: Work directory: ...\target\sonar
INFO: SonarQube Server 4.2
...
[INFO] [15:43:51.829] Source encoding: UTF-8, default locale: en_US
...
[INFO] [15:43:59.169] Sensor ScmActivitySensor...
[INFO] [15:43:59.169] Trying to guess scm provider from project layout...
[INFO] [15:43:59.170] Found SCM type: svn
[INFO] [15:43:59.170] Retrieve SCM blame information with encoding windows-1250...
[INFO] [15:43:59.343] Retrieve SCM blame information with encoding windows-1250 done: 173 ms
[INFO] [15:43:59.345] Sensor ScmActivitySensor done: 176 ms

如何将编码设置为另一个,例如UTF-8?

2 个答案:

答案 0 :(得分:0)

尝试将这些内容添加到POM的properties部分:

    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

答案 1 :(得分:0)

目前你无法做到。这是负责打印编码的行:

TimeProfiler profiler = new TimeProfiler().start("Retrieve SCM blame information with encoding " + Charset.defaultCharset());

然而,这有点误导,因为作者姓名总是被规范化并且去除了所有非ascii字符:

authors.add(lineNumber, normalizeString(line.getAuthor()));
...
private String normalizeString(String inputString) {
  String lowerCasedString = inputString.toLowerCase();
  String stringWithoutAccents = removeAccents(lowerCasedString);
return removeNonAsciiCharacters(stringWithoutAccents);

实际上,编码没有影响。