Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradle plug-in: unable to specify inputs if Groovy DSL is used #1422

Closed
0x6675636b796f75676974687562 opened this issue Jul 4, 2022 · 1 comment · Fixed by #1428
Closed
Assignees
Labels
bug Something isn't working plugins Plugins for build systems to allow them to run diktat

Comments

@0x6675636b796f75676974687562
Copy link
Member

Try to build the example project which uses the Groovy DSL. The build will fail:

C:\diktat\examples\gradle-groovy-dsl>gradle build                                                                                                        
FAILURE: Build failed with an exception.

* Where:
Build file 'C:\diktat\examples\gradle-groovy-dsl\build.gradle' line: 9

* What went wrong:
A problem occurred evaluating root project 'gradle-groovy-dsl'.
> No signature of method: build_8ip68wiz5ht9rnwfbccz91le2.diktat() is applicable for argument types: (build_8ip68wiz5ht9rnwfbccz91le2$_run_closure2) values: [build_8ip68wiz5ht9rnwfbccz91le2$_run_closure2@408bf572]
  Possible solutions: getAt(java.lang.String), with(groovy.lang.Closure), tap(groovy.lang.Closure)

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s

Apparently, the Groovy DSL doesn't understand this Kotlin signature:

    /**
     * Configure input files for diktat task
     *
     * @param action configuration lambda for `PatternFilterable`
     */
    fun inputs(action: PatternFilterable.() -> Unit) {
        action.invoke(patternSet)
    }

An empty inputs { } block is ok:

diktat {
    inputs {
    }
    reporter = "plain"
    debug = false
}

Any attempt to specify the include or exclude rules within the block will lead to a failure.

Environment information

  • diktat version: 1.2.1
  • build tool (maven/gradle): Gradle (6.8 and 7.4)
  • how is diktat run (CLI, plugin, etc.): gradle plug-in
  • kotlin version: 1.7.0
  • operating system: Windows
@petertrr
Copy link
Member

petertrr commented Jul 4, 2022

It can be used in Groovy with it parameter, for reasons described in this answer. We should update docs and check why our functional tests haven't captured this

@petertrr petertrr added the plugins Plugins for build systems to allow them to run diktat label Jul 4, 2022
petertrr added a commit that referenced this issue Jul 8, 2022
### What's done:
* Update build.gradle in examples
* Add functional test for Groovy DSL with explicit inputs
* Fix docs for `diktatExtension.output`: reporter treats any non-empty string as a file name, there are no special values
* Remove `dependsOn` relation between `test` and `functionalTest`, use `shouldRunAfter` instead

This pull request closes #1422
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working plugins Plugins for build systems to allow them to run diktat
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants