'Java preprocessing support in Intellij IDEA
Does anyone know about Java preprocessing support in Intellij IDEA? Probably there are some 3rd party plugins?
Just for example: here's a piece of Java code written for Netbeans (which supports preprocessing):
//#if JSR82
//# import javax.bluetooth.*;
//#endif
Netbeans built-in preprocessor parses those //# keys and comments or uncomments pieces of code depending on defined preprocessor keys.
I'd expect something similar in Intellij IDEA.
Thanx in advance
Solution 1:[1]
You may want to look into configuring different artifacts for the various versions of the lib and then restructuring your code to isolate the version specific code in subclasses/components that are only including in the relevant artifact. This may be impractical, especially in an existing project, but less trouble than writing a plugin. Maven has similar functionality via classifiers.
Solution 2:[2]
Java programmers don't normally use preprocessers the way C/C++ do. Other techniques and systems have been developed like annotations, code generation, etc. Perhaps if you let us know what problem you're trying to solve, someone will know of a java friendly way to help.
Edit: I think the consensus is that you're looking at writing an IntelliJ plugin
Solution 3:[3]
Eleven years on from this question, there seems to be the Manifold preprocessor which integrates with the Java compiler and with IntelliJ via a plugin.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | sblundy |
| Solution 2 | |
| Solution 3 | Michael Kay |
