Importing ant build.xml in Eclipse
Asked Answered
S

3

70

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

update : There is an option to create project using ant build.xml in 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

I guess javac is declared in this task

<taskdef name="setup"
classname="com.android.ant.SetupTask"
classpathref="android.antlibs"/>
Slave answered 7/10, 2010 at 9:33 Comment(4)
You cannot import or you want a simpler import way than the File>Import>Folder/System way?Coppery
I would like to import/create the project in eclipse with the same settings that are specified in build.xml.Slave
That's impossible. You can define much more complicated logic in a build.xml than eclipse could ever supportBenito
the error is because the android sdk is missing in the classpath or the classpath is not set for android.antlibs. Depending on the build.xml, you often pass a parameter with it that tells ant where to find the properties file in which the path to the android sdk is set.Overstride
B
114

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
Biology answered 21/12, 2012 at 12:5 Comment(4)
Dear downvoter, please explain my fault to help me to improve my answer.Biology
Is the error related to 3 steps defined above? As you see, the steps are very straightforward and I am not getting any errors.Biology
The link continues to be broken. Please consider fixing it.Fence
Broken link fixed.Biology
M
12

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

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

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

your setup should be ok with this.

Merce answered 24/8, 2012 at 9:23 Comment(1)
+1 for introducing the technique of dragging & dropping the ANT file from Project Explorer to the Ant view.Kapoor
S
1

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
Squier answered 1/11, 2010 at 9:48 Comment(1)
i m not getting build.properties in my project...what should i doGranvillegranvillebarker

© 2022 - 2024 — McMap. All rights reserved.