Import module exports from files to IntellIJ
In Java/Javac it is possible to pass @filename as a file to read command-line options from.
A project I use closely interacts with the Graal compiler and overwrites parts of the compiler. In order to be able to access the compiler modules, a lot of `add-exports` options are used that live in multiple files. At compile and run time we pass files as `@path/to/exportList` that contain all the required `add-exports`.
However, I was unable to find a way to configure IntelliJ to read from the same files java/javac use. I already tried to change the File->Settings->Build->Compiler->Java Compiler->Compilation Options with the required paths to the export files but that does not solve the problem.
Therefore, I get the following errors in the IDE, and manually sorting all the import errors is not a great solution. I've also looked for an option to disable module access checking completely but could not find one.

Please sign in to leave a comment.
Hello,
It seems there is no way to pass exports list to the compiler as a file - https://youtrack.jetbrains.com/issue/IDEA-204562 .
Does it help if you manually add
--add-exportstoSettings/Preferences | Build, Execution, Deployment | Compiler | Java Compiler | Additional command-line parameters?Hi Egor,
It works if I manually copy the `add-exports` to
Settings/Preferences | Build, Execution, Deployment | Compiler | Java Compiler | Override compiler parameters per-module.It's a shame that currently there is no support for passing files with the compiler options.
I have the same issue. Using the `Additional command-line parameters` does not work. The `Override compiler parameters per-module` partially works, but every time the IDE is restarted, these fields need to be set up again. Is there any workaround?
Some more info, I am using:
Hi @Jjfumero, Could you clarify the build system you're using and provide screenshots from Settings/Preferences | Build, Execution, Deployment | Compiler | Java Compiler before/after the problem?
Hi Egor,
I did not have this problem before since I was using JDK 8. When using OpenJDK >= 11 or GraalVM for JDK11, I get these issues. See attached a few screenshots about the issues.
The build system is maven and the project being built is TornadoVM https://github.com/beehive-lab/TornadoVM
We can build TornadoVM from the terminal with no issues for any OpenJDK (8, 11 and 16). However, from 11 we get these errors in the IDE.
We have all export files here:
https://github.com/beehive-lab/TornadoVM/tree/master/assembly/src/etc/exportLists
In fact, I can see this in the IDE is getting the right paths `Override compiler parameters per-module.` However, it does not work.
Any pointer as a workaround will be very helpful.
>The `Override compiler parameters per-module` partially works, but every time the IDE is restarted, these fields need to be set up again. Is there any workaround?
IDE takes the configuration for this field from the Maven pom.xml files. E.g.
So once you re-import the project IDE will rewrite the manually specified options there taking the configuration from Maven.
Can you clarify what does work exactly when you say "partially"?
Does IDE build (Build | Rebuild Project action) complete successfully?
Thank you Andrey,
This is how my pom file looks like. As you can see, we use a few files for the exports. Each file contains quite a few exports.
Additionally, we provide a different version of Graal (different from the one shipped with JDK 11). As I said, this works perfectly fine from the terminal. Could this work with IntelliJ?
What I meant is that, if I solved the exports issues with the IDE, then I have the issue of the Graal.jar file remaining. The IDE suggest adding the Jar dependencies in the POM file, but once I added them, I have the module issue again. So I can't still get the project "free of errors".
We have a custom build. So we always use the terminal. I suppose I can configure IntelliJ to build but never tried.
I see, thank you for clarifications. Unfortunately, as Egor mentioned, at the moment reading exports from the file is not supported by the IDE. For this please vote for this request in our tracker: https://youtrack.jetbrains.com/issue/IDEA-204562
Thank you Andrey,
I already voted. I wish IntelliJ provides this feature soon.
Juan