如何编译和使用Ant罐子的Andr​​oid项目? [英] How to compile and jar an Android project using Ant?

查看:193
本文介绍了如何编译和使用Ant罐子的Andr​​oid项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让这整个蚁族构建系统的事情的句柄。我创建了一个build.xml文件是Android的使用命令本身给我: Android的更新项目-P

虽然这给了我一个模板build.xml文件,我想一对夫妇更多的选择。具体来说,我想能够 JAR 和/或编译我的项目; preferably带有一个版本号。

奖金问题:我怎样才能排除我的JAR构建文件。例如,我有我用来测试我的功能的一个活动,但我不希望被包含在最终的JAR。

这是Android已经给了我我的build.xml文件是Gisted href=\"https://gist.github.com/1888378\" rel=\"nofollow\">因为它是pretty长(主要是评论)。

修改:我还使用的IntelliJ所以没有具体的Eclipse,请


解决方案

  

具体来说,我希望能够JAR和/或编译我的项目; preferably一个版本号。


在的Andr​​oid,版本号是应用程序,而不是JAR文件。

话虽这么说,加入 JAR 的目标是将其加入你的的build.xml 文件对的事底部:

 <目标名称=罐子取决于=调试>
    <罐子
        destfile =斌/任何你想对呼叫the.jar
        BASEDIR =斌/班
    />
< /目标与GT;

然后,运行蚂蚁的jar 来编译和打包的JAR文件。

您将看到大多数的可重复使用的Andr​​oid组件的这种模式在我的GitHub区(请参阅 cwac- 回购)。


  

奖金问题:我怎样才能排除我的JAR构建文件。例如,我有我用来测试我的功能的一个活动,但我不希望被包含在最终的JAR。


使用不包括 excludesfile ,如的 JAR Ant任务文档

I'm trying to get a handle on this whole "Ant" buildsystem thing. I've created a build.xml that Android natively gives me by using the command: android update project -p . .

While this has given me a template build.xml file, I would like a couple more options. Specifically, I would like to be able to JAR and/or Compile my project; preferably with a version number.

Bonus Question: How can I exclude files from my JAR build. For example, I have one activity that I've used to test my functionality, but I don't want that to be included in the final JAR.

My build.xml file that Android has given me is Gisted here since it's pretty long (mostly comments).

EDIT: I'm also using IntelliJ so no Eclipse specifics, please!

解决方案

Specifically, I would like to be able to JAR and/or Compile my project; preferably with a version number.

In Android, version numbers are for apps, not JARs.

That being said, adding a jar target is a matter of adding this to your build.xml file towards the bottom:

<target name="jar" depends="debug">
    <jar
        destfile="bin/whatever-you-want-to-call-the.jar"
        basedir="bin/classes"
    />
</target>

Then, run ant jar to compile and package the JAR file.

You will see this pattern in most of the reusable Android components in my GitHub area (see the cwac- repos).

Bonus Question: How can I exclude files from my JAR build. For example, I have one activity that I've used to test my functionality, but I don't want that to be included in the final JAR.

Use excludes or excludesfile, as described in the jar Ant task documentation.

这篇关于如何编译和使用Ant罐子的Andr​​oid项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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