Re: ANT - Checkstyle with custom check

"Oliver Burn" <[email protected]> Fri, 5 Sep 2008 13:02:11 +1000
Newsgroups gmane.comp.java.audit.checkstyle.user
Message-ID <[email protected]>
You have another version of ANTLR in your classpath. Look in $ANT_HOME/lib
for an antlr jar.

On Fri, Sep 5, 2008 at 12:56, Thomas Suckow <[email protected]> wrote:

> Running from command line works, custom check works. Ant doesn't work
> for any check.
>
> For each file when running from ant i get [checkstyle] Can't
> find/access AST Node typecom.puppycrawl.tools.checkstyle.api.DetailAST
>
> and output xml shows: Got an exception - java.lang.ClassCastException:
> antlr.CommonAST cannot be cast to
> com.puppycrawl.tools.checkstyle.api.DetailAST
>
> Classpath issues again maybe? Ideas?
>
> Thomas Suckow
>
>
>
> On Thu, Sep 4, 2008 at 5:43 PM, Oliver Burn <[email protected]> wrote:
> > I would do two things:
> >
> > Have a cut down configuration that just contains your custom check.
> > Add println (or logging) statements  in your custom check to debug and
> > verify it is being called.
> >
> > On Fri, Sep 5, 2008 at 10:41, Thomas Suckow <[email protected]> wrote:
> >>
> >> I moved from using sun_checks as my base of checks to using
> >> checkstyle_checks as my base.
> >>
> >> Yet my check still doesn't seem to do anything, even when i do what
> >> the tabcheck does:
> >> if (tabPosition != -1) //We have a tab
> >>                        {
> >>                                log(i + 1, tabPosition, "misusedTab");
> >>
> >> Thomas Suckow
> >>
> >>
> >>
> >> On Thu, Sep 4, 2008 at 5:37 PM, Thomas Suckow <[email protected]>
> wrote:
> >> > You guys are great.
> >> > Got an exception - java.lang.ClassCastException: antlr.CommonAST
> >> > cannot be cast to com.puppycrawl.tools.checkstyle.api.DetailAST
> >> > Thomas Suckow
> >> >
> >> >
> >> >
> >> > On Thu, Sep 4, 2008 at 5:06 PM, Oliver Burn <[email protected]>
> >> > wrote:
> >> >> This is because it has
> >> >>
> >> >>
> http://checkstyle.sourceforge.net/5.x/config_javadoc.html#JavadocPackage
> >> >> replaces this check. Just change to use this one.
> >> >>
> >> >> On Fri, Sep 5, 2008 at 10:02, Thomas Suckow <[email protected]>
> wrote:
> >> >>>
> >> >>> Well I removed the one in the classpath. This would explain why i
> had
> >> >>> problems in command line.
> >> >>> Now however I get the error:  Unable to create a Checker: cannot
> >> >>> initialize module PackageHtml - Unable to instantiate PackageHtml
> >> >>>
> >> >>> Thomas Suckow
> >> >>>
> >> >>>
> >> >>>
> >> >>> On Thu, Sep 4, 2008 at 4:29 PM, Oliver Burn <[email protected]>
> >> >>> wrote:
> >> >>> > This is the "classic" classpath issue. Be sure that you do not
> have
> >> >>> > Checkstyle anywhere else in your classpath. Look in $ANT_HOME/lib.
> >> >>> >
> >> >>> > Also test using the declaration:
> >> >>> >
> >> >>> > <taskdef resource="checkstyletask.properties">
> >> >>> >         <classpath>
> >> >>> >                 <pathelement location="lib/Defcon1Checks.jar"/>
> >> >>> >         </classpath>
> >> >>> > </taskdef>
> >> >>> >
> >> >>> > If this gives the same results, it means that you have another
> >> >>> > version
> >> >>> > of
> >> >>> > Checkstyle in your classpath.
> >> >>> >
> >> >>> > Running ANT with the "-debug" flag can show where it is being
> found.
> >> >>> >
> >> >>> > On Fri, Sep 5, 2008 at 01:32, Bhavana <[email protected]> wrote:
> >> >>> >>
> >> >>> >> I had a similar issue for some time. The target would work only
> on
> >> >>> >> my
> >> >>> >> machine.
> >> >>> >>
> >> >>> >> I had to fix and try out some of the following to get my target
> to
> >> >>> >> work:
> >> >>> >>
> >> >>> >> Adding the custom checkstyle jar to java's extensions
> java\lib\ext
> >> >>> >> Using ant 1.7
> >> >>> >> Making sure there isn't some other jar for checkstyle library
> being
> >> >>> >> used
> >> >>> >> from some other location
> >> >>> >>
> >> >>> >> Thanks
> >> >>> >>
> >> >>> >> Bhavana
> >> >>> >>
> >> >>> >> On Thu, Sep 4, 2008 at 8:22 AM, Thomas Suckow <[email protected]
> >
> >> >>> >> wrote:
> >> >>> >>>
> >> >>> >>> I started using checkstyle with ant about a week ago. It went
> >> >>> >>> smooth.
> >> >>> >>> Trying to add custom checks is kicking my butt.
> >> >>> >>>
> >> >>> >>> I have a check TabOnlyForIndent extends Check
> >> >>> >>> in package org.hopto.defcon1.checks;
> >> >>> >>> I packaged as a jar from eclipse, it has an empty manifest
> >> >>> >>> (besides
> >> >>> >>> version).
> >> >>> >>>
> >> >>> >>> in ant i load checkstyle and put my jar in the classpath:
> >> >>> >>> <taskdef resource="checkstyletask.properties">
> >> >>> >>>        <classpath>
> >> >>> >>>                <pathelement
> >> >>> >>>
> >> >>> >>>
> location="lib/checkstyle-5.0-beta01/checkstyle-all-5.0-beta01.jar"/>
> >> >>> >>>                <pathelement location="lib/Defcon1Checks.jar"/>
> >> >>> >>>        </classpath>
> >> >>> >>> </taskdef>
> >> >>> >>>
> >> >>> >>> I add my check to the config
> >> >>> >>>
> >> >>> >>>  <!-- <module name="TabCharacter"/> Viva La \t -->
> >> >>> >>>  <module name="org.hopto.defcon1.checks.TabOnlyForIndent"/>
> >> >>> >>>  <module name="WhitespaceAfter"/>
> >> >>> >>>
> >> >>> >>> Have my checkstyle target in ant
> >> >>> >>>
> >> >>> >>> <target name="checkstyle" depends="compile"
> >> >>> >>>  description="Checks that we are using consistant well formed
> >> >>> >>> style.">
> >> >>> >>>        <checkstyle config="config_checkstyle.xml"
> >> >>> >>> failOnViolation="false">
> >> >>> >>>                <fileset dir="src" includes="**/*.java"/>
> >> >>> >>>                <formatter type="xml"
> >> >>> >>> toFile="checkstyle-result.xml"/>
> >> >>> >>>        </checkstyle>
> >> >>> >>> </target>
> >> >>> >>>
> >> >>> >>> And kaboom:
> >> >>> >>> Unable to create a Checker: cannot initialize module TreeWalker
> -
> >> >>> >>> Unable to instantiate org.hopto.defcon1.checks.TabOnlyForIndent
> >> >>> >>>
> >> >>> >>> I've tried compiling my check under java 6 and specifying target
> >> >>> >>> 1.4
> >> >>> >>> Tryed various ways of including in classpath
> >> >>> >>>
> >> >>> >>> Ideas, Thoughts, Recommendations?
> >> >>> >>>
> >> >>> >>> Thomas Suckow
> >> >>> >>>
> >> >>> >>>
> >> >>> >>>
> >> >>> >>>
> -------------------------------------------------------------------------
> >> >>> >>> This SF.Net email is sponsored by the Moblin Your Move
> Developer's
> >> >>> >>> challenge
> >> >>> >>> Build the coolest Linux based applications with Moblin SDK & win
> >> >>> >>> great
> >> >>> >>> prizes
> >> >>> >>> Grand prize is a trip for two to an Open Source event anywhere
> in
> >> >>> >>> the
> >> >>> >>> world
> >> >>> >>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> >> >>> >>> _______________________________________________
> >> >>> >>> Checkstyle-user mailing list
> >> >>> >>> [email protected]
> >> >>> >>> https://lists.sourceforge.net/lists/listinfo/checkstyle-user
> >> >>> >>
> >> >>> >>
> >> >>> >>
> >> >>> >> --
> >> >>> >> Bhavana Rehani
> >> >>> >>
> >> >>> >>
> >> >>> >>
> >> >>> >>
> -------------------------------------------------------------------------
> >> >>> >> This SF.Net email is sponsored by the Moblin Your Move
> Developer's
> >> >>> >> challenge
> >> >>> >> Build the coolest Linux based applications with Moblin SDK & win
> >> >>> >> great
> >> >>> >> prizes
> >> >>> >> Grand prize is a trip for two to an Open Source event anywhere in
> >> >>> >> the
> >> >>> >> world
> >> >>> >> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> >> >>> >> _______________________________________________
> >> >>> >> Checkstyle-user mailing list
> >> >>> >> [email protected]
> >> >>> >> https://lists.sourceforge.net/lists/listinfo/checkstyle-user
> >> >>> >>
> >> >>> >
> >> >>> >
> >> >>> >
> >> >>> >
> >> >>> >
> -------------------------------------------------------------------------
> >> >>> > This SF.Net email is sponsored by the Moblin Your Move Developer's
> >> >>> > challenge
> >> >>> > Build the coolest Linux based applications with Moblin SDK & win
> >> >>> > great
> >> >>> > prizes
> >> >>> > Grand prize is a trip for two to an Open Source event anywhere in
> >> >>> > the
> >> >>> > world
> >> >>> > http://moblin-contest.org/redirect.php?banner_id=100&url=/
> >> >>> > _______________________________________________
> >> >>> > Checkstyle-user mailing list
> >> >>> > [email protected]
> >> >>> > https://lists.sourceforge.net/lists/listinfo/checkstyle-user
> >> >>> >
> >> >>> >
> >> >>>
> >> >>>
> >> >>>
> -------------------------------------------------------------------------
> >> >>> This SF.Net email is sponsored by the Moblin Your Move Developer's
> >> >>> challenge
> >> >>> Build the coolest Linux based applications with Moblin SDK & win
> great
> >> >>> prizes
> >> >>> Grand prize is a trip for two to an Open Source event anywhere in
> the
> >> >>> world
> >> >>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> >> >>> _______________________________________________
> >> >>> Checkstyle-user mailing list
> >> >>> [email protected]
> >> >>> https://lists.sourceforge.net/lists/listinfo/checkstyle-user
> >> >>
> >> >>
> >> >>
> >> >>
> -------------------------------------------------------------------------
> >> >> This SF.Net email is sponsored by the Moblin Your Move Developer's
> >> >> challenge
> >> >> Build the coolest Linux based applications with Moblin SDK & win
> great
> >> >> prizes
> >> >> Grand prize is a trip for two to an Open Source event anywhere in the
> >> >> world
> >> >> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> >> >> _______________________________________________
> >> >> Checkstyle-user mailing list
> >> >> [email protected]
> >> >> https://lists.sourceforge.net/lists/listinfo/checkstyle-user
> >> >>
> >> >>
> >> >
> >>
> >>
> -------------------------------------------------------------------------
> >> This SF.Net email is sponsored by the Moblin Your Move Developer's
> >> challenge
> >> Build the coolest Linux based applications with Moblin SDK & win great
> >> prizes
> >> Grand prize is a trip for two to an Open Source event anywhere in the
> >> world
> >> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> >> _______________________________________________
> >> Checkstyle-user mailing list
> >> [email protected]
> >> https://lists.sourceforge.net/lists/listinfo/checkstyle-user
> >
> >
> > -------------------------------------------------------------------------
> > This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> > Build the coolest Linux based applications with Moblin SDK & win great
> > prizes
> > Grand prize is a trip for two to an Open Source event anywhere in the
> world
> > http://moblin-contest.org/redirect.php?banner_id=100&url=/
> > _______________________________________________
> > Checkstyle-user mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/checkstyle-user
> >
> >
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Checkstyle-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/checkstyle-user
>

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/

_______________________________________________
Checkstyle-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/checkstyle-user