Error during Java compilation in plugin unit test
I have a plugin that invokes a Java project's compilation (via CompilerManager#rebuild) which I'm trying to put a test around. I've created my project/java fixture using the heavy fixtures and when the compilation gets invoked I get the following exception:
Internal error: (java.io.IOException) Cannot find IntelliJ IDEA project files at /private/var/folders/2h/6msqxrhn4k77_rvjgv458ky0_0tl6z/T/blah/blah.ipr
java.io.IOException: Cannot find IntelliJ IDEA project files at /private/var/folders/2h/6msqxrhn4k77_rvjgv458ky0_0tl6z/T/blah/blah.ipr
at org.jetbrains.jps.model.serialization.JpsProjectLoader.loadProject(JpsProjectLoader.java:94)
at org.jetbrains.jps.model.serialization.impl.JpsSerializationManagerImpl.loadModel(JpsSerializationManagerImpl.java:42)
at org.jetbrains.jps.cmdline.JpsModelLoaderImpl.loadModel(JpsModelLoaderImpl.java:50)
at org.jetbrains.jps.cmdline.BuildRunner.load(BuildRunner.java:79)
at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:280)
at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:138)
at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler.lambda$channelRead0$0(BuildMain.java:235)
at org.jetbrains.jps.service.impl.SharedThreadPoolImpl.lambda$executeOnPooledThread$0(SharedThreadPoolImpl.java:42)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
I dug in a little bit and it seems the test project does not actually save the project file to disk which JPS is expecting - I've tried various mechanisms to force the save including:
ApplicationManagerEx.getApplicationEx().doNotSave(false)
runInEdtAndWait {
project.save()
}
and
runInEdtAndWait {
PlatformTestUtil.saveProject(project)
}
and when I do I get the following exception and the save doesn't actually occur:
ERROR: Content equals, but it must be handled not on this level: file 0.iml, content
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<orderEntry type="jdk" jdkName="java 1.7" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
java.lang.Throwable: Content equals, but it must be handled not on this level: file 0.iml, content
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<orderEntry type="jdk" jdkName="java 1.7" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
at com.intellij.openapi.diagnostic.Logger.error(Logger.java:136)
at com.intellij.configurationStore.FileBasedStorageKt.writeFile(FileBasedStorage.kt:195)
at com.intellij.configurationStore.FileBasedStorage$FileSaveSession.saveLocally(FileBasedStorage.kt:100)
at com.intellij.configurationStore.XmlElementStorage$XmlElementStorageSaveSession.save(XmlElementStorage.kt:151)
at com.intellij.configurationStore.FileBasedStorage$FileSaveSession.save(FileBasedStorage.kt:85)
at com.intellij.configurationStore.ComponentStoreImplKt.executeSave(ComponentStoreImpl.kt:486)
at com.intellij.configurationStore.ComponentStoreImpl.doSave(ComponentStoreImpl.kt:239)
at com.intellij.configurationStore.ComponentStoreImpl.save(ComponentStoreImpl.kt:196)
at com.intellij.configurationStore.ProjectWithModulesStoreImpl.beforeSave(ProjectStoreImpl.kt:392)
at com.intellij.configurationStore.ProjectStoreImpl.doSave(ProjectStoreImpl.kt:333)
at com.intellij.configurationStore.ComponentStoreImpl.save(ComponentStoreImpl.kt:196)
at com.intellij.openapi.components.impl.stores.StoreUtil.save(StoreUtil.java:49)
at com.intellij.openapi.project.impl.ProjectImpl.save(ProjectImpl.java:349)
The error seems to come from this line : https://github.com/JetBrains/intellij-community/blob/master/platform/configuration-store-impl/src/FileBasedStorage.kt#L196 I'm not sure what it means by "Content equals, but it must be handled not on this level" it seems to only follow this logic path if it's a unit test.
Please sign in to leave a comment.
I changed `error` to `warn` (https://github.com/JetBrains/intellij-community/commit/b8632fad0dfad796f50d978e2172ee9fbf739a20#diff-24b6be7d38beec11f0c1dd4b3eb2a550 five days ago.