Eclipse: multiple project from single source

后端 未结 5 1514
春和景丽
春和景丽 2020-12-10 16:16

at first i have to say that i\'m not very good with english, so i\'m sorry if i can explain very well what i mean :)

I have one project that i need to replicate n ti

5条回答
  •  执念已碎
    2020-12-10 17:02

    From maintenance perspective, I would not consider replicating 1000 projects base on same code base. I would use a single project manage customer-specific resources and swap the required resource at project build phase. In another word, 1 project to build 1000 apks, not 1000 projects to build 1000 apks.

    Based on the details you have given in the question, the right direction (as far as I can see) to solve this kind of use scenario (build multiple applications from single source base) is to adopt external build tools like Ant or Maven dominate build process (both provide the ability to fine-control on every single step i.e. compile, dex, package and etc. during the complete build life cycle) and perhaps write shell script for batch build if needed.

    I am not a fun of PhoneGap but have a quick look through its Get Started Guide, base on my understanding, it is just another programming layer stack on top of Android SDK, to provide ability to write mobile app by mainly using web programming language (HTML, CSS, Javascript), the application still keep the original project skeleton so I would not expect much trouble to write Ant/Maven script to build the PhoneGap app.

    Once you have successfully built your PhoneGap app by Maven. You can start investigating how to solve you scenario, I have seen similar sort of scenario before in StackOverflow, check out this thread and this thread for some case study. You can start a Proof of Concept project for feasibility study.

    I've posted some sample code shows how Maven achieve this, see below.

    Sample Project directory structure:

    myApp/
      src/
      res-barcelona/
      assets-barcelona/
      res-realmadrid/
      assets-realmadrid/
      ... ...
      project.properties
      AndroidManifest.xml
      pom.xml
    

    Sample pom.xml file:

    
      
        barcelona
        
          com.company.app.barcelona
          ${project.basedir}/res-barcelona
          ${project.basedir}/assets-barcelona
        
      
      
        realmadrid
        
          com.company.app.realmadrid
          ${project.basedir}/res-realmadrid
          ${project.basedir}/assets-realmadrid
        
      
      ... ...
    
    
    ....
    
    
      
        com.jayway.maven.plugins.android.generation2
        android-maven-plugin
        3.1.1
        true
        
          
            13
          
          true
          ${app.package.name}
          ${app.res.dir}
          ${app.assets.dir}
        
      
      ... ...
    
    

    To build app-barcelona.apk, run mvn clean install -Pbarcelona.
    To build app-realmadrid.apk, run mvn clean install -Prealmadrid.
    To build other 1000 apks, write shell script.

    Android Maven Plugin provides many configuration let you fine-control build process at every single phase/goal. Check out Project Documentation for full details.

提交回复
热议问题