Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 46506 - Ant UI should have refactoring support
Summary: Ant UI should have refactoring support
Status: RESOLVED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Ant (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows 2000
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Platform-Ant-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-11-12 13:53 EST by David Whiteman CLA
Modified: 2009-08-30 02:16 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Whiteman CLA 2003-11-12 13:53:00 EST
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.
Comment 1 John-Mason P. Shackelford CLA 2003-12-29 13:41:10 EST
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.
Comment 2 Darin Swanson CLA 2004-04-28 15:17:07 EDT
Sorry but we did not make this for 3.0
Comment 3 Lance Walton CLA 2004-05-29 14:43:26 EDT
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
Comment 4 Darin Swanson CLA 2004-05-29 15:05:54 EDT
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.
Comment 5 Lance Walton CLA 2004-05-31 12:25:04 EDT
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
Comment 6 Denis Roy CLA 2009-08-30 02:16:59 EDT
As of now 'LATER' and 'REMIND' resolutions are no longer supported.
Please reopen this bug if it is still valid for you.