How do I manage git submodule subprojects in Eclipse?

后端 未结 5 980
旧巷少年郎
旧巷少年郎 2021-01-01 16:26

(In case it matters, these are Java Android projects)

Project A is a library project.

Project B depends on A

相关标签:
5条回答
  • 2021-01-01 17:00

    I have a similar situation. Import B as existing (android) project into eclipse after you git clone it. Make sure project A is initialized and updated (via git).

    Now, do file->import existing project (android if A is an Android project) and go to where the submodule A project is inside of your project B and add it.

    Now you have two separate projects in eclipse. You can change both projects, and it will all be under Project B, because that is where both projects are located.

    0 讨论(0)
  • 2021-01-01 17:02

    Eclipse Mars Milestone 5 (4.5.0M5) has Multiproject-support. You only need to import "Existing Project" from Subfolder.

    0 讨论(0)
  • 2021-01-01 17:16

    Since this is specifically for Android, have you looked into Android libraries?

    In my case I have a free (B) and a paid for (C) version of my app. Both share a common code base (A). In eclipse I make A an Android library and both B and C use this library and all 3 are separate git repos. With this setup, changes I make in A are automatically available in B and C and I only need to maintain one code base for each project. No fancy build scripts/configs.

    I think this sort of simplicity is what you were after? Apologies if I have misunderstood the question.

    0 讨论(0)
  • 2021-01-01 17:17

    Just use a project build system to track your dependencies (that is what they are good for).

    I would you suggest to use gradle (preferable IMHO but check which one fits better on your context) or maven, both can handle subprojects pretty well and can generate the eclipse configuration for you.

    0 讨论(0)
  • 2021-01-01 17:20

    I'm not sure if i got your setup right:

    Project A : src
    + /projecta.jar (binary of project A)

    Project B : /src
    + /lib/Project A/src as submodule
    + /lib/projecta.jar (binary of project A)

    ..now you change A-A' and compile it, wanting to test it before pushing/commiting, right?
    is it ok for you to just have the jar in B, or do you need the source within project B updated to A'?

    first case: have an ant file compile in project A and deploy it to B as well that ant file is not part of project a, its just a local workaround (its useful to have it in the ant view of eclipse)

    Sketch:

    <property name="projectb.libdir" value="..."/> set appropriate place in project B
    
    <javac fromdir="./src" todir="./build" ...><fileset ... /></javac>
    
    <jar /> from build to projecta.jar
    
    <copy /> projecta.jar to projectb.libdir
    

    Alternative is to create a .jardesc in eclipse, so you can run "create jar" on rightclick.

    is that what you wanted to do?

    0 讨论(0)
提交回复
热议问题