As a Salesforce ISV, we are currently facing the following situation:
We have one managed package available as an application on AppExchange and we would like to propose a 'premium' version of our application providing additional features.
For that matter, we started to develop another managed package. This new package would partly rely on the same APEX code as our initial package.
We tried the Extension to managed package proposed by Salesforce, which makes the first package required to install the 'extension' package. This later would then be able to use the APEX code of the main package. But still, it is necessary to install both packages, even if you only need the features of the second one, which is not appropriate for some of our AppExchange customers. An idea has already been posted to simplify the installation process.
Do you see any other solution to use the same APEX code within two packages, apart from code duplication ? Any idea would be greatly appreciated.
Attribution to: Eric L.
Possible Suggestion/Solution #1
The straight answer is no, there is no package / jar / library concept in Apex like Java for example. All code must be in your package or accessible from other packages via the 'global' access modifier. Which as you points out creates a dependency users need to install.
That said if you are using source control management and Ant scripts, you can implement reuse between your packages upstream from them. Accepting that the code will eventually be duplicated in the packages, but ensuring you have only one place to maintain and manage them. Which is generally the main goal, even though the end result does not reflect that.
A couple of options exist between SVN (for example) and Ant.
- SVN route, you could create a 'shared code' repo and utilise Externals, check out this link.
- Ant route, you can build an Ant script that explicitly pulls in (via the SVN tasks for example) source from different locations prior to deploying to your development and/or packaging orgs.
Hope this helps!
P.S. Have you considered using Permission Sets (which in the future we hope will be licensable) to control your features for both types of users, standard and premimum, and thus having one package? Or if your worried about misuse, by standard users, implement some kind of Protected Customer setting to enable/disable those features? I say this as P.S. as of course your question does not relate to designing packaging strategies, but thought I would mention it, in case you are interested.
Attribution to: Andrew Fawcett
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/4812