score:0

  • select file > export from main menu (or right click on the project name and select export > export…).
  • in the export dialog, select general > ant buildfiles as follows: enter image description here

  • click next. in the generate ant buildfilesscreen:

    • check the project in list.
    • uncheck the option "create target to compile project using eclipse compiler" - because we want to create a build file which is independent of eclipse.
    • leave the name for ant buildfile as default: build.xml

enter image description here

  • click finish, eclipse will generate the build.xml file under project’s directory as follows:
    enter image description here
  • double click on the build.xml file to open its content in ant editor: enter image description here

source

score:2

take a look at the .classpath file in your project, which probably contains most of the information that you want. the easiest option may be to roll your own "build.xml export", i.e. process .classpath into a new build.xml during the build itself, and then call it with an ant subtask.

parsing a little xml sounds much easier to me than to hook into eclipse jdt.

score:2

i'm the one who donated the ant export filter to eclipse. i added the auto export feature, but only to my personal plug-in eclipse2ant, which i still maintain to coordinate bug fixes.

unfortunately i have no time to merge it to the official eclipse builds.

score:2

if all you need is the classpath entries, i do something like the following to use the eclipse build path.

<xmlproperty file=".classpath" collapseattributes="true" delimiter=";" />

then set that value in the path

<path id="eclipse.classpath">
    <pathelement path="${classpath.classpathentry.path}"/>
</path>


<target name="compile" depends="init">

    <javac srcdir="${src}" destdir="${build}" updatedproperty="compiled">
        <classpath refid="eclipse.classpath"/>
    </javac>
</target>

score:4

i've had the same problem, our work environment is based on eclipse java projects, and we needed to build automatically an ant file so that we could use a continuous integration server (jenkins, in our case).

we rolled out our own eclipse java to ant tool, which is now available on github:

ant-build-for-java

to use it, call:

java -jar ant-build-for-java.jar <folder with repositories> [<.userlibraries file>]

the first argument is the folder with the repositories. it will search the folder recursively for any .project file. the tool will create a build.xml in the given folder.

optionally, the second argument can be an exported .userlibraries file, from eclipse, needed when any of the projects use eclipse user libraries. the tool was tested only with user libraries using relative paths, it's how we use them in our repo. this implies that jars and other archives needed by projects are inside an eclipse project, and referenced from there.

the tool only supports dependencies from other eclipse projects and from eclipse user libraries.

score:5

i have been trying to do the same myself. what i found was that the "export ant buildfile" gets kicked off in the org.eclipse.ant.internal.ui.datatransfer.antbuildfileexportpage.java file. this resides in the org.eclipse.ant.ui plugin.

to view the source, use the plug-in development perspective and open the plug-ins view. then right-click on the org.eclipse.ant.ui plugin and select import as > source project.

my plan is to create a java program to programmatically kick off the ant buildfile generation and call this in an ant file every time i build by adding the ant file to the builders of my projects (right-click preferences on a projet, under the builders tab).

score:69

right-click on an eclipse project then "export" then "general" then "ant build files". i don't think it is possible to customise the output format though.


Related Query

More Query from same tag