Kindly advise on the best way of removing unwanted imports from code which are brought about by mvn after making a PR without closing the PR and repeating the work?
Assume you are using eclipse IDE you can try any of the following methods if you haven’t tried out.
Go to the line of unused import, press Ctrl + 1, which is an Eclipse shortcut of a quick fix. This will show a drop-down menu to fix this error and select “remove unused imports.” It will remove that import statement from Java file the unfortunate part is it can’t remove multiple unused imports.
To remove multiple imports in a single click use the "Organize Imports which is a feature of Eclipse IDE to remove multiple or all unused imports statement. on your Menu, Select Source–> Organize Imports. This will remove all unused imports from that Java file.
To remove all unused import statement from Java file is Ctrl + Shift + O, which is a shortcut of organized import in Eclipse, and you can say Eclipse shortcut to remove all unused import statement from the Java file.
@jwnasambu thanks, really helpful. @gracebish if you are using Intellij then go to Settings > Editor > General >Auto Import and check the Optimize imports on the fly checkbox or you can use Ctrl + Shift + O.
Problem while organize imports: openmrs-api/src/main/java/org/openmrs/Concept.java contains ambiguous references. User interaction required. Please advise.
@gracebish have you tried Ctrl + Shift + O? because this shortcut also
- organize existing imports
- remove unneeded imports
- add new required imports
- add unambiguous imports on the fly
@jwnasambu what do you feel?
@gracebish does this help?
@herbert24 it has caused more robust problems than those that were existing before
Okay, @gracebish can you share what you see after entering Ctrl + Shift + O and before it?
@gracebish I can see that you are having trouble in importing and somehow an extra line is added each time. I feel import settings are causing this problem, Can you check the setting once as explained here under Configure Java Import Order. You can also run
mvn clean install, as Maven plugin will re-order imports for you.
@medhavi my IDE is well configured
Does it help?
okay, I think we are definitely missing something important .
@gracebish which IDE are you using?
@dkayiwa I am using eclipse