有没有办法让ADT项目目录布局更加灵活?
我在 android-developers group 上问了这个问题 但没有得到任何回应,所以我想我应该在这里尝试一下。
ADT eclipse 插件似乎对 Android 项目应该如何构建有一个非常严格的想法 - per http://developer.android.com/guide/developing/eclipse-adt.html,它需要在项目的根级别有 AndroidManifest.xml
文件,加上顶层的 res
、assets
、gen
和 src
文件夹,等等。
我想知道是否可以让插件在其识别的布局上更加灵活。特别是,我一直在使用(基于 scala 的)simple 的构建插件-build-tool,它期望项目以更像 Maven 的方式布局,如下所示:(
src/
main/
AndroidManifest.xml
assets/
res/
scala/
java/
test/
resources
<files to include in test jar here>
scala/
<test Scala sources>
java/
<test Java sources>
请参阅 简单构建工具文档)。
这是我在基于 maven 的 java 开发中习惯的布局。然而,当我在 ADT 中加载类似的项目时,我收到了很多关于缺少 AndroidManifest.xml
、缺少 res
目录等的抱怨。这些东西都存在,只是它们不在 ADT 期望的位置。
我不一定需要使用 ADT 来构建我的项目,但我想使用它(和 Eclipse)进行编辑。谁能告诉我是否可以使其在用于查找各种 Android 相关资源的目录中更加灵活?
另外,谁能告诉我ADT插件是否开源?我似乎无法在任何地方找到其源代码的链接。
(作为说明,我也一直在尝试让 sbt 以 ADT 喜欢的方式做事,这可能是可行的,但看起来非常乏味。)
I asked this question on the android-developers group but didn't get any response, so I thought I'd try here.
The ADT eclipse plugin seems to have a pretty rigid idea of how an Android project should be structured - per http://developer.android.com/guide/developing/eclipse-adt.html, it needs to have the AndroidManifest.xml
file at the root level of the project, plus res
, assets
, gen
and src
folders at the top level, and so on.
I'm wondering if it's possible to get the plugin to be a little more flexible with the layout it recognizes. In particular, I've been using a build plugin for the (scala-based) simple-build-tool, which expects projects to be laid out in a more Maven-like fashion, like so:
src/
main/
AndroidManifest.xml
assets/
res/
scala/
java/
test/
resources
<files to include in test jar here>
scala/
<test Scala sources>
java/
<test Java sources>
(see the simple-build-tool docs).
This is a layout I'm used to from maven-based java development. When I load a project like it up in ADT, though, I get a lot of complaints about a missing AndroidManifest.xml
, a missing res
directory, and so on. These things are all present, they just aren't where ADT expects them to be.
I don't necessarily need to use ADT to build my project, but I'd like to use it (and Eclipse) for editing. Can anybody tell me whether it's possible to make it more flexible in the directories it uses to find various Android-related resources?
Also, can anyone tell me whether the ADT plugin is open-source? I can't seem to find a link to its source code anywhere.
(As a note, I've also been trying to wrangle sbt
to just do things in a way that ADT likes, and it's probably possible to do but it seems very tedious.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是 在哪里可以找到 r3 0.94 的 ADT 源,但找不到最新的
Here's is where you can find the ADT source for r3 0.94, couldn't find the latest though
我不相信你可以改变Android项目结构并让ADT理解它。即使使用基于 Ant 的命令行构建,这样做也会“非常乏味”——您必须制作自己的各种 Android Ant 任务副本,修改它们以适应(并希望底层构建工具允许你想要什么),然后在 Android SDK 更新时永远维护它们。
如果您将
main/
视为 Android 项目,那么您的结构实际上相当接近 Android 期望。如果你能说服 sbt 允许 src/ 代替 java/ ,并且 sbt 不会抱怨关于编译后在main/
中得到的bin/
和gen/
,你可能会让它工作。I do not believe you can change the Android project structure and have ADT understand it. It would be "very tedious" to do that even with the Ant-based command-line builds -- you'd have to make your own copy of the various Android Ant tasks, modify them to suit (and hope the underlying build tools allow what you want), then maintain them forever in the face of Android SDK updates.
Your structure is actually fairly close to the Android expectation, if you consider
main/
to be the Android project. If you can convincesbt
to allowsrc/
instead ofjava/
there, and ifsbt
won't complain about the resultingbin/
andgen/
you will wind up with inmain/
after a compile, you might get it to work.据我所知,ADT 需要这些文件夹名称,但有一个解决方法:您可以在 Eclipse 中创建“链接文件夹”。它们与 Unix 中的符号链接类似,但存储在 Eclipse .project 文件中而不是文件系统中,因此它们仅对 Eclipse 可见。
您可以通过在 Eclipse 中右键单击项目的根目录,然后选择“创建新文件夹”来创建一个文件夹。单击“高级”并选择创建链接文件夹的选项。然后输入您想要链接到的位置。您可以在开始时使用 PROJECT_LOC 指定项目目录,因此对于您的示例,您将键入 PROJECT_LOC/src/main/res 作为要链接到的文件夹,并使用自动生成的名称“res”作为创建的文件夹。
As far as I can tell, ADT requires those folder names, but there is a workaround: you can create "linked folders" in Eclipse. These are similar to symbolic links in Unix, but are stored in the Eclipse .project file instead of the filesystem, so they are only visible to Eclipse.
You can create one by right clicking in Eclipse the root of the project, and then selecting "Create New Folder". Click on "Advanced" and select the option to create a linked folder. Then type in where you want it to link to. You can use PROJECT_LOC at the begining to specify the project directory, so for your example you would type PROJECT_LOC/src/main/res as the folder to link to, and use the automatically generated name of "res" for the created folder.