
Home
.. Links
.. Search
.. Plugins
.. Help
.. Irc Faq
Projects
.. Platform/Faq
.. JDT/Faq/Plan
.. PDE/Faq
.. SWT/Faq
.. RCP/Faq
Tools Projects
.. CDT/Faq
.. GEF/Faq
.. EMF/Faq
Wiki Tutorials
Hosted Projects
.. MTJ
.. Google Summer Of Code 2007
.. Update Manager 2.0
.. EasyEclipse
.. Stylebase for Eclipse
Archives
| |
How do I annotate a custom ant task to enable eclipse content assist? How enable european characters in an ANT script?Simply put this line at the beginning of the xml file <?xml version="1.0" encoding="iso-8859-1"?>
Is there a way to initiate a project refresh from inside an Ant script?Try <eclipse.refreshLocal resource="MyProject/MyFolder" depth="infinite"/>
Is there a way to know whether a script was started from inside or outside of Eclipse?Yes, the property "eclipse.running" is set when running inside Eclipse.
How do I get Ant Compiling from within Eclipse?When you try to run a javac task, you'll probably get an error saying something about using the classic compiler and setting JAVA_HOME. What you have to do is either tell Ant to use Eclipse's compiler, or tell it where to find the jdk's compiler. Note that if you start Eclipse with a JDK install VM, the jdk tools.jar is added to the Ant runtime classpath automatically. Option 1 - If you don't want to edit the build script or add a jvm arg (see 2)You can tell ant where the jdk's compiler is with: - Select Windows>>Preferences from the Eclipse Platform menubar
- Select External Tools>>Ant from the Preferences' window menu (Just Ant>>Runtime in newer Eclipse versions)
- Select the Classpath folder
- Click on the Add Jar... button and add your PC's jdk tools.jar (for example, C:/j2sdk1.4.1_01/lib/tools.jar )
- Apply changes
Instead of this, in newer Eclipse builds (e.g. Eclipse 2.1) you can also tell ant to always use Eclipse's compiler. - Select Windows>>Preferences from the Eclipse Platform menubar
- Select Ant>>Runtime from the Preferences' window menu
- Select "Properties" tab
- Click on the upper "Add..." button, and add a property with the name build.compiler and the value org.eclipse.jdt.core.JDTCompilerAdapter
Option 2 - If you don't like having to modify your script (see 3)(This applies mainly to older Eclipse versions) In the Tool Arguments for the External Tool, add the following: -Dbuild.compiler=org.eclipse.jdt.core.JDTCompilerAdapter Unfortunately, you'll have to do this for each External Tool you use. Option 3 - If modifying your Ant script is an optionUse the following code to do this: <target name="configure.eclipse" if="eclipse.running"> <property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/> <echo message="Configuring compiler for Eclipse..."/> </target> Then before your first javac task, do this: <antcall target="configure.eclipse"> Afaik that doesn't work - properties set by a target called by the antcall task are not passed down to the caller. (Respectively for the ant task.) NOTE:I had a problem where the IDE would just close with this technique. To solve this you need to trim out all the debug, deprecation, etc.. tags from the javac task. Or add 'configure.eclipse' as a dependency to your targets that compile. This makes sure that your build script will still work outside of Eclipse. Option 4 - Using a build.properties fileIf your ant build.xml file uses the popular convention of reading in properties from a build.properties file (a practice that is becoming especially common with ant build files used by multiple developers; see for example this article), you can add the following line to your build.properties file: build.compiler=org.eclipse.jdt.core.JDTCompilerAdapter If your entire development team uses eclipse, and your build.xml file uses the default.properties / build.properties convention, you may even want to put that line in the default.properties file; if you do, just remember that for automated pure jdk builds (such as on a nightly build server) you will then want build.compiler=com.sun.tools.javac.Main in the build.properties file used during automatic builds.
How can I say to Eclipse to use Ant 1.5 instead 1.4.1?Note that newer Eclipse versions (such as 2.1) include ant 1.5.2 already. > Eclipse is bundled with Ant 1.4.1 but I need to use some features from Ant 1.5. How can I say to Eclipse to use Ant 1.5 instead 1.4.1? I tried to change the jars in the Ant preferences page, but it did'nt works! What build are you using? You should be able to do the following in F2: 1) Go to your ant 1.5 installation and go to the lib directory 2) Create a temp directory under lib and cd into it 3) jar xvf ..ant.jar 4) remove the Class-Path entry from the META-INFMANIFEST.MF file. 5) Rejar ant with eg jar -cfm ..anteclipse.jar META-INFMANIFEST.MF * (still residing in the temp directory) 6) Go to Window->Preferences->External Tools->Ant 7) Remove: ant.jar jakarta-ant-1.4.1-optional.jar 8) Add (from 1.5): anteclipse.jar optional.jar This scenario works for me (Martin) for version 2.0.1 of eclipse. There is currently bug ( http://bugs.eclipse.org/bugs/show_bug.cgi?id=18644 ) in F2 that prevents you from saving your preferences but the workaround is to create the plugin metadata folder (.metadata/.plugins/org.eclipse.ant.core). Thanks, Rodrigo Step 1 to 7 added by Martin. In Eclipse 2.1, you can set ANT_HOME directly to point to your Ant install. This can be done globally using Window>Preferences>Ant>Runtime>Classpath>Set ANT_HOME. This will automatically add all of the JARs found in the lib directory of the install to the Ant runtime classpath.
How do I run Ant from Eclipse?Right click the ant xml file in the Navigator view and choose the "Run Ant..." option. This will give you a list of the ant targets. Choose the targets. They will be executed in the order you select them. When you run an ant script its automatically added to the "External Tools" configuration. You can rerun the scripts for here(Run -> External Tools). Vazz
How to increase memory heap size for running Ant?Eclipse's Ant integration runs Ant in the same virtual machine as Eclipse. So you need to increase the memory that you allocate to the Eclipse VM. Use -vmargs and specifying something like: "-vmargs -Xmx256M -Xms256M"
Why do I get a errors running Ant when I set ANT_HOME or change the Ant JARs?See this bug report "readme"
Eclipse 3.1 ANT Build File Import/Export See the article in Notes on Software Development, Technology and Life. or in Eclipse Developer's journal Eclipse 3.1 How to create an ANT build file from scratch I wanted to create an ANT build file which can be edited by ANT Editor. I haven't found a 'Create new ANT task' or something similar. My workaround is: 1. Create a new XML file (File->New->Other->XML folder->XML (create XML from scratch) 2. Append <project><target> to the file. Then it contains: <?xml version="1.0" encoding="UTF-8"?> <project><target> 3. Save the XML file (File->Save) 4. Close the XML editor (File->Close) 5. Select the XML file at the Package Explorer 6. Open XML file with the ANT Editor (Right mouse button->Open With->Ant Editor) Eclipse 3.2: How to debug a custom ant task I was running 3.2-M2 on winXP under java 5 (but not using any 1.5- or even 1.4-specific features) and writing a custom Ant task. Part of that is writing a Java class that extends org.apache.tools.ant.Task (see the ant manual for more details). However it wasn't working, so I needed to debug it. I set a breakpoint in my task class and ran my ant build, but the breakpoint wouldn't catch, even under the new Ant Debugger (from the Ant view, Debug As>Ant Build--allows you to set/catch breakpoints in your ant script, but won't step into Java code). Here's how I got my task breakpoint to catch (adapted from fragments by Darin Swanson): devbench=the Eclipse workbench in which you are developing your task. runbench=the Eclipse workbench which you launch from your devbench by creating and running a runconfig. - Create a fresh directory (using whatever filespace tools).
- In my devbench, create a runconfig (Run>Run>Eclipse Application) with Location=that dir, taking all other defaults. Launch that runconfig.
- In the resulting runbench, create an Ant build runconfig pointing to my script, and (on JRE tab) set
- (default) Separate JRE
- VM arguments=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
Hit Apply, but leave the External Tools window up. - Back in my devbench, create a runconfig (Run>Debug>Remote Java Application) with Project=buildController, taking all other defaults (notably Host=localhost and Port==8000). Hit Apply, but leave the Debug window up.
- In not-too-rapid succession (or you'll get "Failed to connect to remote VM" again), but just rapid enough (or the ant build will pass your breakpoint)
- Switch to the runbench, hit Run on the External Tools window.
- Switch to the devbench, hit Debug on the Debug window.
Comments:
Last Modified 6/15/06 12:59 PM
| Hide Tools
|
thats an overkill, here is a simpler solution:
you need to add ant-launcher.jar to the project classpath, and run or debug it.
for my case, I needed to change its working directory to 'test', because there is where my test build.xml was sitting.
you can just as easily provide a build file as a command line argument in the standard way.