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

Document Maven execution ids in more detail #1308

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,59 @@ If you use it and encounter any problems, feel free to open issues on [github](h
To run diktat in **only-check** mode use command `$ mvn diktat:check@diktat`.
To run diktat in **autocorrect** mode use command `$ mvn diktat:fix@diktat`.

Requesting a specific _Maven_ `executionId` on the command line (the trailing
`diktat` in the above example) may be essential in these cases:

* In your `pom.xml`, you have multiple executions with different
configurations (e. g.: multiple rule sets):
<details>

```xml
<executions>

<execution>
<id>diktat-basic</id>
<configuration>
<diktatConfigFile>diktat-analysis.yml</diktatConfigFile>
</configuration>
</execution>

<execution>
<id>diktat-advanced</id>
<configuration>
<diktatConfigFile>diktat-analysis-advanced.yml</diktatConfigFile>
</configuration>
</execution>

</executions>
```
</details>
* Your YAML file with DiKTat rules has a non-default name and/or resides in a
non-default location:
<details>

```xml
<executions>
<execution>
<id>diktat</id>
<configuration>
<diktatConfigFile>/non/default/rule-set-file.yml</diktatConfigFile>
</configuration>
</execution>
</executions>
```
</details>

If you omit the `executionId`:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it always use default default settings, even if custom configuration is tied to the same execution phase?

Copy link
Contributor Author

@unix-junkie unix-junkie May 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whenever an execution is bound to a Maven phase, the executionId becomes irrelevant (and unnecessary).

Alternatively, if you don't bind a specific execution to a phase, the default executionId will be default-cli:

$ mvn diktat:check
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------< org.cqfn.diktat:diktat-examples-maven >----------------
[INFO] Building diktat-examples-maven 1.1.0-SNAPSHOT
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- diktat-maven-plugin:1.1.0:check (default-cli) @ diktat-examples-maven ---
[INFO] Running diKTat plugin with configuration file /home/alice/diktat-example-maven/foo.yml and inputs [/home/alice/diktat-example-maven/diktat-example
-maven/src/main/kotlin]
[WARNING] Not going to check indentation because there are tabs
[WARNING] You have enabled TRAILING_COMMA, but rule will remain inactive until you explicitly set configuration options. See [available-rules.md] for possible configuration options.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.467 s
[INFO] Finished at: 2022-05-26T19:05:49+03:00
[INFO] ------------------------------------------------------------------------

So, technically, you can create a custom configuration with such a default name, but I doubt Maven has any kind of contract for this behaviour. I mean, we probably shouldn't rely on this, as it may change (and break).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like default-cli is part of official maven documentation: https://maven.apache.org/guides/mini/guide-default-execution-ids.html


```console
$ mvn diktat:check
```

&mdash; the plug-in will use the default configuration and search for
`diktat-analysis.yml` file in the project directory (you can still customize the
rule sets by editing the YAML file).

## Run with Gradle using diktat-gradle-plugin
Requires a gradle version no lower than 5.3.

Expand Down