IC2 incorrectly treats project as metadata format even though it's DX source

Issue #2497 resolved
Michał Lisowski created an issue

When the project structure is a bit more complex IC2 can’t determine properly if the project is in metadata format or source.

e.g.

I believe the cause of the issue is the location of the sfdx-project.json file. In my case it is not in the Content Root, but in the folder where the “force-app” folder is. They are at the same level, so is package.json file.

It seems that when i first configure the project it works fine even with such structure. However, after closing the IntelliJ IDEA completely it stops working meaning when I open IDE again, IC2 thinks that the project is in metadata format - it hides all -meta.xml files so I cannot see most of the project files and when I try to retrieve the code it also downloads the files in metadata format (e.g. object as one file).

It can be fixed by either configuring the Content Root as one folder higher (so the sfdx-project.json file is in the root directory) or by copying the sfdx-project.json file to the Content Root (where IlluminatedCloud folder is). Then it works instantly and properly recognises the project as source format.

Salesforce CLI works properly the whole time - via command I can retrieve proper source formatted files, only the IC2 retrieve returns metadata format.

Salesforce CLI version 2.26.10
IntelliJ IDEA Ultimate version 2023.3.3 Build #IU-233.14015.106
OS: macOS Sonoma version 14.2.1

Comments (10)

  1. Scott Wells repo owner
    • changed status to open

    Hi. Yes, you're correct that IC2 determines that a project is source format based on the presence or absence of an sfdx-project.json file in the project root directory. Note that you can, of course, set the IDE's project root directory to the parent of that file. Is there a reason that the root directories are not aligned?

  2. Michał Lisowski reporter

    I just joined this project, I’m not really sure why. The important thing is the .git directory is also at highest level (where Illuminated Cloud folder is) and I’m also using husky which needs to be at the same level where .git folder is.

    So it’s really convenient to have the Content Root setup like this so I can see the .husky folder there. They also keep some other files at this level like readme.

  3. Scott Wells repo owner

    Thanks for the explanation. When I said “IDE’s project root directory”, that was actually kind of misleading. You can actually have the project root and the content root configured distinctly to support a structure like the following:

    projectRoot/
        .git/
        subdir/
            sfdx-project.json
            main/
                default/
    

    where projectRoot is the…well…project root directory, and projectRoot/subdir is the content root directory. IC2 will then look for sfdx-project.json under the content root and not the project root.

    I’m not 100% sure if that will resolve your issues, but I’m hoping that perhaps it will.

  4. Michał Lisowski reporter

    That is exactly my case and it doesn’t work… When I clone the repository and configure the module like below it works only until I close the IDE.

    RandomFolderName/ (Content Root)
        .husky/
        .git/
        subdir/
            emea/
                main/
                    default/
            force-app/
                main/
                    default/
            sfdx-project.json
    

    After I open the IDE one more time it treats the project as metadata format.

    The only way to fix this is to change the module configuration and set the “subdir” as the Content Root.

  5. Scott Wells repo owner

    Hi. Yes, that’s what I was suggesting above. The project root in your example would be RandomFolderName and the content root would be subdir. That content root would have source roots of either emea and force-app or emea/main/default and force-app/main/default. Are you saying that that configuration does or does not work consistently? If that’s not working consistently, that would be a bug.

  6. Michał Lisowski reporter

    subdir as Content Root works consistently. However, that setup hides some files from me, mainly the .husky folder which needs to be at the same level as .git.

    That is why I would like to have the Content Root as RandomFolderName

  7. Scott Wells repo owner

    Hi. You should be able to add a second content root that for the .husky folder with that same folder as the content root’s source root.

  8. Michał Lisowski reporter

    Unfortunately can’t do that on a Mac… Folders starting with a dot are hidden in file selection. However, I found out that I can change the file display in the IDE itself to display Project Files instead of only Project (which displays only Content Root files). I guess that’s a workaround.

  9. Scott Wells repo owner

    Resolving as this should be addressed via project module configuration. I'm curious about the issue adding the suggested module(s) on a Mac, though. Feel free to elaborate so I understand why a workaround was required there.

  10. Log in to comment