简体   繁体   中英

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

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

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM