Replies: 4 comments 7 replies
-
It's feasible to use maven to run the plugin in git commit hook. Haven't done so myself but is 9n my plan to do so at some point. Think you would just run the format cycle giving full gav if maven 3.8.7 or short for maven 3.9.0. Typically short like mvn formatter:format. If I get something before you do I'll document it here. In theory maven wrapper likely would be a better fit so you don't need to install it.
Sent from my Verizon, Samsung Galaxy smartphone
Get Outlook for Android<https://aka.ms/AAb9ysg>
…________________________________
From: Darshit Patel ***@***.***>
Sent: Tuesday, February 28, 2023 5:56:37 AM
To: revelc/formatter-maven-plugin ***@***.***>
Cc: Subscribed ***@***.***>
Subject: [revelc/formatter-maven-plugin] Any way to run the plugin without Maven or as a Standalone JAR? (Discussion #696)
My project(s), unfortunately, doesn't use Maven, but I'd like the flexibility that this plugin provides. Any way to run it as a standalone app which I can trigger from a Git pre-commit hook? Thanks!
—
Reply to this email directly, view it on GitHub<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Frevelc%2Fformatter-maven-plugin%2Fdiscussions%2F696&data=05%7C01%7C%7C58eba9b37f6b4aefe94408db197a7709%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638131785990670412%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=i0gGzUxErkJtxw9vV9%2By1wozzCte%2FiU03qF4VJjx2VI%3D&reserved=0>, or unsubscribe<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAAHODI5IN3QYPV7VWF5OUSTWZXKWLANCNFSM6AAAAAAVKR7LOM&data=05%7C01%7C%7C58eba9b37f6b4aefe94408db197a7709%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638131785990826658%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=G69MCda0yn8QupmhFy7l%2Bv5%2Be7lsNkkewKzqIPTmVEA%3D&reserved=0>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Please try again with latest and show stack. We are a small team and don't really support anything but latest. Once confirmed can look at making it not require maven project. Thanks.
Sent from my Verizon, Samsung Galaxy smartphone
Get Outlook for Android<https://aka.ms/AAb9ysg>
…________________________________
From: Darshit Patel ***@***.***>
Sent: Friday, March 3, 2023 3:46:16 AM
To: revelc/formatter-maven-plugin ***@***.***>
Cc: Jeremy Landis ***@***.***>; Comment ***@***.***>
Subject: Re: [revelc/formatter-maven-plugin] Any way to run the plugin without Maven or as a Standalone JAR? (Discussion #696)
This doesn't work because it requires my project to be a maven project with a POM to even run the goal.
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.114 s
[INFO] Finished at: 2023-03-03T13:33:48+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal net.revelc.code.formatter:formatter-maven-plugin:2.16.0:format (default-cli): Goal requires a project to execute but there is no POM in this directory (<path_to_project>). Please verify you invoked Maven from the correct directory. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProjectException
—
Reply to this email directly, view it on GitHub<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Frevelc%2Fformatter-maven-plugin%2Fdiscussions%2F696%23discussioncomment-5187794&data=05%7C01%7C%7Cb742a655dbd840f5805708db1bc3c0c8%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638134299785751241%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=bkO3K1Fsmo%2FoP1%2BR5f9fcfdU7eRBoteiaksg7jcjusA%3D&reserved=0>, or unsubscribe<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAAHODI4422CCZCTJOA6RS3LW2GVVRANCNFSM6AAAAAAVKR7LOM&data=05%7C01%7C%7Cb742a655dbd840f5805708db1bc3c0c8%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638134299785751241%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=OfIKu%2BhE%2B4m%2BnL6U10p8wXTchXuX0hy8jSw9fTToEEQ%3D&reserved=0>.
You are receiving this because you commented.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
We don't really have JDK 11 installed to run with 2.17.x versions of the libraries. I am using the latest 2.16.0 JAR. Not much of a stack trace to share, unfortunately. I use the install-file goal to load the plugin into the the local maven repository, and then simply run the command. Here's the trace: mvn org.apache.maven.plugins:maven-install-plugin:2.5.2:install-file -Dfile=.git/hooks/formatter-maven-plugin-2.16.0.jar
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.5.2:install-file (default-cli) @ standalone-pom ---
[INFO] Installing /path_to_plugin/formatter-maven-plugin-2.16.0.jar to /path_to_m2/.m2/repository/net/revelc/code/formatter/formatter-maven-plugin/2.16.0/formatter-maven-plugin-2.16.0.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.814 s
[INFO] Finished at: 2023-03-08T10:46:25+05:30
[INFO] ------------------------------------------------------------------------
mvn net.revelc.code.formatter:formatter-maven-plugin:2.16.0:format -DconfigFile=/path_to_formatter/format.xml -DsourceDirectory=/path_to_source/src/ -Dincludes=/path_to_single_file_test/Test.java
+ mvn net.revelc.code.formatter:formatter-maven-plugin:2.16.0:format -DconfigFile=/path_to_formatter/format.xml -DsourceDirectory=/path_to_source/src/ -Dincludes=/path_to_single_file_test/Test.java
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.117 s
[INFO] Finished at: 2023-03-08T10:46:26+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal net.revelc.code.formatter:formatter-maven-plugin:2.16.0:format (default-cli): Goal requires a project to execute but there is no POM in this directory (/current_directory_which_has_projects_but_no_POM). Please verify you invoked Maven from the correct directory. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProjectException The above is generated when the git hook is run. I have hardcoded the values of the I'd be happy to contribute if you require help in making the plugin non-maven based. Would be great to learn, and contribute to something new! |
Beta Was this translation helpful? Give feedback.
-
@darshitpp before this plugin I used to use a shell function that invokes eclipse directly eformat(){
eclipse -nosplash -data /home/sol/eclipse-workspace -vm java -application org.eclipse.jdt.core.JavaCodeFormatter -verbose -config /git/org.eclipse.jdt.core.prefs $@
} Then I just run |
Beta Was this translation helpful? Give feedback.
-
My project(s), unfortunately, doesn't use Maven, but I'd like the flexibility that this plugin provides. Any way to run it as a standalone app which I can trigger from a Git pre-commit hook? Thanks!
Beta Was this translation helpful? Give feedback.
All reactions