I wanted to know if anyone using IntelliJ could compile Orekit using the javac compiler ?
On my end, i can compile it just fine until release 10.1 with the introduction of the DefaultDataContext which seem to be the cause of my compilation error in addition to a huge penalty in compilation time when using Eclipse compiler.
For now i must switch to the eclipse compiler but it is a bit of a bother to change that everytime my configuration is reset .
Ok i may have found something, it seems that we need to define the path to the Annotation processors in Build,Execution,Deployment â Compiler â Annotation processors.
However and by default, the IDE doesnât find the path even though the pom indicates to look inside :
Hence i think we need to fix the pom but still have not found how. I have been trying several fix with <annotationProcessors>but nothing worked so far.
I use IntelliJ. I didnât know about choosing Eclipse mode, so I assume Iâm using javac mode? Running individual tests from the editor works fine. Some things that help are:
Explicitly use a 1.8 JDK (which Iâm sure you already do) in the project settings
Use maven to perform a âcleanâ and âcompileâ
Right-click on the âcompilerâ folder (which contains the DefaultDataContextPlugin) in the project outline and select âMark directory as â Excludedâ
I think I managed to have this running.
My current settings allowed me to have several JetBrains Idea projects (not JetBrains Idea modules) that depend on each others, and to have the compiler plugin work.
This was done by letting JetBrains Idea match the Maven projects hierarchy, as it can link projects together, and also delegate compilation to an external maven program.
So here is what I did.
I started by cloning manually the various projects within one global directory using git clone, so I ended up with base-directory/hipparchus, base-directory/orekit, base-directory/my-application
then from either the Open button on the JetBrains Idea welcome window or from the File â Open top level menu, I just opened the base-directory/hipparchus/pom.xml file and clicked on the Open as project button in the popup, this created the hipparchus project with its many maven modules
from the File â Open top level menu, I then opened the base-directory/orekit/pom.xml file and clicked on the Open as project button in the popup, this created the orekit project
from the File â Settings top level menu, I navigated in the Settings popup and selected Build, Execution, Deployment â Build Tools â Maven â Runner,
in the Runner settings, I selected both Delegate IDE build/run actions to Maven and Skip Tests
Then, when I run Orekit tests, it is maven that builds the library, but it does not run the tests, JetBrains Idea runs them. Not selecting Skip Tests just means the tests would be run twice, once by maven and once by the IDE.
In order to compile and run my application, I just did step 3 again with my application pom.xml. Note that delegating the build to maven is project-specific, so I did it only for Orekit (i.e. the intermediate level, between Hipparchus and my application), for the other projects, I just let Jetbrains Idea do the compilation using its embedded maven tools.
In my case, as I also wanted to be able to modify all projects, I linked them together. This is done for example in Orekit by selecting View â Tool Windows â Maven in the top level menu, and in the maven tool window that appears, click on the big + button with the Add Maven Projects tooltip and select the top level base-directory/hipparchus/pom.xml file, and performed something similar in my application that depends on both Hipparchus and Orekit. So when I switch Orekit to some branch I am working on and rebuild it, I can use it in my application because it follows the maven dependencies properly.
I think i have found a clean fix so that intelliJ can natively compile using Javac.
Issue
We have a kind of chicken & egg problem because the pluginâs source lives in the same module that uses it. javac loads plugins at startup via ServiceLoader.load(Plugin.class): if the descriptor is on the classpath but the listed class hasnât been compiled yet, ServiceLoader fails to instantiate it and the whole compile aborts. Hence the Compilation failed: internal java compiler error
When using maven, this is not an issue because it works with a two-pass build:
First it builds the annotation & compiler only (plugin-compile runs in the generate-sources phase)
process-resources copies the descriptor into target/classes/META-INF/services/
The main default-compile runs with -Xplugin:dataContextPlugin, excluding org/orekit/compiler/**. The plugin class is now on the classpath and the plugin runs.
BUT IntelliJâs compiler compiles the module in one pass so it does not find the DefaultDataContextPlugin because its .class has not been generated yet.
Suggested fix
Move service descriptor out of src/main/resources to a separate location and add a maven step to copy it into target/classes during process-resources.
Iâll create a merge request with the suggested fix.
Move com.sun.source.util.Plugin from src/main/resources to src/main/plugin-descriptor
In maven-resources-plugin, add a new step to copy com.sun.source.util.Plugin from src/main/plugin-descriptor to project build directory
Move -Xplugin:dataContextPlugin from default maven-compiler-plugin to a dedicated data-context-plugin profile that automatically detects if IntelliJâs build i being used
If true, skip this argument
If not, re-add it to preserve original behaviour
Hence, when reloading & rebuilding project in intellij, the .idea/compiler.xml does not re-add -Xplugin:dataContextPlugin.
Plugin is still activated in CI and with standard maven build
You may want to take a look @evan.ward since you made the plugin.