Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jdt-dev] JDT Core as a library / Eclipse CLI

Hey,

And then there is also Eclipse TEA [1]; It provides a "headless" workbench implementation (actually copied from E4 unit tests ;)), which allows to basically run /any/ code from the Eclipse UI headlessly. We heavily use TEA at our company to:

1) Setup workspaces from scratch (this part of the code is currently closed source, as we're rewriting it :)). But it's not hard to implement a tiny'ish specific solution yourself.
2) Compile projects within this workspace (with build orchestration normally lacking from Eclipse).
3) Run code formatters and code generators (i.e. run Eclipse Code as well as Launch Configurations, also see [2]).
4) Run EASE scripts, which allows to do anything Jonah was referring to from a determined point in TEA taskchains ;) TEA has built-in integration for EASE.
5) Execute unit tests, execute UI tests (headlessly with Xephyr).
6) Even manipulate and commit source repositories in some locations
7) Build update sites, products, ...

The only "downside" of this approach is, that TEA lives inside Eclipse, requiring an Eclipse installation on every machine performing builds. But that would be the very same with your approach, right? :)

Feel free to ask me anything about TEA - I'm happy to spread the word :)

[1] https://www.eclipse.org/tea/
[2] https://github.com/mduft/lcdsl

Cheers,
Markus

-----Original Message-----
From: jdt-dev-bounces@xxxxxxxxxxx [mailto:jdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Jonah Graham
Sent: Sunday, March 11, 2018 4:42 PM
To: Eclipse JDT general developers list. <jdt-dev@xxxxxxxxxxx>
Subject: Re: [jdt-dev] JDT Core as a library / Eclipse CLI

Hi Sebastien,

The Eclipse EASE project provides a command line scriptable interface
to Eclipse. For example, you can in numerous languages (my example in
Python) access projects in the workspace. See an example from the
tutorial I did at EclipseCon France[1].

For example:

loadModule('/System/Resources')
workspace = getWorkspace()
print("Information about workspace ({})".format(workspace.getLocation()))
for i, project in enumerate(workspace.getProjects()):
# do something with existing projects

There are some scripts we cobbled together for creating JDT projects[2].

Christian (the project lead of EASE) created an application that
starts up plug-ins like the platform does by default, that may give
you some hits too?[3]


[1] https://github.com/jonahkichwacoders/EASE-Python-Examples/blob/master/Solutions/Share%20Solutions/show_projects_in_workspace.py
[2] https://github.com/jonahkichwacoders/EASE-Python-Examples/blob/master/Utilities/create5javaprojects.py
[3] http://git.eclipse.org/c/ease/org.eclipse.ease.core.git/tree/plugins/org.eclipse.ease/src/org/eclipse/ease/applications/RunHeadlessScript.java

HTH
Jonah

~~~
Jonah Graham
Kichwa Coders Ltd.
www.kichwacoders.com


On 11 March 2018 at 12:47, Sebastian Kürten
<sebastian.kuerten@xxxxxxxxxxxx> wrote:
> Hi,
>
> it's been a while[1] since I posted here about using Eclipse's JDT Core
> as a library in a standalone Java project. I recently discovered that
> there has been the fortunate development that five releases of this
> library have been published to Maven Central during 2017[2]. One of the
> initial problems I tried to tackle with this can now be solved: running
> the Eclipse Formatter standalone or from within 3rd party tooling!
>
> I've set up a little example, a CLI, that is designed to be a handy
> tool for running tasks that you usually perform through the Eclipse user
> interface, but from the command line or from scripts instead:
>
> https://github.com/sebkur/eclipse-cli
>
> As mentionend above, running the formatter already works[3], which I
> consider highly useful on its own. You can specify a formatter
> configuration and a number of files or directories to format
> recursively.
>
> Another thing I would be very interested in is creating and
> manipulating workspaces outside the Eclipse UI (The use case here is
> to automatically set up a number of workspaces on fresh working
> environments and adding the projects to them initially).
>
> That task seems to be a bit more involved, since it requires the
> ResourcesPlugin to be running. I could not get this working yet[2].
> Maybe someone more experienced with the Eclipse plugin has an idea how
> this could work. I appreciate any directions on this.
>
> Thanks,
> Sebastian
>
> [1]http://dev.eclipse.org/mhonarc/lists/jdt-dev/msg00879.html
> [2]http://mvnrepository.com/artifact/org.eclipse.jdt/org.eclipse.jdt.core
> [3]https://github.com/sebkur/eclipse-cli/blob/master/cli/src/main/java/de/topobyte/eclipse/cli/RunFormat.java
> [4]https://github.com/sebkur/eclipse-cli/blob/master/cli/src/main/java/de/topobyte/eclipse/cli/RunCreateWorkspace.java
>
> PS: I tried something along these lines so far to, but that does not
> work because the ResourcePlugin instance obtained is null:
>
> public static void main(String[] args) throws Exception
> {
>         EclipseStarter.main(args);
>         BundleContext bc =
>         EclipseStarter.getSystemBundleContext();
>
>         InternalPlatform platform =
>         InternalPlatform.getDefault(); platform.start(bc);
>
>         try {
>                 ResourcesPlugin plugin = ResourcesPlugin.getPlugin();
>                 Workspace workspace = new Workspace();
>         } catch (Throwable e) {
>                 System.out.println("error: " +
>                         e.getClass().getSimpleName());
>                         e.printStackTrace(); }
>
>         EclipseStarter.shutdown();
> }
> _______________________________________________
> jdt-dev mailing list
> jdt-dev@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe from this list, visit
> https://dev.eclipse.org/mailman/listinfo/jdt-dev
_______________________________________________
jdt-dev mailing list
jdt-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jdt-dev

SSI Schäfer IT Solutions GmbH | Friesachstrasse 15 | 8114 Friesach | Austria
Registered Office: Friesach | Commercial Register: 49324 K | VAT no. ATU28654300
Commercial Court: Landesgericht für Zivilrechtssachen Graz

Back to the top