月蚀:从单一来源多项目 [英] Eclipse: multiple project from single source

查看:173
本文介绍了月蚀:从单一来源多项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

起初,我不得不说,我是不是很好的英文,所以我很抱歉,如果我能很好地解释我的意思:)

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 :)

我有一个项目,我需要重复n次;每一个新的项目必须具有相同的源$ C ​​$ C,但不同的资源(例如:图像,HTML文件,声音,PDF等),不同的类/包名

I have one project that i need to replicate n times; every new project must have the same source code, but different resources (ex: images, html files, sounds, pdf, etc) and different class/packages names.

我的项目是不是一个标准的Java,但是Android + PhoneGap的。 我有一个Eclipse插件,创建一个空的PhoneGap项目...也许有一种方法来修改这个插件创建我的标准项目?

my project is not a standard java, but android + phonegap. I have an eclipse plugin that create an empty phonegap project... maybe there is a way to modify this plugin to create my standard project?

这可能吗?最好是也有一个系统来提交源变化形成的主要项目,以孩子的,但它不是强制性的。

Is it possible? The best is to have also a system to commit source changes form the main project to the childs, but it's not mandatory.

再次对不起,我的英语水平。

Sorry again for my english.

编辑:

很抱歉,如果我重新编辑了这个问题,但我真的无法找到我的问题的解决方案。

Sorry if i edit again this question, but really i can't find a solution for my problem.

我想用一个例子整合,也许我可以解释一下我所需要的。

I want to integrate it with an example, maybe i can explain what i need.

想像你已经开发和Android应用程序与Eclipse和PhoneGap的,对于足球队,例如巴塞罗那。

imagine you have developed and android application with eclipse and phonegap, for a football team, example Barcelona.

该应用程序主要是HTML + jquerymobile,但你已经修改了活动,Android清单,增加了一些PhoneGap的插件,一些媒体资源,等等。

The app mainly is in html + jquerymobile, but you have modified the activity, the android manifest, added some phonegap plugins, some media resource, etc.

现在你必须重复这个程序为更多的球队,很多球队。对于每个人,你必须创建一个新的PhoneGap项目,修改每一个文件,添加插件,增加资产....这些任务不能没有错误。

Now you have to replicate this app for more teams, a lot of teams. For everyone you have to create a new phonegap project, modify every single file, add the plugins, add the assets.... those tasks can't be error free.

不过,很大的问题是:如果你只有一点点的更新在code,你如何能复制过来10/20/50/100/1000项目

But the very big problem is: if you have only a little update in your code, how you can replicate it over 10/20/50/100/1000 projects?

我添加的Andr​​oid,的PhoneGap和科尔多瓦标签也到了后更加具体。

I've added android, phonegap and cordova tags too to the post to be more specific.

再次对不起,我的英语水平。

Sorry again for my english.

修改N°2

我只是打与Maven Android插件了一个多星期了,但没有成功。 我需要的是集中式的code,我可以switcch应用程序和包名称,图标,只是很少的配置文件。

I just played with maven android plugin for over a week now, without success. What i need is centralized code where i can switcch the app and packagename, the icons, and just little configuration files.

Android的库不是一个解决方案,因为它无法导出资产的文件。

Android libs is not a solution, because it can't export assets files.

我开始赏金为这个问题寻找一个详细的解答......请帮助:(

I started a bounty for this question looking for a detailed answer... please help :(

推荐答案

从维护的角度看,我不会考虑在同一code碱基复制1000项目基地。我会用一个单一的项目管理客户的特定资源和交换在项目建设阶段所需的资源。换句话说,一期工程建设1000的apk,不是1000项目,以建立1000的apk。

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.

是采用像蚂蚁或外部构建工具Maven的主导构建过程(包括提供精细控制,即编译,地塞米松,包装等过程中完整的构建生命周期的能力,对每一个步骤),也许写的shell脚本,如果需要批量建造。

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.

我并不是PhoneGap的的乐趣,但有一个快速浏览一下通过获得入门指南,基我的理解,它只是一个在Android SDK的顶级编程层堆叠,以提供主要利用网页编程语言(HTML,CSS,JavaScript)的编写手机应用程序的能力,应用程序仍然保持原有的项目框架,所以我不希望比较麻烦,写的Ant / Maven的脚本构建PhoneGap的应用程序。

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.

一旦你已经成功地构建了PhoneGap的应用程序通过Maven的。你可以开始研究如何解决你的情况,我以前见过的StackOverflow的类似那种情景,检查出的这个线程和<一href="http://stackoverflow.com/questions/9699485/skinning-android-app-with-maven-build-profiles">this线程一些案例研究。你可以从概念项目的证明了可行性研究。

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.

我已经张贴了一些示例code显示Maven的是如何做到这一点,见下文。

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

示例项目目录结构:

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

样品pom.xml文件:

Sample pom.xml file:

<profiles>
  <profile>
    <id>barcelona</id>
    <properties>
      <app.package.name>com.company.app.barcelona</app.package.name>
      <app.res.dir>${project.basedir}/res-barcelona</app.res.dir>
      <app.assets.dir>${project.basedir}/assets-barcelona</app.assets.dir>
    </properties>
  </profile>
  <profile>
    <id>realmadrid</id>
    <properties>
      <app.package.name>com.company.app.realmadrid</app.package.name>
      <app.res.dir>${project.basedir}/res-realmadrid</app.res.dir>
      <app.assets.dir>${project.basedir}/assets-realmadrid</app.assets.dir>
    </properties>
  </profile>
  ... ...
</profiles>

....

<plugins>
  <plugin>
    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
    <artifactId>android-maven-plugin</artifactId>
    <version>3.1.1</version>
    <extensions>true</extensions>
    <configuration>
      <sdk>
        <platform>13</platform>
      </sdk>
      <undeployBeforeDeploy>true</undeployBeforeDeploy>
      <renameManifestPackage>${app.package.name}</renameManifestPackage>
      <resourceDirectory>${app.res.dir}</resourceDirectory>
      <assetsDirectory>${app.assets.dir}</assetsDirectory>
    </configuration>
  </plugin>
  ... ...
</plugins>

要构建的应用程序,barcelona.apk,运行 MVN全新安装-Pbarcelona
要构建应用程序,realmadrid.apk,运行 MVN全新安装 - prealmadrid
要建立其他1000的apk,编写shell脚本。

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插件提供了许多配置,让您更加细致地控制构建过程在每一个单相/目标。请查看项目文档的全部细节

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

这篇关于月蚀:从单一来源多项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆