To perform static analysis on your code:
Execute the jtest task. Your command line may resemble the following:
gradle jtest -I PATH/TO/JTEST/integration/gradle/init.gradle |
The Jtest Plugin for Gradle will collect the necessary build data in the .json file, and analyze your code depending on the test configuration you provided.
By default, test sources are excluded from analysis. To analyze test code, enable the
includeTestSources command line option; see Modifying the Scope with the jtest.includeTestSources Option.
Jtest allows running static analysis configurations for Android projects using dedicated Gradle tasks. The static analysis can be executed for a particular application variant (build type and product flavor). Only one application variant is supported per run. To perform static analysis for more than one application variant, you must run it separately for each variant.
To perform static analysis, the following task must be executed:
jtest[APPLICATION VARIANT NAME] - where APPLICATION VARIANT NAME is the name of the application variant for which the test configuration will be run.
To list available tasks for all application variants for an Android Gradle build, use the command:
gradlew tasks –I [JTEST_HOME/integration/gradle/init.gradle] |
Example:
This example shows a command line that executes the "Android Guidelines" test configuration for the “Debug” build type and a flavor named “Demo” (the application variant name is "DemoDebug").
gradlew installDemoDebug jtestDemoDebug –Djtest.config=”builtin://Android Guidelines” |