Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jdt-dev] Using JDT as dependency in a project

Hello,

as so many projects rely on the Eclipse formatter for formatting their
source code, I find it fundamental to be able to run the Eclipse
formatter programatically. I found this[1] section in the JDT
Programmer's Guide that explains how to do that.

I'm able to use that approach in a plain Java project (not an Eclipse
plugin) by including the Maven dependency
'org.eclipse.jdt:org.eclipse.jdt.core:3.10.0' in my project, which can
be resolved from Maven Central.

This is however a very old version which does not work the same way
Eclipse Mars or Neon does. Searching through the web, I found a
separate Maven repository[2], that contains a much more recent version
'org.eclipse.jdt:org.eclipse.jdt.core:3.13.0.v20160913-0926' of that
artifact.

That artifact can't be used however, because it does not contain proper
references to its dependencies such as 'org.eclipse.text' and others.
The result ist that the CodeFormatter's format() method returns a
reference to TextEdit that cannot be resolved.

Is there some other Maven repository with recent versions of the JDT
libraries somewhere that I am missing or is it just impossible to use
JDT in simple Java projects?

Thanks,
Sebastian

[1]
http://help.eclipse.org/neon/topic/org.eclipse.jdt.doc.isv/guide/jdt_api_codeformatter.htm?cp=3_0_0_8
[2]
https://repo.eclipse.org/content/repositories/eclipse



Back to the top