function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

How to delete/undeploy apex classes

How do I delete/undeploy apex classes thru' the Eclipse IDE ? Thanks

An example would be great
I m having an awful lot of problems with undeploying as well.
Apparently it seems that its better to do it with ant rather than eclipse.
But as u requested, an example would be welcome. Anyone??
The Deploy Wizard in the IDE compares the components in your project to the components in your destination organization, then gives you the option to Add what's missing from the destination, Overwrite what's in both places, or Delete what's in the destination but not your source project.

To delete a component using the IDE, you need to use the Deploy Wizard with a project that does not contain the component you want to delete, so that the wizard gives you the option to delete that component from the destination organization.

In the Summer '08 IDE, the easiest way to do this is to create a new Project using the "Custom unpackaged component types" option in the Project Contents page, and deselect the type of component you want to delete.  For example, if you want to delete an Apex Class, then deselect Apex Class so you have no classes in your IDE project.  When you use the Deploy Wizard against the org where you want to delete the Apex Class, it will compare your project (containing no Apex Classes) to your destination organization (containing the class to delete) and give you the option to delete any Apex Class in the destination.

Thanks. Thats great.

Where is teh deploy wizard? And how do I find out which version I am on in the IDE

In Summer '08, you can launch the Deploy Wizard by right-clicking on your "src" folder and selecting > Deploy to Server...

To determine your IDE version, go to Help > Software Updates > Manage Configuration and look at the list of plugins for " IDE xx.x.x.xxxxxxxxx".  The version number for Summer '08 is 13.0.0.



It turns out that I am on IDE

Is there a way I can deploy in thsi version

Yes, the Deploy Wizard has been in the IDE for several releases.  If you don't see the > Deploy to Server option on the "src" folder, try it from the project root or other folders under "src".

I did find that.

When I try to deploy ' Component Deployment' window opens up and when I put in the org settings the 'Next' button is not highlighted. There are no proxy settings. What am I doing wrong?

I can however do 'Save to Server' to push the code in Sandbox, but this does not delete.

Try tabbing out of the password field.  If you can't get it to work, you may want to install the latest IDE and see if that works any better for you.  These IDE releases are in Developer Preview, so rather than upgrading your current Eclipse, we recommend installing the new IDE plugin into a new Eclipse instance and recreating your projects in a brand new workspace.

Yes, that did work. I didnt have to update the plug-in. As you mentioned the IDE is buggy and tab in and out activated the 'next' button.

Thanks again !!

Always ThinkinAlways Thinkin

The deploy utility still runs unit tests even if you're just deleting a class. Ironically, the class I'm attemping to delete is a regression test that fails now due to validation rules I put in place. So because it fails unit testing, I can't delete it.


Obviously, all I need to do is deactivate the validation rules while deleting but, come on, why run validation testing when only deleting components?!



The Metadata API runs tests on a production deploy after all changes are made, including deletes.  Most likely some other problem is preventing the deploy operation, once the offending class is removed, causing the whole thing to roll back.  Perhaps the validation rules are affecting other tests as well?  Or removing this class causes your test coverage to drop below the required minimums?
Always ThinkinAlways Thinkin
I've got one class to replace with an updated version and one to delete. I can't replace the one until I delete the other, I can't delete the other until I replace the one. Like I said, it's just a matter of turning off the validation rules during off-peak hours and making the changes.
You can perform both actions in a single deploy() using the Ant tool.  You will need your new class file, a package.xml listing your new class, and a destructiveChanges.xml listing the old class to delete.