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.
ajay try this post, there are some step-by-step instructions included here.
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.
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
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.
Related
I'm using SchemaCrawler v14.21.02 programmatically in my Java project to generate schema diagrams. I would like to generate a diagram with a reduced set of columns, as done by adding the option -infolevel=standard -command=brief when running SchemaCrawler from the command line.
My question is: how do I pass this option when running SchemaCrawler programmatically?
I have found the SchemaInfoLevel and SchemaInfoLevelBuilder classes in package schemacrawler.schemacrawler, but the -command=brief option eludes me.
Please take a look at the example code provided as part of the SchemaCrawler project, at ExecutableExample.java. I have highlighted the relevant parts of the code, if you click on the link.
Sualeh Fatehi, SchemaCrawler
I used IntelliJ to write Cucumber feature files i.e., *.feature files and corresponding step definition files in Java within the IDE. The user experience is great and IDE opens up its IntelliSense showing all valid options for which the step definitions exist. If I write a new step in a scenario or a step that has no corresponding step definition exist already in the Java file, it highlights the step with different colour and similarly if regex don't match. I get informed by this highlighting that something has to be written for this step in Java file or the step is wrong and will not execute.
I need the same functionality on a non developer machine i.e., on a Business Analyst or Product owner machine, where there is no IDE installed but just an editor like Notepad++. I know about the Notepad++ plug-in for Gherkin but it doesn't highlight the step for which step definition is missing in the *.java step definition file. Please suggest any editor or free IDE that has similar plug-in available.
Thanks,
Shany
In case you use JIRA to manage your stories then you can use a JIRA plugin which has Auto-complete, parameter highlight functionality. There are other similar plugins you can browse.
I want to edit the following preferences using the java code
Eclipse-Preferences-General-Workspace-Text file encoding-Others-UTF-8
Run dialog-Run configurations-Common tab-encoding-Others-UTF-8
Run dialog-Run configurations-Arguments tab-write '-Dfile.encoding=UTF-8' in the 'VM Arguments' text box
Add '-Dfile.encoding=UTF-8' in 'eclipse.ini' file in the Eclipse folder
I need to have a method that adjusts the 4 things when it's called so I want to adjust the preferences above using java not manualyy .. how can I do that ?
You need to learn how to do Eclipse Plugin Development and then getting at the various property pages and manipulating them will require you to get familiar with the Eclipse RCP, and you will need to know how to query the workspace etc. Look at the book Eclipse Plug-ins
When using the standard api, for example the collections library, the predictive text options windows also shows the comments on class/methods.
however when I do the same style comments on my own code - the open project I am working on (code completion works correctly, just no comments appear), and then reference it later. These comments are not displayed. I get the correct code completion options, just none of the associated comments/documentation. They are not in jar, they are source files, that are built using maven into a war file.
Is there a setting I need to enable in eclipse, or do I need to set up javadoc or something ?
How embarassing, you to have to specify double asterix at the begininng of comment to create a javdoc comment
/**
* read the documentation before asking questions on stackoverlow
*/
If the class is part of a jar you need to associate the javadoc jar or path. You can right click on the jar in eclipse and specify the path in the properties dialog.
I have the following problem. I have something like 300 Eclipse Plugins. Now, as part of an ant script I want to read all MANIFEST.MF files and then look for the execution environment string.
Bundle-RequiredExecutionEnvironment: J2SE-1.4
Now, this string has several possible values. I want to create a report that lists the execution environment for each plug-in. That part is not really a problem as I can use some kind of regexp to obtain it.
My problem is that I want also to create some kind of summary for tracking changes at a glance, something like:
JS2E-1.4: 50 Plugins
JS2E-1.5: 150 Plugins
JS2E-1.6: 74 Plugins
Anyone has some suggestions on how could I go around this?
EDIT: Reason for using ANT is that I want to integrate it with a nightly build script
I would definitively go for hard-coded Ant task and decompose the problem in two tasks:
the first task takes a jar file and outputs a plugin-info.xml file that contains various infos, like the environment
the second task parses all these xml files and creates an XML summary report
This will of course generate (n+1) XML files for n plugins and some will find this way too much.
The nice end effect with that approach is that you can generate either detail or aggregated reports very easily (with some XSLT magic.) or even graphs.
If i were to do it myself, i probably would just write a perl script.
If it has to be done from Ant, i would write an Ant Task to do it.
I would suggest just printing each executable environment on System.out and then post process with "|sort| uniq -c".
You can use the math task from the ant-contrib project
I had to do it, I'd probably go for some shell script or custom code