Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Code style used for Liferay source (for Java)
Can we download code style used for fomatting portal source?
If no, How to replicate similar code style in our custom modules/custom code developed.
Thanks,
Nagendra
You mean something like this?
https://github.com/liferay/liferay-portal/blob/master/modules/util/source-formatter/src/main/resources/checkstyle.xml
Kind of, something in the lines of https://github.com/google/styleguide/blob/gh-pages/eclipse-java-google-style.xml.
BUT I cannot import checkstyle from the link your provided into Eclipse directly, right?
Preference > Check Style > Formatter > GoogleStyle ( as in above link)
How to use Liferay's checkstyle for custom code, any links would be helpful.
Thank you, that helps. I tried to run the same for my custom module project ( Gradle one though) - It was showing what are the issues w/ code. Does it really format? Do we need to manually fix the suggestions once formatter is run?
Is there a way we can make format source code in Eclipse windows machine (CTRL + SHIFT + F will auto format yourcode) makes equilavent of formatSource of gradle task.
I'm not sure to be honest. My experience has always been that code formatting is handled as part of a build time activity (if it matters). Personally, I use some conventions in my code that don't even follow the "Java" norm -- for example, I like to line up my braces in the left hand column. For projects where it was necessary to have all the code formatted a certain way, the build engineer integrated a step into the build process that would format the source.
I'm not sure if you have seen it, but I did find this reference in the docs:
https://dev.liferay.com/de/develop/reference/-/knowledge_base/7-0/source-formatter-plugin
.. I know it is a Maven plugin, but you can easily run maven goals from your Gradle projects as well. I didn't read it in detail though so I am not sure if perhaps it is the same thing you have already tried.
I know that some people also have a setting in their IDE that will auto format source when you hit save. You might want to disable all that stuff and try the build tools on their own to see if maybe one is overriding the other.
Powered by Liferay™