DX Connection doesn't save correctly in Configure Project.

Issue #741 resolved
Rowan Massey created an issue

I have multiple DX modules in my project, I create a new scratch org, and then select Configure Project from the Illuminated Cloud menu. I select the new scratch org from the connection dropdown for each of the modules in the project. I click the save button, everything appears fine. However, if I go to Configure Project again, only the last module has been successfully updated to the new scratch org, the rest are unspecified. I have to manually update the .iml file for each of the other modules.

Comments (36)

  1. Scott Wells repo owner

    Thanks for filing, Rowan. Yeah, it sounds like from #740 and this story that there are issues with SFDX and multi-module projects. I'll take a look in the next few days. Hopefully it's some minor stuff required to make it all work properly. I'll keep you posted via these two tickets.

  2. Rowan Massey reporter

    Hey Scott, no problem at all. Not massive issues, they're easy enough to get around. Just thought I'd log them anyways. Thanks for that, and the quick response :-)

  3. Rowan Massey reporter

    Updating the priority of this. The more DX projects that we include in the project, the more tedious it becomes to update each of the project's .iml files.

  4. Scott Wells repo owner

    Rowan, for this and for #740, can you describe the way your multi-module project is set up? In particular I'd like to know the general directory structure including where the key SFDX files and directories reside (e.g., .sfdx/ and sfdx-project.json) for each module, and which scratch orgs are used by each module. I want to make sure I'm setting things up properly as I look at supporting this. Oh, and what manual changes are you having to make to the .iml files to make it work? Thanks!

  5. Rowan Massey reporter

    Hi Scott, thanks again for the quick response. Right. I'll try and explain. We currently have eight Github repositories housing the relevant code. I initially opened the Core Project, and then added the rest of them as modules. Similar to as follows:

    Core Project
    Utilities
    Common Components
    etc ...
    

    Each of these modules contain a .sfdx directory and sfdx-project.json file in the root of module, and get deployed to the same scratch org. In the .iml file, I need to update the connectionName value in the Illuminated Cloud facet for all projects other than the last one (which is the only one that gets updated in Configure Project) e.g

        <facet type="IlluminatedCloud" name="Illuminated Cloud">
          <configuration>
            <option name="connectionName" value="project-scratch-org-1" />
            <option name="deploymentSubstitutionRules">
              <list>
                <SubstitutionRule>
                  <option name="filenamePattern" value="" />
                  <option name="substitutionPattern" value="" />
                  <option name="substitutionText" value="" />
                </SubstitutionRule>
              </list>
            </option>
            <option name="moduleContents">
              <ModuleContents>
                <option name="manifest">
                  <Manifest />
                </option>
              </ModuleContents>
            </option>
          </configuration>
        </facet>
    

    Is that enough to get you up and running? Thanks again for looking into this.

  6. Scott Wells repo owner

    That helps, yes. A few more questions if you don't mind. First, is the source code for these modules all intended for deployment into a single scratch org, or are you deploying into a scratch org per-module? I was under the impression that it was the former and these were all truly "modules" of the same code base broken out for better separation of concerns and management.

    If that's the case, are these all just package directories in a single shared sfdx-project.json at the project-level?

    If that's the case (and I realize that at this point I may be asking the complete wrong questions if my expected answer to the first question was wrong!), have you considered setting up this project as a single module with multiple content/source roots, one for each package directory? That's generally how I'd intended to map SFDX projects to IntelliJ projects/modules, and it's one of the motivations for the recent enhancement to support multiple source roots with one designated as the default source root...which maps to the default package directory.

    Let me know if I'm way off-base here and missing what you're trying to do. If that's the case I'll definitely go back to the drawing board.

  7. Rowan Massey reporter

    I don't mind at all :-) Ask away. The code for these modules will be deployed into a single scratch org (at least that's how we're currently developing it). However, some of these repositories will be shared across teams. Common Components for instance will be used by multiple teams, but deployed to their own scratch orgs. So in that sense, the intention is better separation of concerns, and management.

    Would setting it up as a single module with multiple contents/sources still work if some of those modules had to be in separate Github repos?

  8. Scott Wells repo owner

    Yes, you can set up version control for your single-module project where each directory is associated with a different repo (or even VCS provider if you want). Open up Settings>Version Control and you'll see a table where you can add a row per-directory and set the VCS config for that directory. In that manner you can have a single-module project with multiple source roots, one per-package directory, each pointing to a different Git repo, and I think you'll get the desired behavior. I would say tinker with that a bit and let me know if/how it doesn't meet your needs.

  9. Rowan Massey reporter

    Ah, I didn't realise that functionality was available. I just tried it there now, but the plus sign is disabled for some reason. I'll do a bit of investigation, and let you know.

  10. Scott Wells repo owner

    Let me know what you find. I can also try to set up a "multi-module" SFDX project as a single module as described and send it over to you as a reference implementation. I probably wouldn't be able to do that until this weekend, though, but I'm happy to do it. Honestly it would be educational for me as well just to put something concrete to the thoughts I'm sharing with you.

  11. Rowan Massey reporter

    I will do. Just trying to read up on the VSC config that you suggested. That would be perfect - the weekend is absolutely fine. Thanks for that.

  12. Rowan Massey reporter

    Hey Scott, right I have that setup as you suggested, and it looks great :-) You've converted me - It seems to meet our needs alright. I'm more than happy to move to that way of setting up multiple modules for a dx project. So just for my own edification, I'll now have to update the sfdx-project.json to include those other directories in the packageDirectories node?

  13. Scott Wells repo owner

    Outstanding! That's how I'd like to see SFDX projects configured because it maps very cleanly to the sfdx-project.json package directories.

    I'm resolving this issue since Rowan has found the proposed solution satisfactory. I noticed that there are several other watchers/followers on this issue. If one of you still wants to discuss multi-module SFDX projects, feel free to reopen with details on your setup and we can see if the same approach would apply or not.

  14. Rowan Massey reporter

    Sorry Scott, I seem to have hit another issue. Whenever I add one (or more) Context Roots to my "main" project, and restart IntelliJ, or close and re-open the project (this is crucial to reproduce the issue) , the project seems to revert to the old style metadata dev-org setup. I get the following error:

    Invalid configuration for module 'main-project'
                        Module 'main-project': The following must be configured properly:
                        module's configured connection must resolve to a global connection
                        module connections must have configured credentials
                        module must have a configured metadata subscription
    
                        Full resolution of these items may require multiple steps.
    

    if I remove the added "Utils" Content Root and restart the project, it seems to work fine, and it reverts back to the scratch-org setup.

  15. Scott Wells repo owner
    • changed status to open

    Okay. There may still be some warts to work through. Let me set up a project this way on my own this weekend and see whether I encounter the same issues. If so, I'll address them for a build early next week.

  16. Rowan Massey reporter

    One other thing I've noticed Scott. While you're working through those warts ;-) When I load a project as a Context Root, I don't get any files appearing under aura, labels, customMetadata, layouts and permissionSets. Actually, the only files I seem to get are under classes and objects. For objects though, I only get field directories - no files, and I don't get anything appearing under fields and validationRules either. Everything appears fine if I load the project as an existing module.

  17. Rowan Massey reporter

    Hey Scott, how're things? Here, just wondering if you've had any luck reproducing the above?

  18. Scott Wells repo owner

    Rowan, I actually did set up a project just last week with three separate package directories each with multiple source roots beneath them (for production vs. test source and also unpackaged/post-install source) and haven't run into any issues with it. I may need to work with you to understand the difference between how I've configured this one and how you've configured yours so that I can either model the same thing as you and hopefully reproduce the issue or help you model yours the same as mine and help you to resolve the issue. Maybe we should just do a quick screeshare sometime soon to compare notes. That might be the most expedient path forward.

  19. Rowan Massey reporter

    Hey Scott, damn. I wonder what I'm doing wrong then. A screen share would probably be the best way forward. I'll see if I can reproduce on a demo project setup, and let you know.

  20. Scott Wells repo owner

    Let me know when you have a simple standalone project that reproduces the issue. You can either just send that to me for triage or we can jump on a screenshare.

  21. Rowan Massey reporter

    Hi Scott, how's things? Here, I'll just show you what's happening on our current project. It would be way easier than trying to set up several others to reproduce things. Let me know when suits you to do a screen share, and I'll show you the issues I'm having. Thanks again.

  22. Scott Wells repo owner

    Rowan, I apologize for the long-delayed response here. We've had a major deadline in my day job that has caused me to be rather sidetracked. I should be available for a screenshare to compare notes this week if you're also available. Just let me know and I'm sure we can find a common time. Sorry again going dark on you!

  23. Rowan Massey reporter

    Hey Scott, no problem at all sure. :-) I'm available all this week. Let me know when suits you - and I'll work around that.

  24. Rowan Massey reporter

    Hi @RoseSilverSoftware - do you think we could have a look at this in the foreseeable future? I appreciate you're probably flat out with with work.

  25. Scott Wells repo owner

    Hi, Rowan. Yeah, I've been much less responsive on this than intended. Again, sincere apologies. Do you have some times later this week that you might be available for a screenshare so we can compare approaches? I'm also at TrailheaDX next week if you happen to be going. We could grab some time there if so.

  26. Rowan Massey reporter

    Hi Scott, no problem. I noticed you've released version 2, so figured you were pretty busy. I absolutely have time. I'll make sure I'm free whenever suits you? I'm in Dublin, not too sure where in the world you are. Afraid my company won't be forking out for TrailheaDX - unfortunately.

  27. Scott Wells repo owner

    Hey...sorry...fell behind again. Yes, things are a bit crazy. My availability tomorrow is a bit sketchy right now. How does Monday look for you? After that I'm going to be heading to TrailheaDX for the remainder of the week, so that won't work well either.

    I'm in Austin, TX, by the way. Just let me know if Monday works for you, and if so, ideally some times that might work. I'm in CDT which is (I think) ~6 hours behind you.

  28. Scott Wells repo owner

    Rowan, can you send me an email at support@illuminatedcloud.com so that I can set up a Hangouts meeting for us on Monday? I need an email address to do so.

  29. Rowan Massey reporter

    @RoseSilverSoftware Working like a charm - thanks again for your time. I'll mark this resolved.

  30. Log in to comment