Eclipse:单个来源的多个项目 [英] Eclipse: multiple project from single source

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

问题描述

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



我有一个项目,我需要复制n次;每个新项目必须具有相同的源代码,但具有不同的资源(例如:图像,html文件,声音,pdf等)和不同的类/包名称。



我的项目不是一个标准的java,而是android + phonegap。
我有一个eclipse插件创建一个空的phonegap项目...也许有一种方法来修改这个插件来创建我的标准项目?



是吗可能?最好是还有一个系统将主要项目的源代码修改提交给孩子,但不是强制性的。



再次抱歉我的英语。



编辑:



对不起,如果我再次编辑这个问题,但是我真的找不到我的问题的解决方案。 / p>

我想将其整合到一个例子中,也许我可以解释我需要什么。



想象你已经开发和Android应用程序与eclipse和phonegap,一个足球队,例如巴塞罗那。



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



现在你必须复制这个应用程序更多的团队,很多团队。对于所有人,您必须创建一个新的电话交换项目,修改每个单独的文件,添加插件,添加资产....这些任务不能错误。



但是最大的问题是:如果您的代码只有一点点更新,那么您可以如何在10/20/50/100/1000项目中复制?



我还添加了android,phonegap和cordova标签,以便更具体地说明。



再次抱歉我的英文。



编辑N°2



我刚刚使用maven android插件一个礼拜,没有成功。
我需要的是集中式代码,我可以切换应用程序和packagename,图标和只是一些配置文件。



Android库不是解决方案,因为它不能导出资产文件。



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

$ b $从维护的角度来看,我不会考虑复制基于相同代码库的1000个项目,我将使用一个项目来管理客户特定的资源,并交换所需的在项目建设阶段的资源,换句话说,1个项目建1000个apks,而不是1000个项目来构建1000个apks。



根据你在问题中给出的细节,正确的方向(据我所见)解决这种使用场景(从单一源代码构建多个应用程序)是采用外部构建工具,如Ant或Maven主导构建过程(都提供精细控制的能力Ø n在整个构建生命周期期间的每一步,即编译,映射,包等),并且如果需要,可以编写用于批量构建的shell脚本。



我不是PhoneGap的乐趣,而是快速浏览其入门指南,基于我的理解,它只是另一个编程层堆栈在Android SDK之上,提供了通过主要使用Web编程语言(HTML,CSS,Javascript)编写移动应用程序的能力,应用程序仍然保留原始的项目框架,所以我不希望编写Ant / Maven脚本来构建PhoneGap应用程序。



一旦你成功构建了PhoneGap应用程序由Maven。您可以开始调查如何解决您的情况,我已经在StackOverflow中看到类似的情况,请查看此线程此线程为某些案例分析。您可以启动可行性研究概念证明项目。



我已经发布了一些示例代码,显示了Maven如何实现这一点,见下文。



示例项目目录结构:

  myApp / 
src /
res - 巴塞罗那/
assets-barcelona /
res-realmadrid /
assets-realmadrid /
... ...
project.properties
AndroidManifest。 xml
pom.xml

示例pom.xml文件:

 <个人资料> 
<个人资料>
< id> barcelona< / id>
<属性>
< 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>
<个人资料>
< id> realmadrid< / id>
<属性>
< 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>

要构建app-barcelona.apk,运行 mvn clean install -Pbarcelona

要构建app-realmadrid.apk,运行 mvn clean install -Prealmadrid

To构建其他1000个apache,编写shell脚本。



Android Maven插件提供了许多配置,可以让您在每个阶段/目标中精细控制构建过程。有关详细信息,请查看项目文档


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 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.

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.

EDIT:

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.

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

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

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.

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?

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

Sorry again for my english.

EDIT N°2

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

解决方案

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:

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

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.

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

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