On 11/02/2011, at 9:17 AM, ajfwil wrote:
>
> Hello Adam,
>
> Thanks for your response.
>
> I managed to get one step closer by replacing:
>
> rule('config/codenarc/MyCustomRuleScript.groovy')
>
> with
>
> def ruleScript = new File('config/codenarc/MyCustomRuleScript.groovy')
> rule('file:' + ruleScript.canonicalPath)
This relies on the user running Gradle from the project directory. If the user
runs Gradle from some other directory (eg using the -p flag), or uses the
daemon, the working directory won't be the project directory, and
ruleScript.canonicalPath will point somewhere else.
Here's another approach which may work better, given that CodeNarc expects
scripts to be visible on its classpath:
in your ruleset:
rule('myCustomRuleScript.groovy')
in your build.gradle
org.codenarc.ant.CodeNarcTask.class.classLoader.addURL(file('config/codenarc').toURI().toURL())
>
> Now I am having fun with this exception:
>
>
> * What went wrong:
> Execution failed for task ':codenarcMain'.
> Cause: org.codehaus.groovy.control.MultipleCompilationErrorsException:
> startup failed:
> script1000001.groovy: 2: unable to resolve class
> org.codenarc.source.SourceCode
> @ line 2, column 1.
> import org.codenarc.source.SourceCode
> ^
>
> script1000001.groovy: 1: unable to resolve class
> org.codenarc.rule.AbstractRule
> @ line 1, column 1.
> import org.codenarc.rule.AbstractRule
> ^
>
> 2 errors
Can you run gradle with -s and send in the resulting stack trace. It might have
some clues as to what's going wrong.
>
>
> Why org.codenarc.* is not on the classpath for this task is beyond me.
>
> At this point, I am almost through with codenarc.
>
> Regards,
> Adam Wilmore
>
> --
> View this message in context:
> http://gradle.1045684.n5.nabble.com/code-quality-plugin-location-of-custom-codenarc-rule-tp3373768p3380273.html
> Sent from the gradle-user mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
> http://xircles.codehaus.org/manage_email
>
>
--
Adam Murdoch
Gradle Developer
http://www.gradle.org
CTO, Gradle Inc. - Gradle Training, Support, Consulting
http://www.gradle.biz