Find your content:

Search form

You are here

Using the Deprecated annotation in a multi-org setting

 
Share

You can use the deprecated annotation on methods, classes, etc in a managed package so they can't be referenced in future releases. However, you can't have the deprecated annotation in any org other than a packaging org. We use ant scripts to deploy code from our subversion repository to an integration org, packaging org, and development orgs. If we add this annotation and check it into source control, it will no longer deploy anywhere other than the packaging org.

Am I missing how this is supposed to work in what seems like a typical development environment? Is there a best practice for using deprecation when the same code gets deployed to multiple orgs?


Attribution to: Rob Scott

Possible Suggestion/Solution #1

I haven't done any development with managed packages yet. I've only worked on code that would be used within the same company, so I haven't had any use for managed packages. The first time that I saw the need to deprecate something I naturally looked for and found the @deprecated annotation and figured that I could use it just like Java, but it is only available for managed packages. As far as I can tell Salesforce has no built in support for deprecating methods that works universally.

Anyway, back to your issue. You are building out of svn with ant scripts. Could you modify the ant scripts to add in an additional step that does a post checkout step to change the @deprecated to //@deprecated (i.e., comment out) in the non managed builds?

Of course, all of these could be ant targets, etc. that you compose together.

  1. Checkout from svn into temp directory
  2. If it is a non managed package build then execute script/command to search and replace in .cls files, copying files into final directory.
  3. Run ant migration task from final directory.

Attribution to: Peter Knolle

Possible Suggestion/Solution #2

You are correct in your assumption - I have the same issue with our development process, where we use separate dev branch and packaging orgs.

In my case I've simply created my own DeprecatedException, which is a hackish stopgap measure until Salesforce fix the issue (I've just added it to my list of things to raise at Dreamforce).

For the time being, Peters idea is probably the only way to do it - do a regex search and replace to uncomment the deprecation annotations in your packing org.


Attribution to: James Davies
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/406

My Block Status

My Block Content