gleclaire / codenarc-maven-plugin

Maven Mojo Plug-In to generate reports based on the CodeNarc Analyzer
https://gleclaire.github.io/codenarc-maven-plugin/
Apache License 2.0
7 stars 17 forks source link

No way to provide codenarc.properties #14

Open php-coder opened 8 years ago

php-coder commented 8 years ago

I've created codenarc.properties and put it to src/test/resources/codenarc.properties but the plugin doesn't pick it up:

     [java] 2016-07-27 17:28:15,310 PropertiesFileRuleSetConfigurer [main] INFO - RuleSet configuration properties file [codenarc.properties] not found.

The same with src/main/resources. How to configure codenarc with codenarc.properties?

php-coder commented 8 years ago

The only one workaround for that is to use @SuppressWarnings but it requires to modify many files :-((

chrismair commented 8 years ago

Is that" codenarc.properties" definitely on the classpath when running CodeNarc?

See http://codenarc.sourceforge.net/codenarc-configuring-rules.html#Configuring_Rules_Using_a_Properties_File

You can try setting the "codenarc.properties.file" system property to the path or URL of the properties file. Maybe try setting it to an absolute file path with a "file:" prefix just to make sure it "can" get picked up.

php-coder commented 8 years ago

Is that" codenarc.properties" definitely on the classpath when running CodeNarc?

I tried to put it to a different places but it didn't work because when plugin constructs classpath it includes only some artifacts and log4j config: https://github.com/gleclaire/codenarc-maven-plugin/blob/36a22bd524ef8aa0c55abde708f8999ba1e06d64/src/main/groovy/org/codehaus/mojo/codenarc/CodeNarcMojo.groovy#L351-L378

chrismair commented 8 years ago

Setting "codenarc.properties.file" system property with a "file:" + absolute path should work.

gleclaire commented 8 years ago

let me know if that works. In a future release we look at adding that to the plugin to pass it through.

php-coder commented 7 years ago

@gleclaire

let me know if that works

No, it doesn't work:

$ mvn -Dcodenarc.properties.file=file:$PWD/src/main/config/codenarc.properties codenarc:codenarc
...
[INFO] totalPriority3Violations is 2
...
$ cat $PWD/src/main/config/codenarc.properties 
UnnecessaryReturnKeyword.enabled = false
chrismair commented 7 years ago

I think that file:$PWD is being treated as a relative path. For me, $PATH is "/home/Chris". And I think that file:/home/Chris is not the proper way to specify an absolute path.

https://en.wikipedia.org/wiki/File_URI_scheme

So I think what you'd need is file://$PWD

php-coder commented 7 years ago

@chrismair No, it doesn't work either. Does it work for you?