Community
Participate
Working Groups
I would like to be able to perform refactorings in the Ant editor. One that comes quickly to mind is the equivalent of "extract method" (e.g."extract target"). Here's a brief snippet to explain: <target name="zipSourceJar"> <property name="outSourceJar" value="my-src.zip"/> <mkdir dir="${destinationDir}"/> <zip zipfile="${destinationDir}/${outSourceJar}" compress="true"> <fileset dir="tmpWorkObfuscateOut"> <include name="**/*.java, **/*.ico, **/*.properties"/> </fileset> </zip> </target> Say for instance that I wanted to make the <zip> task part of a new target. I would like to swipe it and select "extract target" so that the script would now look like: <target name="zipSourceJar"> <property name="outSourceJar" value="my-src.zip"/> <mkdir dir="${destinationDir}"/> <antcall target="zipItUp"/> </target> <target name="zipItUp"> <zip zipfile="${destinationDir}/${outSourceJar}" compress="true"> <fileset dir="tmpWorkObfuscateOut"> <include name="**/*.java, **/*.ico, **/*.properties"/> </fileset> </zip> </target> I'm sure there are a lot of other refactorings that could be applied to Ant script editing, but this is one I am repeatedly doing by hand.
A few more refactoring ideas: * extract to property -- Prompt user for a property name and then replace a selected literal (throughout the build file) with a propery dereference, creating a <property> assignment. The dialog ought also to indicate whether the propery is a path so as to determine whether to use the value or location attribute. * rename target * rename property * use named fileset -- Prompt user for a fileset name, add an id attribute to the selected fileset, rewrite identical filesets such that the refid the first. * reorder dependency -- In a dialog with two panes, the first pane uses GEF to illustrate dependency relationships between targets (arrows from one target to another indicate a target referenced by another's depends=""), the second pane is a list of the targets sorted by build sequence. As the user drags arrows from one target to another and adds or deletes arrows, the build sequence pane refreshes. Once satisfied, the user clicks an 'ok' and the depends attibutes of the various targets in build file are updated.
Sorry but we did not make this for 3.0
Hi. I'm interested in refactoring support for ant as well. Is this on the cards as part of the standard Eclipse release or is it best done as an open source plug in project? Regards, Lance
Lance, I would definately like to see this in the next release of Eclipse. It will not be in the 3.0 release unfortunately as we ran out of time. Very soon we will be starting the planning / developing for the next release and it would be great if you joined us in making this feature a reality.
Cool. Here are a few more refactorings that I'd like to see: 1. Scrub dependencies - Suppose target T1 has dependencies on T2 and T3 (in that order). Now suppose that T2 is also dependent on T3. Then T1 does not need to express the dependency on T3. 2. Make dependency an antcall / Make antcall a dependency 3. Extract target - this extraction could either result in an antcall or a dependency. If an antcall is required, we should be able to specify parameters I'd also like to see some forensic tools (I've seen ant scripts that were several thousand lines long!): 1. Find potential target extractions: search the ant script for common sections that could be turned into targets and antcalls/dependencies. It would be nice if this could deal with parameterised antcalls. 2. Find sections that could be turned into antcalls/dependencies to existing targets. Regards, Lance
As of now 'LATER' and 'REMIND' resolutions are no longer supported. Please reopen this bug if it is still valid for you.