Cannot compile unless code is first committed.
See original GitHub issueOn our project, we just added the plugin and formatted our entire codebase (which worked great, BTW).
But when I try to compile our project I’m now getting the following error:
[ERROR] Failed to execute goal com.cosium.code:maven-git-code-format:1.36:validate-code-format (validate-code-format) on project ktc-services: /Users/mcpierce/Repositories/know-the-costs/ktc-services/src/main/java/com/outpatientservicesllc/persistence/service/WorkQueueService.java is not correctly formatted ! -> [Help 1]
Even though our entire codebase was formatted by the plugin. If I git commit the code, without changing it, the build runs fine.
I should also add that I’m using the google-java-format plugin for IntellJ to format code as I go, so the code being saved as pre-formatted correctly.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Is it acceptable to commit code that doesn't compile?
I think this would largely depend on whether you're working alone or with a team, and if the team agrees if this is...
Read more >Git Compile Error [duplicate] - Stack Overflow
You have a so-called conflict (file in the working copy and file in the repository have been edited independently from each other, and...
Read more >How to Fix and Compile Errors
If you can't figure the error out, try commenting out the code you have most recently written until it goes away. Then, reintroduce...
Read more >5 Debugging Tips for a Solution that Won't Compile
One of the first things a developer is asked to do when starting on a new project is to download the code and...
Read more >Fix the top 10 most common compile time errors in Java
If code doesn't compile, the program is entirely unable to execute. As such, it's imperative to fix compile time errors in Java as...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@reda-alaoui Okay, understood. We’ll adjust our system to use a profile for CI that runs the check at build time. Thank you!
I think I understand more clearly your issue.
I bet you are using
mvn install
to perform your build.install
triggers theverify
phase.By default,
validate-code-format
is bound to mavenverify
phase. The purpose ofvalidate-code-format
is to make the CI fail the build if it find badly formatted files in the git repo. Badly formatted files could be committed/pushed because of a developer that commit without ever running maven (i.e. no installed hooks) or a ‘malicious’ developer that manually removed the hook. The CI is then the last defense against this.Disabling
validate-code-format
will only remove this guard. The pre-commit formatting will keep working without any issue.If you want to keep
validate-code-format
for the CI while being able to runmvn install
locally despite badly formatted files, you have to move it into a maven profile that would be enabled by your CI only.