1

I am having trouble with adding checkstyle to my build file. I have been attempting to follow the tutorial at http://checkstyle.sourceforge.net/anttask.html as well as look at examples of code that use checkstyles and find solutions to my problem (such as No output from Checkstyle in ANT), but when I ant build the file (terminal command ant compile jar run), nothing along the lines of checkstyle seems to happen. I think I've inserted the packages in the correct directories. Here is part of my buildfile code:

<property name="checkstyle.dir" location="home/lakers/NoteTaker/analysis/bin/checkstyle-5.6" /> 

...

   <target name="checkstyle">
    <taskdef resource="checkstyletask.properties">
    <classpath>
        <pathelement location="home/lakers/NoteTaker/analysis/bin"/>
        <pathelement location ="home/lakers/NoteTaker/analysis/bin/checkstyle-5.6/checkstyle-5.6-all.jar"/>
    </classpath>
    </taskdef>

    <echo>Starting checkstyle</echo>
    <checkstyle config="sun_checks.xml" failOnViolation="false">
        <fileset dir="src" includes="**/*.java"/>
        <fileset dir="NoteTaker/NoteTaker/src/notetaker" includes="**/*.java"/>
        <formatter type="plain"/>
    </checkstyle>
    <echo>Checkstyle finished</echo>
</target>

If anything I said is unclear, please let me know and I will try to clarify. Your help is greatly appreciated. :)

1 Answer 1

3

Make sure the following files are present:

  1. checkstyle-5.6-all.jar -- in -- home/lakers/NoteTaker/analysis/bin/checkstyle-5.6/checkstyle-5.6-all.jar,
  2. sun_checks.xml -- in your -- base directory

maybe you missed the proper directory for sun_checks.xml.

I have made one build file and its working properly.

The directory structure is :

project
|--------src
|         |------packages/*.java files
|
|--------files
          |------checkstyle-all-5.6.jar
          |------sun_checks.xml

I have copied checkstyle-all-5.6.jar and *sun_checks.xml* to this project directory.

My build.xml looks like :

<?xml version="1.0"?>
<project name="XYZ" basedir="." default="job">

    <taskdef resource="checkstyletask.properties" classpath="${basedir}/files/checkstyle-5.6-all.jar" />

    <target name="job">
        <checkstyle config="files/sun_checks.xml"
            failureProperty="checkstyle.failure" failOnViolation="false">
            <fileset dir="src" includes="**/*.java" />
            <formatter type="plain" />
        </checkstyle>

        <echo>Job is Done</echo>
    </target>

</project>

I have run this build file and its giving the violations correctly.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.