I am one of the developers of CodeNarc. 

(1) It looks like the problem is this code within CodeNarc for loading a
rule script file: 

        def inputStream = resourceFactory.getResource(path).inputStream 
        Class ruleClass 
        inputStream.withStream { input -> 
            GroovyClassLoader gcl = new GroovyClassLoader() 
            ruleClass = gcl.parseClass(input) 
        } 

I expect that the new GroovyClassLoader() should probably instead be: 
        new GroovyClassLoader(this.class.classLoader()) 

That may explain not being able to compile the rule script file. I will file
a bug report for that. 

(2) The file:xxx URL to the rule script file can also be a relative path (to
the current dir). So I suggest trying: 

        rule('file:config/codenarc/MyCustomRuleScript.groovy') 

instead of: 

        def ruleScript = new
File('config/codenarc/MyCustomRuleScript.groovy') 
        rule('file:' + ruleScript.canonicalPath) 
 


-- 
View this message in context: 
http://gradle.1045684.n5.nabble.com/code-quality-plugin-location-of-custom-codenarc-rule-tp3373768p3397917.html
Sent from the gradle-user mailing list archive at Nabble.com.

Reply via email to