You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@sedona.apache.org by "jbampton (via GitHub)" <gi...@apache.org> on 2025/07/29 06:18:23 UTC
[PR] [GH-1643] Add `mvn spotless:apply` as a pre-commit hook [sedona]
jbampton opened a new pull request, #2188:
URL: https://github.com/apache/sedona/pull/2188
## Did you read the Contributor Guide?
- Yes, I have read the [Contributor Rules](https://sedona.apache.org/latest/community/rule/) and [Contributor Development Guide](https://sedona.apache.org/latest/community/develop/)
## Is this PR related to a ticket?
- Yes, and the PR name follows the format `[GH-XXX] my subject`. Closes #1643
## What changes were proposed in this PR?
Added our first "Java" based hook to run `mvn spotless:apply`
## How was this patch tested?
Tested with Java 11.
Tested first with `pre-commit run --all-files` and also then with `git commit`
Tried failing the hook with messy Java and saw the correct reformat and the hook failed.
## Did this PR include necessary documentation updates?
- No, this PR does not affect any public API so no need to change the documentation.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [GH-1643] Add `mvn spotless:apply` as a pre-commit hook [sedona]
Posted by "petern48 (via GitHub)" <gi...@apache.org>.
petern48 commented on code in PR #2188:
URL: https://github.com/apache/sedona/pull/2188#discussion_r2240639224
##########
.pre-commit-config.yaml:
##########
@@ -40,6 +40,19 @@ repos:
files: \.(js|ya?ml)$
language: node
additional_dependencies: ['prettier@3.6.2']
+ - id: maven-spotless-apply
+ name: maven spotless apply
+ description: automatically formats Java and Scala code using mvn spotless:apply.
+ entry: mvn spotless:apply
+ language: system # Indicates that the 'entry' command should be run directly as a system command.
+ types: [java, scala] # Specifies that this hook should run on Java and Scala files.
+ pass_filenames:
+ false # Crucial: tells pre-commit NOT to pass filenames as arguments to 'mvn spotless:apply'.
+ # Spotless typically scans the whole project based on its configuration.
+ always_run:
+ true # Ensures this hook runs even if no Java files are changed.
+ # This is useful for spotless:apply which might affect files not staged.
Review Comment:
Is it just to format java files even when they aren't staged?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [GH-1643] Add `mvn spotless:apply` as a pre-commit hook [sedona]
Posted by "petern48 (via GitHub)" <gi...@apache.org>.
petern48 commented on code in PR #2188:
URL: https://github.com/apache/sedona/pull/2188#discussion_r2240680768
##########
.pre-commit-config.yaml:
##########
@@ -40,6 +40,19 @@ repos:
files: \.(js|ya?ml)$
language: node
additional_dependencies: ['prettier@3.6.2']
+ - id: maven-spotless-apply
+ name: maven spotless apply
+ description: automatically formats Java and Scala code using mvn spotless:apply.
+ entry: mvn spotless:apply
+ language: system # Indicates that the 'entry' command should be run directly as a system command.
+ types: [java, scala] # Specifies that this hook should run on Java and Scala files.
+ pass_filenames:
+ false # Crucial: tells pre-commit NOT to pass filenames as arguments to 'mvn spotless:apply'.
+ # Spotless typically scans the whole project based on its configuration.
+ always_run:
+ true # Ensures this hook runs even if no Java files are changed.
+ # This is useful for spotless:apply which might affect files not staged.
Review Comment:
It depends since most of the development is in Java (at least for now). I still don't quite see how this is particularly useful for Java devs. Does it really make a difference if `mvn spotless:apply` doesn't run on your unstaged java files? Won't it still run whenever you do finally decide to commit it? That's the only time it matters imo.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [GH-1643] Add `mvn spotless:apply` as a pre-commit hook [sedona]
Posted by "jbampton (via GitHub)" <gi...@apache.org>.
jbampton commented on PR #2188:
URL: https://github.com/apache/sedona/pull/2188#issuecomment-3130891878
Seems that 4 versions of Java are already installed by default in the Ubuntu 24 image as seen below and that is why this "system" or Java hook has passed on GitHub Actions. And a version of Maven is installed as well. But when running this hook on your local machine you do need Java and most likely Java 11. I did try running this hook at first with Java 21 and the hook failed with a Java code exception. The result lead to using Java 11 successfully.
https://github.com/actions/runner-images/blob/ubuntu24/20250720.1/images/ubuntu/Ubuntu2404-Readme.md#java
https://github.com/actions/runner-images/blob/ubuntu24/20250720.1/images/ubuntu/Ubuntu2404-Readme.md#project-management
<img width="826" height="500" alt="Screenshot from 2025-07-29 16-29-13" src="https://github.com/user-attachments/assets/da30873d-282e-4ca4-857f-9930c51e5cdf" />
<img width="2550" height="1171" alt="Screenshot from 2025-07-29 16-27-28" src="https://github.com/user-attachments/assets/a08236c2-aac5-4c1b-8f3b-d9c581aac48b" />
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [GH-1643] Add `mvn spotless:apply` as a pre-commit hook [sedona]
Posted by "petern48 (via GitHub)" <gi...@apache.org>.
petern48 commented on code in PR #2188:
URL: https://github.com/apache/sedona/pull/2188#discussion_r2240632228
##########
.pre-commit-config.yaml:
##########
@@ -40,6 +40,19 @@ repos:
files: \.(js|ya?ml)$
language: node
additional_dependencies: ['prettier@3.6.2']
+ - id: maven-spotless-apply
+ name: maven spotless apply
+ description: automatically formats Java and Scala code using mvn spotless:apply.
+ entry: mvn spotless:apply
+ language: system # Indicates that the 'entry' command should be run directly as a system command.
+ types: [java, scala] # Specifies that this hook should run on Java and Scala files.
+ pass_filenames:
+ false # Crucial: tells pre-commit NOT to pass filenames as arguments to 'mvn spotless:apply'.
+ # Spotless typically scans the whole project based on its configuration.
+ always_run:
+ true # Ensures this hook runs even if no Java files are changed.
+ # This is useful for spotless:apply which might affect files not staged.
Review Comment:
@jbampton Could you elaborate on what you meant by this? I'm getting some noticeable delays (up to ~2-3 seconds) on my commits now even when I'm purely working in Python and no Java.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [GH-1643] Add `mvn spotless:apply` as a pre-commit hook [sedona]
Posted by "jiayuasu (via GitHub)" <gi...@apache.org>.
jiayuasu commented on code in PR #2188:
URL: https://github.com/apache/sedona/pull/2188#discussion_r2240654537
##########
.pre-commit-config.yaml:
##########
@@ -40,6 +40,19 @@ repos:
files: \.(js|ya?ml)$
language: node
additional_dependencies: ['prettier@3.6.2']
+ - id: maven-spotless-apply
+ name: maven spotless apply
+ description: automatically formats Java and Scala code using mvn spotless:apply.
+ entry: mvn spotless:apply
+ language: system # Indicates that the 'entry' command should be run directly as a system command.
+ types: [java, scala] # Specifies that this hook should run on Java and Scala files.
+ pass_filenames:
+ false # Crucial: tells pre-commit NOT to pass filenames as arguments to 'mvn spotless:apply'.
+ # Spotless typically scans the whole project based on its configuration.
+ always_run:
+ true # Ensures this hook runs even if no Java files are changed.
+ # This is useful for spotless:apply which might affect files not staged.
Review Comment:
Yes. I think this is the goal but yeah, I forgot this will affect the python development. Do you think we should remove it?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [GH-1643] Add `mvn spotless:apply` as a pre-commit hook [sedona]
Posted by "jiayuasu (via GitHub)" <gi...@apache.org>.
jiayuasu merged PR #2188:
URL: https://github.com/apache/sedona/pull/2188
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org