1

While working across multiple OS, what is preferable way to use libraries in IDEA project?

The .iml file has libraries from Maven listed, some platform dependent:

...
    <orderEntry type="inheritedJdk" />
    <orderEntry type="sourceFolder" forTests="false" />
    <orderEntry type="library" name="Maven: org.openjfx:javafx-controls:17.0.0.1" level="project" />
    <orderEntry type="library" name="Maven: org.openjfx:javafx-controls:linux:17.0.0.1" level="project" />
    <orderEntry type="library" name="Maven: org.openjfx:javafx-graphics:17.0.0.1" level="project" />
    <orderEntry type="library" name="Maven: org.openjfx:javafx-graphics:linux:17.0.0.1" level="project" />
    <orderEntry type="library" name="Maven: org.openjfx:javafx-base:17.0.0.1" level="project" />
    <orderEntry type="library" name="Maven: org.openjfx:javafx-base:linux:17.0.0.1" level="project" />
    <orderEntry type="library" name="Maven: org.openjfx:javafx-fxml:17.0.0.1" level="project" />
    <orderEntry type="library" name="Maven: org.openjfx:javafx-fxml:linux:17.0.0.1" level="project" />
...

Trying to boot it up on Windows those get overwritten with Windows related versions of those libraries:

...
    <orderEntry type="inheritedJdk" />
    <orderEntry type="sourceFolder" forTests="false" />
    <orderEntry type="library" name="Maven: org.openjfx:javafx-controls:17.0.0.1" level="project" />
    <orderEntry type="library" name="Maven: org.openjfx:javafx-controls:win:17.0.0.1" level="project" />
    <orderEntry type="library" name="Maven: org.openjfx:javafx-graphics:17.0.0.1" level="project" />
    <orderEntry type="library" name="Maven: org.openjfx:javafx-graphics:win:17.0.0.1" level="project" />
    <orderEntry type="library" name="Maven: org.openjfx:javafx-base:17.0.0.1" level="project" />
    <orderEntry type="library" name="Maven: org.openjfx:javafx-base:win:17.0.0.1" level="project" />
    <orderEntry type="library" name="Maven: org.openjfx:javafx-fxml:17.0.0.1" level="project" />
    <orderEntry type="library" name="Maven: org.openjfx:javafx-fxml:win:17.0.0.1" level="project" />
...

... which I don't think will stay the same for back on Linux/MacOS.

How to work with that? Adding it to .gitignore seems bad idea...

AgainPsychoX
  • 1,527
  • 1
  • 16
  • 20
  • The iml file should only base on dependencies managed by the project pom.xml file(s) so there is no need to check it into a repo. – Robert May 04 '22 at 21:31

1 Answers1

0

Use Settings (Preferences on macOS) | Build, Execution, Deployment | Build Tools | Maven | Importing | Store generated project files externally option.

Don't commit project files for the external build model based projects (Maven/Gradle/SBT).

See also this FAQ.

CrazyCoder
  • 389,263
  • 172
  • 990
  • 904