revelc/formatter-maven-plugin

Reported "has not been previously formatted." while it was formatted.

Closed this issue · 3 comments

Describe the bug
After updating to version 2.18.0 (from version 2.17.1), build reports an error:

Failed to execute goal net.revelc.code.formatter:formatter-maven-plugin:2.18.0:validate (default-cli) on project operator-framework-core: File '/home/runner/work/java-operator-sdk/java-operator-sdk/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/informer/InformerEventSource.java' has not been previously formatted. Please format file (for example by invoking `mvn -f operator-framework-core net.revelc.code.formatter:formatter-maven-plugin:2.18.0:format`) and commit before running validation!

for command:
./mvnw ${MAVEN_ARGS} formatter:validate -Dconfigfile=$PWD/contributing/eclipse-google-style.xml --file pom.xml

see: operator-framework/java-operator-sdk#989
and failed action logs: https://github.com/java-operator-sdk/java-operator-sdk/runs/5387771172?check_suite_focus=true

The file was previously formatted, and by formatting it does not help.

Versions (OS, Maven, Java, and others, as appropriate):

  • Affected version(s) of this project: [e.g. 2.18.0]

Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537)
Maven home: /home/runner/.m2/wrapper/dists/apache-maven-3.8.4-bin/52ccbt68d252mdldqsfsn03jlf/apache-maven-3.8.4
Java version: 17.0.2, vendor: Eclipse Adoptium, runtime: /usr/lib/jvm/temurin-17-jdk-amd64
OS name: "linux", version: "5.11.0-1028-azure", arch: "amd64", family: "unix"

Thx!

@csviri We changed the default on stripping extra spaces from line endings. Can you try running a format, commit it and check that is the case? Then try verify after to see if you still have this issue?

Ahh, the problem was that I did not delete the caches before reformat, at least
./mvnw ${MAVEN_ARGS} clean formatter:format -Dconfigfile=$PWD/contributing/eclipse-google-style.xml --file pom.xml
Required that, otherwise it did not reformat the code (maybe there is a flag to force reformat I assume, just not aware of that, sorry)
So the problem is solved, thx!

@csviri Please keep an eye out on this issue as this seems strange that nothing helped. If you continue to see issue, let us know so we can look into this in more depth. If you see it again, possibly you can create a small sample or how you ran to cause the issue to occur.