How to achieve cross-platform Intellij IDEA `.iml` file with platform-dependent libraries?

182 Views Asked by At

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...

1

There are 1 best solutions below

0
CrazyCoder On

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.