Reputation: 19948
Is there a command line way to invoke the java code formatting feature of Eclipse? Also, is there a way to configure the way it formats the code via command line?
The goal is to have a common code formatting mechanism for the entire team and automate that step prior to check in of code.
Upvotes: 6
Views: 2615
Reputation: 12718
Have a look at the JDT application org.eclipse.jdt.core.JavaCodeFormatter
.
I haven't tried this out, but you should be able to start eclipse as
eclipse -application org.eclipse.jdt.core.JavaCodeFormatter -all...other...options
See org.eclipse.jdt.core.formatter.CodeFormatterApplication
for the available options.
Upvotes: 1
Reputation: 4238
ajay try this post, there are some step-by-step instructions included here.
Upvotes: 6
Reputation: 12553
I know of no way from command line. Have you looked at Save Actions?
Preferences => Java => Editor => Save Actions let you format all code whenever it's saved. If everyone uses Eclipse, you can distribute your standard formatting XML file and use Save Actions to take the manual step out of formatting.
The downside, of course, is that everyone has to use the same project settings.
Upvotes: -1
Reputation: 471
You can create specific format xml and whole team can use that Windows/Preference/java/formatter/Configure project specific setting , here we can edit and create customized format xml .Others can import this xml . Not very sure about command line
Upvotes: -1