Remove JRE entry from External Library for Android Studio project
Answered
Hi,
I am building a project for a specific environment which must no rely on the standard JRE. Standard Java APIs are provided by other project dependencies. Therefore I would like to remove the JRE entry from the External Dependencies.
I can remove it by deleting the following line from the .iml file:
<orderEntry type="inheritedJdk" />
but it is added back as soon as I reload the Gradle project.
Is there a way to remove it permanently ?
Regards
Please sign in to leave a comment.
Register listener com.intellij.openapi.externalSystem.service.project.manage.ProjectDataImportListener and modify IDE-side model accordingly (https://plugins.jetbrains.com/docs/intellij/sdk.html)
Hi,
Thanks for your answer.
I tried to use the listener ProjectDataImportListener by creating this class:
and adding it in the plugin.xml file:
But it does not seem to be executed.
I tried the same thing with the listener ProjectManagerListener, it is well called:
Not sure it is the right way to remove the SDK but the SDK does not appear anymore in the External Libraries. The remaining problem is that it appears again as soon as I reload the Gradle project (right-click on the project in the Gradle view > Reload Gradle project).
Would the use of ProjectDataImportListener listener solve this problem ? Should I use another listener ?
Regards
I found a way to have the JRE entry removed even after a Gradle project reload by using the extension com.intellij.openapi.roots.ProjectExtension:
The drawback is that this extension is an internal API. But I didn't find a better way so far.
Also I would like to be able to do the same thing but as the module level : in a project, a module uses the JRE as a dependency and another one does not. I tried to use the ModuleManager API but did not find a way to remove the JRE entry. Is this even possible ?
Regards
It seems your ProjectDataImportListener doesn't have Project CTOR parameter, then it should work.