JDEV_HOME/jdev/bin/ojaudit -rulehelp -output SONAR_HOME/conf/ojaudit-rulehelp.txtto generate a text file with all the audit rules in your JDeveloper installation. This is needed by the SonarQube plugin to discover all the rules that are available in your JDeveloper installation. Unfortunately, JDeveloper version 11.x does not include the severity for all rules in this file so all will be imported in SonarQube with severity Major. You can change these afterwards if you like.
SONAR_HOME/conf/sonar.propertiesand add a line
sonar.ojaudit.rulehelp=conf/ojaudit-rulehelp.txtto point to the location of the created text file. This path is relative to SONAR_HOME or can be an absolute path
ADF EMG ojauditsettings and set the value for the
sonar.ojaudit.jdevhomeproperty. This should be the full path to the jdeveloper home directory. This is the directory that has
jdev/binas the subdirectory, for example
Be sure to read the installation instructions, especially the part on getting the rulehelp.txt file from ojaudit and registering it with SonarQube
When you analyse a project using SonarQube you can either use ant, maven or the command-line sonar-runner. Since the latter is the preferred approach by SonarQube we'll be using that as an example although the same settings apply to the other methods.
For sonar-runner to do its work it needs a
sonar-project.properties file in the root of the project you are going to analyse. When using the ojaudit plugin the example below is the simplest setup:
# basic information about the sonar project sonar.projectKey=ExampleProject sonar.projectName=Description of your project. sonar.projectVersion=0.99 # set language to use ojaudit plugin sonar.language=ojaudit # sources of the project assuming this properties file is # in same directory as .jws file sonar.sources=. # jdeveloper workspace file to analyze. # Relative path from the directory of this property file sonar.ojaudit.jws=ojauditSonar.jws
Once this is done you can simply run
SONAR_HOME/bin/sonar-runner from your project directory and it should analyse your project with ojaudit and feed all violations to SonarQube.
Most projects that you want to analyse with ojaudit probably also have java code in them. You could create two sonar-project.properties files and use one to analyse your project with java plugins and one for ojaudit, but there is a clever way to do both in one run by using modules. You can specify multiple modules in a single sonar-project.properties file and then override sonar properties per module. This allows you to setup one module for java analysis and another for ojaudit analysis:
# basic information about the sonar project sonar.projectKey=ExampleProject sonar.projectName=Description of your project. sonar.projectVersion=0.99 # use two modules sonar.modules=java-module,ojaudit-module # configuration for java-module java-module.sonar.language=java # although property is named projectName, this is actually the module name java-module.sonar.projectName=Java Module # by default modules are in a subdirectory with there name and we don't need that java-module.sonar.projectBaseDir=. java-module.sonar.sources=src/main/java,src/test/java # configuration for ojaudit-module # set language to use ojaudit plugin ojaudit-module.sonar.language=ojaudit ojaudit-module.sonar.projectName=OJAudit Module ojaudit-module.sonar.projectBaseDir=. # sources of the project assuming this properties file is in same directory as .jws file ojaudit-module.sonar.sources=. # jdeveloper workspace file to analyze. Relative path from the directory of this property file ojaudit-module.sonar.ojaudit.jws=ojauditSonar.jws
If you now run sonar-runner it should analyse your project in one go with both the SonarQube java analysis as well as the ojaudit analysis from our plugin.
Below are the properties you can set.
| ||project only||no default||Relative path to .jws or .jpr file from sonar project home|
| ||global and/or project||no default|| absolute path to JDeveloper home directory (that has |
| ||global and/or project||All Rules|| name of the JDeveloper audit profile to execute. Run |
| ||global and/or project|| || ojaudit executable within |
| ||global and/or project||60||maximum number of seconds to wait for ojaudit to complete|
| ||global only||SONAR_HOME/conf/ojaudit-rulehelp.txt|| Path to the output of |
If you want to build the plugin yourself from source code or even contribute to the project, please see the separate page on Developing