Java 在 Eclipse 中导入 ant build.xml

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3880350/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 06:17:54  来源:igfitidea点击:

Importing ant build.xml in Eclipse

javaandroideclipseant

提问by Suresh

I have an android project that uses ant to build, is it possible to import this ant project in eclipse IDE?

我有一个使用 ant 构建的 android 项目,是否可以在 eclipse IDE 中导入这个 ant 项目?

update : There is an option to create project using ant build.xmlin eclipse File->New->Project->Java->Java project from existing ant Buildfile. and if the build.xml file is selected it show error Specified buildfile does not contain a javac task

更新:有一个选项可以build.xml在 eclipse File->New->Project->Java->Java 项目中使用 ant 从现有的 ant Buildfile创建项目。如果选择了 build.xml 文件,则会显示错误Specified buildfile does not contain a javac task

I guess javac is declared in this task

我猜 javac 是在这个任务中声明的

<taskdef name="setup"
classname="com.android.ant.SetupTask"
classpathref="android.antlibs"/>

回答by alvinsj

Try the following method, got it work for me.

试试下面的方法,让它对我有用。

  1. Make sure you have ant installed
  2. Create new project> android project > choose from exisiting source (your project source)
  3. Download ant-contrib.jar, then unzip it and put the jar file to where you prefer.
  4. Add the ant-contrib jar file to Eclipse: Window>Preferences>Ant>Runtime>Global Entries>Add external jar
  5. Configure your build.properties. (copy and edit build.properties.example to build.properties)
  6. Now open build.xml in editor in Eclipse then hit Run
  7. Add the built jar files in your project properties, Project Properties>Java Build Path>Add JAR
  1. 确保你安装了 ant
  2. 创建新项目> android 项目> 从现有源(您的项目源)中选择
  3. 下载ant-contrib.jar,然后解压缩并将 jar 文件放在您喜欢的位置。
  4. 将 ant-contrib jar 文件添加到 Eclipse:Window>Preferences>Ant>Runtime>Global Entries>Add external jar
  5. 配置您的 build.properties。(复制并编辑 build.properties.example 到 build.properties)
  6. 现在在 Eclipse 的编辑器中打开 build.xml 然后点击运行
  7. 在您的项目属性中添加构建的 jar 文件,Project Properties>Java Build Path>Add JAR

回答by Tejas

just simply import "existing projects into workspace" and import your project. then open 'ant' window from windows-->show/view --> ant

只需简单地将“现有项目导入工作区”并导入您的项目。然后从 windows-->show/view-->ant 打开“ant”窗口

drag-drop your ant file from project explorer to the ant window.

将您的 ant 文件从项目资源管理器拖放到 ant 窗口。

click to expand, and select the target you want to run ->right click -> run as ANT

单击展开,然后选择要运行的目标 -> 右键单击​​ -> 作为 ANT 运行

your setup should be ok with this.

你的设置应该没问题。

回答by mmdemirbas

From this link:

这个链接

  1. Open Eclipse, select File> New> Project
  2. Select "Java Project from Existing Ant Build File"
  3. Show your build file and write a project name
  1. 打开 Eclipse,选择文件>新建>项目
  2. 选择“来自现有 Ant 构建文件的 Java 项目
  3. 显示您的构建文件并写入项目名称