简体   繁体   English

如何重构和移动子包以及最外层的包?

[英]How to refactor and move sub-packages along with the outermost package?

There is an outermost package and then a number of many sub- and sub-sub packages in an existing open-source project. 在现有的开源项目中,有一个最外层的程序包,然后是许多子程序和子子程序包。

Eg: com.example.android.outer and then com.example.android.outer.inner1; 例如: com.example.android.outer ,然后com.example.android.outer.inner1; com.example.android.outer.inner2 ... com.example.android.outer.inner2 ...

I am trying to move the whole outermost & all its sub-packages down the hierarchy, from that project to another new one. 我试图将整个最外层及其所有子包从该项目移到另一个项目。 There are like few hundred files and more than 50 sub and sub-sub packages. 大约有几百个文件,超过50个子和子子包。 Following are the issues that I am encountering: 以下是我遇到的问题:

1) If I am refactoring(or copying) the outermost package, only the files which are in outermost package are getting moved. 1)如果我要重构(或复制)最外层软件包,则仅移动最外层软件包中的文件。

2) If I am just copying the files, then there are issues with the .R import. 2)如果我只是复制文件,则.R导入存在问题。 The R file that was generated in the previous project remains( import com.example.android.outer.R; ) and gives errors in the new project. 先前项目中生成的R文件将保留(import com.example.android.outer.R;),并在新项目中给出错误。 Since I have 100's of files, manually removing the import line from each of them it is a pain. 由于我有100多个文件,因此从每个文件中手动删除导入行是很痛苦的。

How can I refactor the package and its sub and sub-sub ... packages down the hierarchy at once? 如何立即在层次结构中重构软件包及其子和sub-sub ...软件包? I tried to search but could find any help. 我尝试搜索,但可以找到任何帮助。 Thanks in advance. 提前致谢。

Move (refactor) the packages one by one. 一次移动(重构)软件包。 It is a one-time task, you can do it in less than one hour, just go ahead with that. 这是一项一次性的任务,您可以在不到一个小时的时间内完成它,只需继续进行即可。

Honestly, Eclipse will take care about everything, you don't have to worry. 老实说,Eclipse会处理所有事情,您不必担心。 You would waste more time with finding and fixing bugs if you are copying and trying to fix it manually, compared to the time you spend on manually moving packages. 与手动移动软件包相比,如果您要手动复制和修复它,则将浪费更多的时间查找和修复错误。

Last but not least, you'll lose your source control history with copying. 最后但并非最不重要的一点是,您将失去复制的源代码管理历史记录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 JDK9模块如何帮助“封装范围的子包”? - How will JDK9 modules help for 'package-scoped sub-packages'? 在Eclipse中,如何将一个包和所有子包导出为jar? - In Eclipse, how can I export a package and all sub-packages as a jar? 在Spring中,如何在包(包括子包)中的每个bean id前面加上常量字符串? - How do I prefix each bean id in a package (inc. sub-packages) with a constant string in Spring? log4j:记录包,但不包括其子包 - log4j: logging a package, but excluding its sub-packages 为什么子包不能看到包私有类? - Why can't sub-packages see package private classes? module-info.java'opens'语句可以包含一个包和所有子包吗? - Can a module-info.java 'opens' statement include a package and all sub-packages? 如何使用import java。*来使用'java'包下的所有子包? - What About using import java.* for using all sub-packages under the package 'java'? 在Java中,包同时包含类和子包是否被认为是不好的做法? - Is it considered bad practice in java for a package to contain both classes and sub-packages? ArchUnit 规则检查 class 是否在同一个 package 或子包中访问? - ArchUnit rule to check if class is accessed within same package or sub-packages? 子包之间的Java私有类 - Java private classes between sub-packages
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM