Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / February 2006

Tip: Looking for answers? Try searching our database.

Ant with checkstyle problem

Thread view: 
JoshRountree@gmail.com - 03 Feb 2006 06:26 GMT
I can't for the life of me get checkstyle to work. I the latest
versions of both checkstyle and ant. I would like to use the antlib
feature of the latest ant.

I think I need someone to step me through it, because I've read every
page about 5 times, and tried every possible combination I can think
of.

1. Where do I put the checkstyle directory?
2. Can someone explain the fields used to refer to the checkstyle task
using the antlib?

Thanks
James Westby - 03 Feb 2006 13:13 GMT
> I can't for the life of me get checkstyle to work. I the latest
> versions of both checkstyle and ant. I would like to use the antlib
[quoted text clipped - 9 lines]
>
> Thanks

You haven't explained what you have achieved so far, or what the problem is.

Anyway, here's a rough outline.

1) Download checkstyle.jar
2) Set up a checkstyle.xml file, you can just copy the sun-checks.xml
from the checkstyle distribution.
3) Define a target in your build.xml file

    <target name="checkstyle" description="Runs checkstyle on all the
source files">
        <checkstyle config="${etc.directory}/checkstyle.xml">
            <fileset dir="${source.directory}" includes="**/*.java"/>       
            <formatter type="plain"/>
        </checkstyle>
    </target>

  if you have properties called

     etc.directory which refers to the dir with checkstyle.xml in it
     source.directory where the tree containing source files to be
checked are

4) If you have the checkstyle.jar local to the project add

    <taskdef resource="checkstyletask.properties"
            classpath="${lib.directory}/checkstyle-all.jar"/>
   
    where lib.directory refers to the dir containing checkstyle.jar

  (Not sure what to do if checkstyle.jar is global)

5) Execute the target

  ant checkstyle

6) Post any error messages

James
Roedy Green - 03 Feb 2006 15:50 GMT
>I think I need someone to step me through it, because I've read every
>page about 5 times, and tried every possible combination I can think
>of.

I'd think all you need to do is put the jar in e:\apache-ant-1.6.5\lib
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Roedy Green - 03 Feb 2006 15:51 GMT
On Fri, 03 Feb 2006 15:50:30 GMT, Roedy Green
<my_email_is_posted_on_my_website@munged.invalid> wrote, quoted or
indirectly quoted someone who said :

>I'd think all you need to do is put the jar in e:\apache-ant-1.6.5\lib

if that did not work, try putting it in the ext directory of the java
it is using.

see http://mindprod.com/jgloss/classpath.html
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

JoshRountree@gmail.com - 03 Feb 2006 19:48 GMT
Just for clarification I am using Ant 1.6.5 and CheckStyle 4.1

Once I unzip the checkstyle archive, it has lots of jar files (7 to be
exact). It seems I need to place one of them in the "Ant\lib
directory", but which one?
Once I get checkstyle in the right place I would like to use it based
on the example here, http://checkstyle.sourceforge.net/anttask.html,
that uses features available in Ant 1.6 and later.

I think it would also help me out if someone can explain exactly what,
xmlns:cs="antlib:com.puppycrawl.tools.checkstyle"> , in the example
means?

Thanks
Roedy Green - 03 Feb 2006 22:59 GMT
>Once I unzip the checkstyle archive, it has lots of jar files (7 to be
>exact). It seems I need to place one of them in the "Ant\lib
>directory", but which one?

one of the nice things about this problem is putting a jar somewhere
it is not needed won't hurt. Put it everywhere.  When you get in
working, if it is important, you can use a binary search technique to
figure out which one was the crucial one.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

James Westby - 04 Feb 2006 02:06 GMT
> Just for clarification I am using Ant 1.6.5 and CheckStyle 4.1
>
> Once I unzip the checkstyle archive, it has lots of jar files (7 to be
> exact). It seems I need to place one of them in the "Ant\lib
> directory", but which one?

From the article you reference below

 The easiest way is to include checkstyle-all-4.1.jar in the classpath.

have you tried that?

> Once I get checkstyle in the right place I would like to use it based
> on the example here, http://checkstyle.sourceforge.net/anttask.html,
[quoted text clipped - 3 lines]
> xmlns:cs="antlib:com.puppycrawl.tools.checkstyle"> , in the example
> means?

http://ant.apache.org/manual/CoreTypes/antlib.html

James


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.