This documentation relates to QuickBuild 13.0.x
Select here if you are using a different version

The JavaNCSS Plugin

This example plugin analyzes JavaNCSS report to count source and comment lines of your project and if comment to source ratio is under a specified threshold, it reports a build error. It also adds a pie chart to build overview page displaying source and comment lines, and adds a stack bar chart to statistics page to display trends of comment to source ratio over time.

Before diving into the source code, please follow below steps to see how this plugin works:

  1. Make sure Apache Ant is installed.
  2. Open the plugin development workspace and make sure the example project com.example.javancss is imported into the workspace following this guide.
  3. Download this test project and extract it to a directory, say /path/to/componentA.
  4. Start QuickBuild by running Eclipse configuration Bootstrap.
  5. Open the browser and point to http://localhost:8810_ (or any other port you configured in _<QuickBuild install dir>/conf/, select the root configuration and switch to steps tab.
  6. Define the master step as a sequential composition step, and add below child steps into it:
    • A step of type Build/Ant. Give this step a name, and specify the property Ant build file as /path/to/componentA/build/build.xml.
    • A step of type Publish/JavaNCSS Report. Give this step a name, and specify the property JavaNCSS report path as /path/to/componentA/build/metrics.xml.
  7. Switch to page Administration->Plugin Management, and configure the Ant plugin to specify path to Ant executable if it is not in the system path.
  8. Run root configuration to build the test project. After the build finishes:
    • A pie chart will appear in the build overview screen displaying source and comment lines of the test project.
    • A build tab named "javancss" will appear. This tab is created only for demonstration purpose, and does not include any content.
    • Switch to dashboard, and hover mouse over more... link of the newly generated build to bring up the build summary. The build summary will include source and comment line information. Clicking on this information will lead to javancss build tab.
  9. Switch to menu Administration->Plugin Management and configure property comment threshold of the JavaNCSS plugin as 20. This tells QuickBuild to fail the build if comment to source ratio is less than 20%.
  10. Edit file /path/to/componentA/src/com/example/componentA/ to remove all comments.
  11. Switch back to QuickBuild and run the root configuration again. The build will fail with a message Source comments are less than 20%.
  12. Edit file /path/to/componentA/src/com/example/componentA/ to add comments, and run the root configuration again to generate a new build.
  13. Switch to menu Statistics->JavaNCSS, and you will see a stack bar chart displaying trends of source and comment lines for all builds.


Enter labels to add to this page:
Wait Image 
Looking for a label? Just start typing.