Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » How to create a build.xml file and use it as an ANT scipt for compiling?
How to create a build.xml file and use it as an ANT scipt for compiling? [message #513684] Wed, 10 February 2010 14:40 Go to next message
Eclipse UserFriend
I have setup a java program with source code in Eclipse.
The project currently contains no build.xml.
Now the tasks are gettings more complex and a simple compile is no more sufficient.
I need an ANT script.

How do I create, add and call such an build.xml from the projects Java Perpective?

Ben
Re: How to create a build.xml file and use it as an ANT scipt for compiling? [message #513864 is a reply to message #513684] Thu, 11 February 2010 09:18 Go to previous messageGo to next message
Eclipse UserFriend
You can just create it as normal and then either call it manually, or
add an ANT builder to the list of builders associated with your project
(do that in the project properties dialogue in the Builders pane).

Steffen

On 10/02/2010 19:40, Ben wrote:
> I have setup a java program with source code in Eclipse.
> The project currently contains no build.xml.
> Now the tasks are gettings more complex and a simple compile is no
> more sufficient.
> I need an ANT script.
>
> How do I create, add and call such an build.xml from the projects Java
> Perpective?
>
> Ben
Re: How to create a build.xml file and use it as an ANT scipt for compiling? [message #513928 is a reply to message #513864] Thu, 11 February 2010 12:09 Go to previous messageGo to next message
Eclipse UserFriend
Ok, thank you.

One more question: Is there a way to generate a basic build.xml from my current project properties?

So I could start to add additional targets in this prepared base build.xml file instead of having to write all stuff from scratch again.

Ben

Steffen Zschaler wrote on Thu, 11 February 2010 09:18
You can just create it as normal and then either call it manually, or
add an ANT builder to the list of builders associated with your project
(do that in the project properties dialogue in the Builders pane).

Steffen

On 10/02/2010 19:40, Ben wrote:
> I have setup a java program with source code in Eclipse.
> The project currently contains no build.xml.
> Now the tasks are gettings more complex and a simple compile is no
> more sufficient.
> I need an ANT script.
>
> How do I create, add and call such an build.xml from the projects Java
> Perpective?
>
> Ben

Re: How to create a build.xml file and use it as an ANT scipt for compiling? [message #514080 is a reply to message #513928] Fri, 12 February 2010 06:30 Go to previous messageGo to next message
Eclipse UserFriend
I don't think there is such an option... or, at least, none I know about...

It's a bit of hard work, but I do maintain a "build.xml" into every eclipse project. While I develop, I do use Eclipse's compiler, while the ANT build is used for deployment.
Re: How to create a build.xml file and use it as an ANT scipt for compiling? [message #514091 is a reply to message #514080] Fri, 12 February 2010 07:22 Go to previous messageGo to next message
Eclipse UserFriend
Ok, thank you for response.

Is there somewhere a sample ANT script for typical Eclipse deployment tasks?

I know how to use Ant scripts in general but I would like to know how to reference Eclipse directories and objects from within them.

For example:
How do I reference a jar file "aaa.jar" which is currently in

<ECLIPSEPROJECTBASEFOLDER>\lib\

Ben
Re: How to create a build.xml file and use it as an ANT scipt for compiling? [message #514125 is a reply to message #514091] Fri, 12 February 2010 09:01 Go to previous message
Eclipse UserFriend
I do not use any special variables to make reference either to the eclipse installation folder or workspace directories...

I place "build.xml" file in the root directory of the project. When I run it (using "Run As"/"ANT build" option), eclipse launches it using that same directory as working directory.

This is a stripped sample of a common "build.xml" file I do use:

<?xml version="1.0" encoding="UTF-8"?>
<project name="cmlibs" default="dist" basedir=".">
	<property name="build.base" value="/tmp/build" />
	<property name="build.this" value="${build.base}/${ant.project.name}" />

	<target name="clean">
		<delete dir="${build.this}" includes="**/*" />
	</target>

	<target name="compile" depends="clean">
		<mkdir dir="${build.this}" />

		<javac srcdir="src" destdir="${build.this}" debug="${debug}" encoding="UTF-8" target="1.5">
		</javac>
	</target>

	<target name="dist" depends="compile">
		<copy todir="${build.this}">
			<fileset dir="src" excludes="**/*.java" />
		</copy>

		<jar basedir="${build.this}" destfile="${build.base}/${ant.project.name}-${version}.jar" manifest="src/META-INF/MANIFEST.MF" />
		<zip basedir="src" destfile="${build.base}/${ant.project.name}-${version}-sources.jar" />
	</target>
</project>


Hope it's useful.
Previous Topic:Remote debugging into Tomcat/Linux/x64 from Win7 x64
Next Topic:What I type isn't what shows up
Goto Forum:
  


Current Time: Tue Mar 18 10:53:51 EDT 2025

Powered by FUDForum. Page generated in 0.03508 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top