I have the following projects under Eclipse:
我在Eclipse下有以下项目:
A (Android Project) => B (Java Project) => C (Java Project)
A(Android项目)=> B(Java项目)=> C(Java项目)
where symbol "=>" indicates that the project to the left of the symbol is dependent on the project to the right of the symbol and the build path of project B always include project C under all circumstances.
其中符号“=>”表示符号左侧的项目依赖于符号右侧的项目,项目B的构建路径在所有情况下始终包含项目C.
If I include both project B and C under the build path of project A, A runs without problems.
如果我在项目A的构建路径下包含项目B和C,则A运行没有问题。
However, if I include project B without including project C under the build path of project A, A crashes when run.
但是,如果我在项目A的构建路径下包含项目B而不包括项目C,则A在运行时崩溃。
Is there an alternative to solving the above issue without including project C under the build path of project A since there is no direct dependency between A and C?
是否有替代解决上述问题而不在项目A的构建路径下包含项目C,因为A和C之间没有直接的依赖关系?
Note that C should not be converted to an android project so as to allow other java projects (not indicated here) that depend on it to run as well.
请注意,C不应该转换为Android项目,以便允许依赖它的其他java项目(此处未指出)也可以运行。
3 个解决方案
#1
0
Librairy from project C should be exported by project B.
项目C的Librairy应由项目B导出。
http://www.informit.com/articles/article.aspx?p=367962 section 6.1.4
http://www.informit.com/articles/article.aspx?p=367962第6.1.4节
Regards, Stéphane
此致,Stéphane
#2
0
No you can't solve the base problem although there are a lot of workarounds.
虽然有很多解决方法,但是你无法解决基本问题。
Everything has to be included otherwise you will get classnotfound exceptions. You can always build Project C to a JAR file and include that in your lib path and then you won't have to have the dependency on the project. Build Project B to, to a Jar file and you can develop your android project without any references to any eclipse Java projects.
必须包含所有内容,否则您将获得classnotfound异常。您始终可以将Project C构建为JAR文件并将其包含在lib路径中,然后您就不必具有项目依赖性。将项目B构建到Jar文件,您可以开发您的android项目,而无需任何eclipse Java项目的引用。
Think of it this way if you download a jar file for example Farmors super lib far.jar and my lib have other dependencies you have to fetch them to and there dependencies and so on recursively thats why we have advance tools like maven to handle all this dependance mess.
如果您下载一个jar文件,例如Farmors super lib far.jar,并且我的lib有其他依赖项,您必须将它们提取到依赖项等依赖性等等,这就是这样想的,这就是为什么我们有像maven这样的高级工具来处理所有这些依赖混乱。
#3
0
I think that the best solution in your case is to move your project to use tools like maven or ivy. Those kind of tools helps you to manage this kind of problems that are dependency management. Of course, those tools provide many more features, for example, improving the process of build, filtering resources, deploying automatically artifacts, create reports, etc
我认为,在您的情况下,最好的解决方案是将您的项目移动到使用maven或ivy等工具。这些工具可以帮助您管理这种依赖管理的问题。当然,这些工具提供了更多功能,例如,改进构建过程,过滤资源,自动部署工件,创建报告等
I work with maven a lot and I try to explain how I try to solve the problem in your case. First of all, you could mavenize all of our projects (including the Android one) and define the relationship between your projects (A depends on B, who depends on C), only, setting the most important project for maven projects, the 'pom.xml' file.
我和maven一起工作很多,我试着解释一下如何在你的情况下解决问题。首先,你可以对我们所有的项目(包括Android项目)进行整理,并定义你的项目之间的关系(A取决于B,谁依赖于C),只为maven项目设置最重要的项目,'pom .xml'文件。
In [this link][3] you could read about Introduction to dependency mechanism. The idea is simple: you need to define the organization of what requires every project, that can be artifacts or libraries around the net. Maven will download everything and will build every project. In your case, probably you will need to build the C project, that automatically (once it is configured correctly) would be used by the B project, and so on by A.
在[this link] [3]中,您可以阅读有关依赖机制的介绍。这个想法很简单:你需要定义每个项目需要的组织,可以是网络周围的工件或库。 Maven将下载所有内容并构建每个项目。在您的情况下,您可能需要构建C项目,B项目将自动使用(一旦配置正确),依此类推。
Pay attention to understand how dependencies are managed, because it's the key.
注意理解依赖关系的管理方式,因为它是关键。
By the way, in the Android project probably you will need to use the [Android maven plugin][4] that will fit perfectly for your purposes.
顺便说一句,在Android项目中,您可能需要使用适合您目的的[Android maven插件] [4]。
Good luck!
祝你好运!
#1
0
Librairy from project C should be exported by project B.
项目C的Librairy应由项目B导出。
http://www.informit.com/articles/article.aspx?p=367962 section 6.1.4
http://www.informit.com/articles/article.aspx?p=367962第6.1.4节
Regards, Stéphane
此致,Stéphane
#2
0
No you can't solve the base problem although there are a lot of workarounds.
虽然有很多解决方法,但是你无法解决基本问题。
Everything has to be included otherwise you will get classnotfound exceptions. You can always build Project C to a JAR file and include that in your lib path and then you won't have to have the dependency on the project. Build Project B to, to a Jar file and you can develop your android project without any references to any eclipse Java projects.
必须包含所有内容,否则您将获得classnotfound异常。您始终可以将Project C构建为JAR文件并将其包含在lib路径中,然后您就不必具有项目依赖性。将项目B构建到Jar文件,您可以开发您的android项目,而无需任何eclipse Java项目的引用。
Think of it this way if you download a jar file for example Farmors super lib far.jar and my lib have other dependencies you have to fetch them to and there dependencies and so on recursively thats why we have advance tools like maven to handle all this dependance mess.
如果您下载一个jar文件,例如Farmors super lib far.jar,并且我的lib有其他依赖项,您必须将它们提取到依赖项等依赖性等等,这就是这样想的,这就是为什么我们有像maven这样的高级工具来处理所有这些依赖混乱。
#3
0
I think that the best solution in your case is to move your project to use tools like maven or ivy. Those kind of tools helps you to manage this kind of problems that are dependency management. Of course, those tools provide many more features, for example, improving the process of build, filtering resources, deploying automatically artifacts, create reports, etc
我认为,在您的情况下,最好的解决方案是将您的项目移动到使用maven或ivy等工具。这些工具可以帮助您管理这种依赖管理的问题。当然,这些工具提供了更多功能,例如,改进构建过程,过滤资源,自动部署工件,创建报告等
I work with maven a lot and I try to explain how I try to solve the problem in your case. First of all, you could mavenize all of our projects (including the Android one) and define the relationship between your projects (A depends on B, who depends on C), only, setting the most important project for maven projects, the 'pom.xml' file.
我和maven一起工作很多,我试着解释一下如何在你的情况下解决问题。首先,你可以对我们所有的项目(包括Android项目)进行整理,并定义你的项目之间的关系(A取决于B,谁依赖于C),只为maven项目设置最重要的项目,'pom .xml'文件。
In [this link][3] you could read about Introduction to dependency mechanism. The idea is simple: you need to define the organization of what requires every project, that can be artifacts or libraries around the net. Maven will download everything and will build every project. In your case, probably you will need to build the C project, that automatically (once it is configured correctly) would be used by the B project, and so on by A.
在[this link] [3]中,您可以阅读有关依赖机制的介绍。这个想法很简单:你需要定义每个项目需要的组织,可以是网络周围的工件或库。 Maven将下载所有内容并构建每个项目。在您的情况下,您可能需要构建C项目,B项目将自动使用(一旦配置正确),依此类推。
Pay attention to understand how dependencies are managed, because it's the key.
注意理解依赖关系的管理方式,因为它是关键。
By the way, in the Android project probably you will need to use the [Android maven plugin][4] that will fit perfectly for your purposes.
顺便说一句,在Android项目中,您可能需要使用适合您目的的[Android maven插件] [4]。
Good luck!
祝你好运!