-1

I am getting Audit errors as below, when try to run>mvn clean install` my cucumber-java project. It was running fine This happens all of sudden.

All errors seems to be coding related. But when I build and run tests through IntelliJ 2019.3 Ultimate all running fine.

[INFO] Starting audit...
[ERROR] C:\Repo\....\cucumber\stepdefinition\CommonStepdefs.java:4: 'cucumber.api.java.en.Given' should be separated from previous imports. [ImportOrder]
[ERROR] C:\Repo\...\cucumber\stepdefinition\CommonStepdefs.java:7: Wrong order for 'common.Utilities' import. [ImportOrder]
[ERROR] C:\Repo\...\src\test\java\common\Utilities.java:27: Line is longer than 120 characters (found 146). [LineLength]
[ERROR] C:\Repo\...\src\test\java\common\Utilities.java:46: Line is longer than 120 characters (found 153). [LineLength]
Audit done.

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  11.344 s
[INFO] Finished at: 2020-02-01T10:27:53+11:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.13:check (validate) on project automation: Failed during checkstyle execution: There are 48 checkstyle errors. -> [Help 1]

Maven configurations:

Maven home: C:\apache-maven-3.6.2\bin\..
Java version: 1.8.0_231, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk1.8.0_231\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

Below section was removed from POM

            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-checkstyle-plugin</artifactId>
                        <version>2.13</version>
                        <dependencies>
                            <dependency>
                                <groupId>com.puppycrawl.tools</groupId>
                                <artifactId>checkstyle</artifactId>
                                <version>6.17</version>
                            </dependency>
                            <dependency>
                                <groupId>com.abc.standards.java</groupId>
                                <artifactId>checkstyle</artifactId>
                                <version>1.4</version>
                            </dependency>
                        </dependencies>
                        <executions>
                            <execution>
                                <id>validate</id>
                                <phase>validate</phase>
                                <configuration>
                                    <configLocation>abc-java-checkstyle.xml</configLocation>
                                    <encoding>UTF-8</encoding>
                                    <consoleOutput>true</consoleOutput>
                                    <failsOnError>false</failsOnError>
                                    <failOnViolation>false</failOnViolation>
                                </configuration>
                                <goals>
                                    <goal>check</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
Shabar
  • 2,617
  • 11
  • 57
  • 98

2 Answers2

1

Looks like you're running checkstyle and getting checkstyle errors? You could either fix the errors in the log or not run checkstyle?

beirtipol
  • 823
  • 5
  • 21
  • @bertipol When you say `not run checkstyle` you mean to delete the plugin from `maven local repo` or skip whenever run the command as @Syed Affan Hamdani mentioned above? – Shabar Feb 01 '20 at 00:05
1

Clearly the error is from the styling plugin of maven. An easy fix can be:

mvn clean install -Dcheckstyle.skip

This should let the build run.

Nullish Byte
  • 354
  • 2
  • 10
  • A good solution would be to investigate why are your styles not in accordance with the plugin requirement. Intellij is quite easy to configure to style your code with a few keystrokes. – Nullish Byte Feb 01 '20 at 00:05
  • I removed `checkstyle` from POM and removed one `config` file from the project. Then it shows error: `[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.13:check (validate) on project automation: Failed during checkstyle execution: Unable to find suppressions file at location: /config/codestyle/checkstyle-suppressions.xml: Could not find resource '/config/codestyle/checkstyle-suppressions.xml'. -> [Help 1` – Shabar Feb 01 '20 at 00:38
  • Can you please post what exactly you removed from pom? – Nullish Byte Feb 01 '20 at 00:42
  • Added to the question. The other doubt should `maven codestyle`and `IntelliJ` formatting tally always – Shabar Feb 01 '20 at 02:23
  • Further, other thing is even after commented out those from `POM` when `mvn clean install` keep downloading this plugin. – Shabar Feb 01 '20 at 02:30
  • As a option I did this as specified by @SvenDöring in project level `POM` and it worked. https://stackoverflow.com/questions/32308188/disable-maven-checkstyle. I think the reason why download still happening becuase I have parent POM reference which has this plugin. – Shabar Feb 02 '20 at 01:22