[SalesForce] Unlocked Package Dependencies

Given two unlocked packages: UP_A and UP_B.
UP_B classes uses classes from UP_A (UP_B depends on UP_A).

When I try to create a new version to UP_B from terminal I get the message:

ClassFromUP_B: Invalid type: ClassFromUP_A

My understanding is since ClassFromUP_A belongs to UP_A its source code shouldn't be part of the UP_B.

What Am I misunderstanding?

Further Info

My sfdx-project.json:

{
    "packageDirectories": [
        {
            "path": "atlas-quantum",
            "default": true,
            "package": "atlas-quantum",
            "versionName": "ver 0.1",
            "versionNumber": "0.1.0.NEXT"
        }
    ],
    "namespace": "",
    "sfdcLoginUrl": "https://login.salesforce.com",
    "sourceApiVersion": "46.0",
    "packageAliases": {
        "fflib-apex-mocks@0.1.0.1": "04t1K000002uwEIQAY",
        "fflib-apex-common@0.1.0.1": "04t1K000002uwENQAY",
        "atlas-quantum": "0Ho1K000000k9cQSAQ",
        "atlas-quantum@0.1.0-1": "04t1K000002uwCRQAY",
        "atlas-quantum@0.1.0-2": "04t1K000002uwCWQAY"
    }
}
  • atlas-quantum is my project that depends on fflib-apex-common
  • fflib-apex-common depends on fflib-apex-mocks

Error message I get when I try to create atlas-quantum package version: Assets: Invalid type: fflib_SObjectDomain,Assets: Invalid type: fflib_SObjectDomain,Application: Invalid type: fflib_Application.SelectorFactory,Application: Invalid type: fflib_Application.DomainFactory,Application: Invalid type: fflib_Application.SelectorFactory,Application: Invalid type: fflib_Application.DomainFactory,AssetsSelector: Invalid type: fflib_SObjectSelector,AssetsSelectorTest: Dependent class is invalid and needs recompilation:
Class AssetsSelector : Invalid type: fflib_SObjectSelector,Assets: Invalid type: fflib_SObjectDomain.IConstructable

IMPORTANT: the code is working properly in the scratch org.

Best Answer

From the documentation you will need to specify dependency using dependencies property in the project-sfdx.json.

{
  "packageDirectories": [
    {
        "path": "atlas-quantum",
        "default": true,
        "package": "atlas-quantum",
        "versionName": "ver 0.1",
        "versionNumber": "0.1.0.NEXT",
        "dependencies": [
            {
               "package": "fflib-apex-mocks@0.1.0.1"

            },
            {
               "package" : "fflib-apex-common@0.1.0.1"
            }
        ]
    }
],
"namespace": "",
"sfdcLoginUrl": "https://login.salesforce.com",
"sourceApiVersion": "46.0",
"packageAliases": {
    "fflib-apex-mocks@0.1.0.1": "04t1K000002uwEIQAY",
    "fflib-apex-common@0.1.0.1": "04t1K000002uwENQAY",
    "atlas-quantum": "0Ho1K000000k9cQSAQ",
    "atlas-quantum@0.1.0-1": "04t1K000002uwCRQAY",
    "atlas-quantum@0.1.0-2": "04t1K000002uwCWQAY"
   }
}
Related Topic