You could only compile on IntelliJ IDEA 15 and guard the call with an if statement. For example:
final BuildNumber build = ApplicationInfo.getInstance().getBuild();
if (build.getBaselineVersion() >= 143) {
// call setUseClasspathJar() here
}
The build number ranges for different IntelliJ Platform-based products are available here.
Another option would be to use reflection to call the method, if it is available. This is a lot more verbose, but com.intellij.util.ReflectionUtil
is available to make it a little easier:
final Method method =
ReflectionUtil.getDeclaredMethod(SimpleJavaParameters.class,
"setUseClasspathJar", boolean.class);
if (method != null) {
try {
method.invoke(parameters, true);
}
catch (IllegalAccessException e1) {
throw new RuntimeException(e1);
}
catch (InvocationTargetException e1) {
throw new RuntimeException(e1);
}
}