简体   繁体   English

Git版本控制和图书馆项目

[英]Git Versioning and Library Projects

Please read both 1 and 2. If you are not an Android dev you could still help because this is a versioning problem as well. 请阅读1和2.如果您不是Android开发人员,您仍然可以提供帮助,因为这也是版本控制问题。

Here is the situation: 情况如下:

I have inherited an android project created in IntelliJ and am currently importing it into Eclipse. 我继承了一个在IntelliJ中创建的android项目,目前正在将它导入Eclipse。 But many obstacles lay in the way... 但是路上有很多障碍......

  1. In IntelliJ Android Libraries can be sub-directories (children) of the project, however, in Eclipse you can only select Android Libraries that are in the current workspace (Siblings). 在IntelliJ中,Android库可以是项目的子目录(子项),但是,在Eclipse中,您只能选择当前工作区中的Android库(兄弟姐妹)。 Is it possible to select a child directory? 是否可以选择子目录?
  2. If #1 cannot be fixed then how can I approach the following: I have an Android Library project that contains many reusable components (static utils). 如果#1无法修复,那么我该如何处理以下内容:我有一个Android库项目,其中包含许多可重用的组件(静态工具)。 Assume the Android Library is a sibling directory to the project. 假设Android Library是项目的兄弟目录。 I have a version 1 application that uses the Android Library. 我有一个使用Android库的版本1应用程序。 I now create a version 2 that uses the Android Library but I also update the libraries API (change some methods). 我现在创建一个使用Android库的版本2,但我也更新库API(更改一些方法)。 Version 2 is in development and version 1 is being maintained. 版本2正在开发中,版本1正在维护中。 When Eclipse cleans the projects the Android Library is no longer compatible with version 1 since the API has changed. 当Eclipse清理项目时,由于API已更改,Android库不再与版本1兼容。

The project inherited was build in IntelliJ and the Android Library was a git repo and git submodules. 继承的项目是在IntelliJ中构建的,Android库是一个git repo和git子模块。 Thus the reference was to a git commit and the repo could be externally updated. 因此,引用是git提交,repo可以在外部更新。 I essentially need to get versioning with Android Libraries working (I do not care about using or not using git submodules). 我基本上需要使用Android库进行版本控制(我不关心使用或不使用git子模块)。 Anybody have a solution? 有人有解决方案吗?

The Answer for 答案

In IntelliJ Android Libraries can be sub-directories (children) of the project, however, in Eclipse you can only select Android Libraries that are in the current workspace (Siblings). 在IntelliJ中,Android库可以是项目的子目录(子项),但是,在Eclipse中,您只能选择当前工作区中的Android库(兄弟姐妹)。 Is it possible to select a child directory? 是否可以选择子目录?

Yes it is possible to reference a child directory(Android Library Project) in your Application project. 是的,可以在Application项目中引用子目录(Android Library Project)。

Step 1: Add the library project's directory inside your Application project's root directory. 步骤1:在Application项目的根目录中添加库项目的目录。

Step2: Import this sub directory as a project in eclipse. Step2:将此子目录导入为eclipse中的项目。

File -> Import , Under Android select Existing Android Code Into Workspace , For Root Directory browse to the root directory of your app project directory. File - > Import ,在Android选择Existing Android Code Into Workspace ,对于Root Directory浏览到应用项目目录的根目录。 In the list of Projects you get your own project plus the library project ie the sub directory. 在项目列表中,您可以获得自己的项目以及库项目,即子目录。 Make sure that only the library project is selected and not your App . 确保仅选择了库项目,而不是您的应用程序 Hit Finish . 命中Finish

Step 3: Reference to this library project. 第3步:参考此库项目。

Go to your Application project's Android properties and add this library project in the library section . 转到Application项目的Android properties并在library section添加此库项目。

And you're done. 而且你已经完成了。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM