Organize Java Imports programmatically

自闭症网瘾萝莉.ら 提交于 2020-01-06 08:09:39

问题


I have written a custom build script for my android app. I included some "easy" preprocessing, so I can define comments like

//#ifdef something
... CODE
//#endif

and get rid of the Code part if configured so. The Problem is, that after preprocessing I don't need some modules anymore, so I leave them out. What remains is the import statement for that module which bites me, if I want to build the app finally. I'm searching for a way within my preprocessing, to organize the java Imports inside my script after preprocessing happens. Any Solution without the need for additional "clicks" is very welcome.


回答1:


Sometimes you're really need preprocessor (quite rare). But you could actually achieve same goal with right build process.

Anyway back to the question you could use next technique:

//#ifdef something
... IMPORTS
//#endif



回答2:


take a look at http://code.google.com/p/java-comment-preprocessor/ p.s. example of usage for one of my cases http://code.google.com/p/java-comment-preprocessor/wiki/ExampleOfUsageForJ2ME



来源:https://stackoverflow.com/questions/12182399/organize-java-imports-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!