I tend to use Groovy for almost all my targets these days, and it makes dealing with XML pretty simple. However, if you want to avoid Groovy, you can just brute force this puppy like this:
<target name="generate-project-files"> <echoxml file=".project"> <projectDescription> <name>Your Project Name here</name> <comment></comment> <projects> </projects> <buildSpec> <buildCommand> <name>org.eclipse.jdt.core.javabuilder</name> <arguments> </arguments> </buildCommand> </buildSpec> <natures> <nature>org.eclipse.jdt.core.javanature</nature> </natures> </projectDescription> </echoxml> <echoxml file=".classpath"> <classpath> <classpathentry path="src/java/main" kind="src"/> <classpathentry path="src/conf/main" kind="src"/> <classpathentry path="src/conf/test/integration" output="target/classes/test/integration" kind="src"/> <classpathentry path="src/conf/test/unit" output="target/classes/test/unit" kind="src"/> <classpathentry path="src/java/test/integration" output="target/classes/test/integration" kind="src"/> <classpathentry path="src/java/test/unit" output="target/classes/test/unit" kind="src"/> <classpathentry path="org.eclipse.jdt.launching.JRE_CONTAINER" kind="con"/> <classpathentry path="target/classes/main" kind="output"/> </classpath> </echoxml> </target> The second part that outputs the .classpath file might need some additional elements to specify the location of the log4j JAR file. -bp On Oct 13, 2010, at 8:21 AM, <prakash.sivaku...@wipro.com> wrote: > Can you please send me a sample, how the target would look like, > > Consider only the log4j need to be in my classpath and the nature of my > project is just JAVA nature. > > Thanks > Prakash S > > -----Original Message----- > From: Brian Pontarelli [mailto:br...@pontarelli.com] > Sent: Wednesday, October 13, 2010 7:45 PM > To: Ant Users List > Subject: Re: .project and .classpath > > The main purpose of the .project file is to set the project name and the > main purpose of the .classpath file is to set the dependencies. It > really depends on what you need, but I would suggest that checking those > files into source control would make life simpler. Or if you want to > build them using Ant and have no dependencies, just write a target that > outputs the proper XML. If you have a number of dependencies, then > you'll need to construct the .classpath to reference those dependencies > (i.e. JAR files). > > -bp > > > On Oct 13, 2010, at 8:07 AM, <prakash.sivaku...@wipro.com> > <prakash.sivaku...@wipro.com> wrote: > >> Thank you very much brian, but we are using apache ant to build our >> projects. >> >> Is there any way in getting those files when building the project > using >> apache ant. >> >> Thanks >> Prakash S >> >> -----Original Message----- >> From: Brian Pontarelli [mailto:br...@pontarelli.com] >> Sent: Wednesday, October 13, 2010 7:29 PM >> To: Ant Users List >> Subject: Re: .project and .classpath >> >> This depends on your dependency management tool. If you are using >> Savant, Ivy or Maven, it is pretty simple to write a target that >> generates these files. >> >> -bp >> >> >> On Oct 13, 2010, at 3:36 AM, <prakash.sivaku...@wipro.com> >> <prakash.sivaku...@wipro.com> wrote: >> >>> >>> >>> "mvn clean compile install eclipse:eclipse" >>> >>> Generates the following eclipse configuration files: >>> .project and .classpath files >>> .setting/org.eclipse.jdt.core.prefs with project specific compiler >>> settings >>> .various configuration files for WTP (Web Tools Project), if the >>> parameter >>> wtpversion is set to a valid version (WTP configuration is not >> generated >>> by >>> default) >>> >>> when we use maven build script with the eclipse plugin as above >> command >>> >>> Is there any option available for apache ant., if so please help out, >>> how to bring those file when taking build of a project which doesn't >>> have those. >>> >>> As these files will not be checked-in to the repository we need to >> auto >>> generate those files, so that it will be treated as a java project. >>> >>> Please do not print this email unless it is absolutely necessary. >>> >>> The information contained in this electronic message and any >> attachments to this message are intended for the exclusive use of the >> addressee(s) and may contain proprietary, confidential or privileged >> information. If you are not the intended recipient, you should not >> disseminate, distribute or copy this e-mail. Please notify the sender >> immediately and destroy all copies of this message and any > attachments. >>> >>> WARNING: Computer viruses can be transmitted via email. The recipient >> should check this email and any attachments for the presence of > viruses. >> The company accepts no liability for any damage caused by any virus >> transmitted by this email. >>> >>> www.wipro.com >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: user-unsubscr...@ant.apache.org >> For additional commands, e-mail: user-h...@ant.apache.org >> >> >> Please do not print this email unless it is absolutely necessary. >> >> The information contained in this electronic message and any > attachments to this message are intended for the exclusive use of the > addressee(s) and may contain proprietary, confidential or privileged > information. If you are not the intended recipient, you should not > disseminate, distribute or copy this e-mail. Please notify the sender > immediately and destroy all copies of this message and any attachments. >> >> WARNING: Computer viruses can be transmitted via email. The recipient > should check this email and any attachments for the presence of viruses. > The company accepts no liability for any damage caused by any virus > transmitted by this email. >> >> www.wipro.com > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@ant.apache.org > For additional commands, e-mail: user-h...@ant.apache.org > > > Please do not print this email unless it is absolutely necessary. > > The information contained in this electronic message and any attachments to > this message are intended for the exclusive use of the addressee(s) and may > contain proprietary, confidential or privileged information. If you are not > the intended recipient, you should not disseminate, distribute or copy this > e-mail. Please notify the sender immediately and destroy all copies of this > message and any attachments. > > WARNING: Computer viruses can be transmitted via email. The recipient should > check this email and any attachments for the presence of viruses. The company > accepts no liability for any damage caused by any virus transmitted by this > email. > > www.wipro.com --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@ant.apache.org For additional commands, e-mail: user-h...@ant.apache.org