Share
Embed
Second Generation Packaging - It's not just for ISVs
Slide deck from my talk at London's Calling 2022 on second generation packaging.
Keir Bowden
January 29, 2024
Transcript
41 slides
-
CTO at BrightGen 11 time MVP Certified Technical Architect >
10 years package development experience - SI + ISV About Me -
A collection of metadata components Treated as a single unit
Install in one atomic operation Everything goes in, or nothing does Remove in one atomic operation After removing local references … Deletes data for packaged objects What is a package -
Distribution Internal Selected customers Entire world Promotes modular development Isolated
functionality Independent release cadence Communication through well-defined interfaces Identifiable Components from packages are marked with an icon Why Packages? -
Terminology Packaging Org (1st) Developer Edition for First Generation package
development Namespace Prefix applied to all metadata Package version Snapshot of the components at a point in time Immutable Subscriber Org Org where package has been installed -
Dev Hub (2nd) Salesforce DX Developer Hub Create and manage
second generation packages Create and manage scratch orgs Unpackaged Metadata Metadata required during package develop/test Not included in final package Beta version Unreleased version of a package May never be released Install only in scratch, developer or sandbox orgs Promote to release if testing successful Terminology -
Comparison Source of Truth First Gen Second Gen Packaging Org
Version Control SFDX/CLI Optional/Basic Mandatory/Integrated Team Development Challenging Straightforward Create Version Packaging Org UI Filesystem + CLI Namespace Single Package Multiple Packages Ancestry Linear Flexible Unpackaged Metadata Mixed in org Declarative -
Namespace defined in Packaging Org Unique to each package Restricted
to this one org Expose code through global keyword Blunt instrument Code available to everyone • Subscriber Org • Any other packages installed in that org Namespace - 1st Gen -
Defined in developer edition Registered in Dev Hub Available for
multiple packages Potential for namespace collisions E.g. BOOKSTORE__Book__c in two packages Expose code through global keyword Namespace - 2nd Gen And @namespaceAccessible annotation -
Explicitly grant access to each member Class Method Property Interface
Can add or remove at any time - may break code Cannot mix with @AuraEnabled Creates dependency SALESPKG requires COREPKG to be installed @namespaceAccessible Annotation -
Define previous version (ancestorVersion) Optional Ancestry - 2nd Gen 1.25.0
can extend 1.24.0 released version And any ancestors of 1.24.0 "Use the ancestor that’s the immediate parent of the version you’re creating" SalesforceDX Developer Guide, https://sforce.co/3jUdxZH -
Ancestry - 2nd Gen V1.0.0 V2.0.0 V2.1.0 V2.2.0 V3.0.0 V3.1.0
V4.0.0 V4.1.0 ancestorVersion 1.0.0 ancestorVersion 2.0.0 ancestorVersion 2.1.0 ancestorVersion 2.0.0 ancestorVersion 3.0.0 No ancestorVersion ancestorVersion 4.0.0 -
Parallel development streams, like version control Multiple beta versions with
the same number Only one can be promoted to released Use --branch <name> switch when creating version Branching -
Branching 2.0.0 2.0.0. 1 2.1.0. 1 2.1.0. 2 2.1.0. 1
2.1.0. 2 2.1.0 Version Control Merge Feature Branch AuthorReading Feature Branch OrderApprovals Feature Branch LoyaltyCard -
Choose Your Plan First Generation Second Generation Managed Unmanaged Unlocked
Managed Org Dependent -
1st Gen Managed Features Namespaced Code obfuscated Upgradeable When to
use List on app exchange Features missing in 2GP -
2nd Gen Managed Features Namespaced Code obfuscated Upgradeable When to
use List on app exchange Extend 1GP ISV Tightly controlled apps -
Example - revert 1.33 version of package to 1.25 Downgrade
Package Metadata is : Modified (Apex classes reverted to 1.25) Deprecated (Custom objects not present in 1.25) Deleted (Report not present in 1.25) Fails if local code depends on 1.33 code -
Move metadata in/out of package Release metadata from package into
org Claim metadata from org in to package Collaboration required Cannot use namespaces Package and org must be logically complete No demo, just screenshots (sorry) Migrate Metadata -
2nd Gen Unlocked When to Use System Integrator Enterprise Customer
Newer Org Entire Application New Distribute Open Source -
2nd Generation Org Dependent Unlocked Features No Namespace Code visible/editable
Upgradeable Downgradeable Migrate metadata Depend on Org Metadata -
Tests run on installation Faster development Slower installation Complicates development
process Dependent metadata must be present during development Local changes may prevent upgrade - collaboration required Scratch orgs can be a challenge Tooling can't tell the difference Dependent metadata can sneak into package LIkely to target fewer subscriber orgs Org Dependent -
2nd Generation Org Dependent Unlocked When to Use Mature Org
Rely on existing metadata Extend existing apps Enterprise Customer Sweet spot for SI -
Official Docs Managed : sforce.co/398qygi Unlocked : sforce.co/3NuNBk9 Trailhead :
Managed Module : sforce.co/3GUTmFr Unlocked Trail : sforce.co/38W51qQ 2nd Gen Launch FAQs - historic interest Developer Controlled : bit.ly/3MsZV2W Unlocked : bit.ly/3O1ZWMO Trailblazer groups : Unlocked : sforce.co/3xo6jEC London's Calling 21 Org Dependent Packages youtu.be/XzUWr6gV9zk More Information - 2nd Generation Only!