ADF & JDeveloper | Tuesday, December 27, 2011

CheckStyle Integration with JDeveloper through Ant External Tools

By: Shay Shmeltzer | Director of Product Management - Oracle

When developers switch from Eclipse to JDeveloper they sometime find that a plug-in that they were using in Eclipse is not available for JDeveloper. In many of the cases a plug-in is not really needed since the functionality is already built-in in JDeveloper. But still sometimes developers would like to get a plug-in they were used to.

Case in point, Checkstyle - an open source utility that audits your Java code according to rules you define for it. JDeveloper has a built in Audit framework with lots of rules that you can turn on or off, and you can also add new audit rules and checks. But what if you want to leverage Checkstyle instead?

One solution is to build an extension that will integrate the two, but for a quicker - and more basic - solution you could opt for the Tools->External Tools option. This option has been there for ages now and allows you to invoke command line interfaces and pass parameters. In recent versions two new options were added that allow you to integrate either Ant or Maven scripts as well.

In this demo I show how to integrate CheckStyle into JDeveloper using this simple Ant script:

<?xml version="1.0" encoding="windows-1252" ?>
<project xmlns="antlib:org.apache.tools.ant" name="Project1" default="all" basedir=".">
    <taskdef resource="checkstyletask.properties" classpath="checkstyle-5.5-all.jar"/>
    <target name="checkstyleAll">
        <checkstyle config="sun_checks.xml">
            <fileset dir="${dir}" includes="**/*.java"/>
        </checkstyle>
    </target>
    <target name="checkstyle">
        <checkstyle config="sun_checks.xml" file="${file}"></checkstyle>
    </target>
</project>

 Here are the steps:


Join the discussion

Comments ( 4 )
  • guest Thursday, May 31, 2012

    thanks


  • guest Wednesday, June 6, 2012

    i am able to customize the look and feel according to my requirement but i have problem in customizing af:selectOneChoice content drop down image.

    Could you please provide some input on this.


  • Shay Wednesday, June 6, 2012

    guest - I'm not sure what this question has to do with this specific blog entry - you should probably post this on the OTN discussion forum though.

    A basic demo of skinning the selectOneChoice is here:

    http://jdevadf.oracle.com/adf-richclient-demo/faces/components/skinningKeys/selectOneChoice.jspx


  • guest Tuesday, June 30, 2015

    shay,

    was trying the same with checkstyle 6.8.

    getting following exception:

    BUILD FAILED

    C:\HPP\Checkstyle\checkstyle-6.8\checkstyle.xml:5: Problem: failed to create task or type checkstyle

    Cause: The name is undefined.

    Action: Check the spelling.

    Action: Check that any custom tasks/types have been declared.

    Action: Check that any <presetdef>/<macrodef> declarations have taken place.

    i modified the shay.xml as:

    <?xml version="1.0" encoding="windows-1252" ?>

    <project xmlns="antlib:org.apache.tools.ant" name="Project1" default="all" basedir=".">

    <taskdef resource="checkstyletask.properties" classpath="checkstyle-6.8-all.jar"/>

    <target name="checkstyleAll">

    <checkstyle config="checkstyle_checks.xml">

    <fileset dir="${dir}" includes="**/*.java"/>

    </checkstyle>

    </target>

    <target name="checkstyle">

    <checkstyle config="checkstyle_checks.xml" file="${file}"></checkstyle>

    </target>

    </project>

    could not find : checkstyletask.properties and sun_checks.xml

    for sun_checks.xml i used ...Checkstyle\checkstyle-6.8\config\checkstyle_checks.xml

    please advise


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha
 

Visit the Oracle Blog

 

Contact Us

Oracle

Integrated Cloud Applications & Platform Services