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

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


Back to the top