just started with the codenarc plugin for grails - seems to be great! But now I try to configure a dynamic report title like this: "code quality report for ${appName}"

Unfortunately, it seems that the appName property is not available at the right time - I just get a null value.

Any ideas?

PS: using Grails 2.0.4 with ":codenarc:0.19"

有帮助吗?

解决方案

appName is by default bound in BuildConfig.groovy but is not available to the configuration closure for codenarc. I am yet to become cognizant of an absolute reasoning behind that behavior, unless anyone here throws some light on it. But you can very well read application.properties directly to get the appName as below:

codenarc.reports = {
    def props = new Properties()
    new File("application.properties").withInputStream {props.load(it)}

    MyHtmlReport('html') {
        outputFile = "${props['app.name']} - CodeNarc-Report.html"
        title = "${props['app.name']} - Sample Report"
    }
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top