Сбой выполнения Sonar-runner, вызывающий исключение приведения

После настройки инструментов сонара (SonarQube, база данных MySql и Sonar-runner) я без проблем выполняю анализ проекта Android. Но после установки Android-плагина для сонара и повторения анализа этот не удается получить следующую ошибку:

INFO  - Preview mode
Load batch settings
User cache: /home/user/.sonar/cache
INFO  - Install plugins
INFO  - Exclude plugins: devcockpit, jira, pdfreport, views, report, buildstability, scmactivity, buildbreaker
INFO  - Create JDBC datasource for jdbc:h2:/home/user/workspace/myAndroidProject/.sonar/.sonartmp/preview1394469024394-0
INFO  - Initializing Hibernate
INFO  - Load project settings
INFO  - Apply project exclusions
INFO  - -------------  Scan myAndroidProject
INFO  - Load module settings
INFO  - Language is forced to java
INFO  - Loading technical debt model...
INFO  - Loading technical debt model done: 424 ms
INFO  - Configure Maven plugins
INFO  - Base dir: /home/user/workspace/myAndroidProject
INFO  - Working dir: /home/user/workspace/myAndroidProject/.sonar
INFO  - Source dirs: /home/user/workspace/myAdnroidProject/src
INFO  - Source encoding: UTF-8, default locale: en_EN
INFO  - Index files
INFO  - Included sources: 
INFO  -   src/**
INFO  - 116 files indexed
WARN  - Accessing the filesystem before the Sensor phase is deprecated and will not be supported in the future. Please update your plugin.
INFO  - Index files
INFO  - Included sources: 
INFO  -   src/**
INFO  - 116 files indexed
WARN  - Accessing the filesystem before the Sensor phase is deprecated and will not be supported in the future. Please update your plugin.
INFO  - Index files
INFO  - Included sources: 
INFO  -   src/**
INFO  - 116 files indexed
INFO  - Quality profile for java: Sonar way
INFO  - Sensor JavaSourceImporter...
INFO  - Sensor JavaSourceImporter done: 49 ms
INFO  - Sensor JavaSquidSensor...
INFO  - Java AST scan...
INFO  - 116 source files to be analyzed
INFO  - 116/116 source files analyzed
INFO  - Java AST scan done: 6693 ms
WARN  - Java bytecode has not been made available to the analyzer. The Depth of Inheritance Tree (DIT) metric, Response for Class (RFC) metric, Number of Children (NOC) metric, Lack of Cohesion (LCOM4) metric, deperecated dependencies metrics, UnusedPrivateMethod rule, RedundantThrowsDeclarationCheck rule, S1160 rule, S1217 rule are disabled.
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 18.440s
Final Memory: 12M/357M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
ERROR: Unable to execute Sonar
ERROR: Caused by: org.sonar.api.resources.Directory cannot be cast to    org.sonar.api.resources.JavaPackage

Мой файл sonar-project.properties имеет следующий вид:

#Required metadata
sonar.projectKey=mKey
sonar.projectName=myAndroidProject
sonar.projectVersion=1.0

# Paths to source directories.
# Paths are relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# Do not put the "sonar-project.properties" file in the same directory with the source code.
# (i.e. never set the "sonar.sources" property to ".")
sonar.sources=src

# The value of the property must be the key of the language.
sonar.language=java

# Encoding of the source code
sonar.sourceEncoding=UTF-8

# Analysis mode
sonar.analysis.mode=preview


#Enables the Lint profile to analyze the code using the Lint rules.
#sonar.profile=Android Lint

Я использую следующую среду:

  • SonarQube 4.2 RC1
  • Сонар-раннер 2.3
  • База данных: MySQL
  • Убунту 12.04 ЛТС
  • Ява 1.7

Я попытался удалить плагин Android, но проблема не устранена. Единственный способ, который я нашел для решения этой проблемы, - это удалить базу данных и пользователя и создать их снова.


person Marcos B.    schedule 10.03.2014    source источник
comment
ИНФОРМАЦИЯ. Создайте источник данных JDBC для jdbc:h2:/home/user/... Это показывает, что вы все еще используете базу данных H2.   -  person rogue lad    schedule 11.03.2014
comment
#sonar.jdbc.url=jdbc:h2:tcp://localhost:9092/sonar #sonar.embeddedDatabase.dataDir= #sonar.embeddedDatabase.port=9092 Я прокомментировал эти строки. Я думаю, что ответ @David RACODON - SonarSource является наиболее точным.   -  person Marcos B.    schedule 11.03.2014


Ответы (2)


Как указано на http://docs.codehaus.org/pages/viewpage.action?pageId=236224987, подключаемый модуль Android еще не совместим с SonarQube 4.2-RC1. См. также http://jira.codehaus.org/browse/SONARPLUGINS-3483.

person David RACODON - QA Consultant    schedule 10.03.2014
comment
Спасибо!! Три ужасных дня, исследуя это, и, наконец, я нашел некоторую надежду. Значит есть еще возможность использовать плагин, может со старой версией? - person Marcos B.; 11.03.2014
comment
Например, 4.1.2 является последней стабильной версией. См. sonarqube.org/downloads и docs.codehaus.org/display/SONAR/Plugin+version+matrix. - person David RACODON - QA Consultant; 12.03.2014
comment
Я обновил свою версию сонара, а также установил Android-плагин в Sonar для добавления профиля Lint. В файле sonar.properties у меня есть строка sonar.profile=Android Lint для запуска профиля Lint. Но после выполнения анализа у меня возникает эта ошибка: Lint must be invoked with the System property com.android.tools.lint.bindir pointing to the ANDROID_SDK tools directory. У меня есть переменная среды ANDROID_HOME, указывающая на каталог sdk, поэтому я не знаю, что еще я могу сделать. - person Marcos B.; 17.03.2014
comment
Я бы порекомендовал вам дождаться версии 1.0 плагина для Android. Это удалит эту зависимость от Android SDK. См. jira.codehaus.org/browse/SONARANDRO-14 и jira.codehaus.org/secure/ - person David RACODON - QA Consultant; 17.03.2014

Вам необходимо предоставить двоичные файлы (файлы байт-кода .class) исполнителю сонара. Добавьте следующую строку в свой файл sonar-project.properties.

# Path to the class files
sonar.binaries=build\\classes\\main

Если приведенная выше строка не работает, проверьте фактический путь к вашим двоичным файлам и поместите его в свойство sonar.binaries.

person rogue lad    schedule 11.03.2014