Skip to content

About

Allows import of projects using an Eclipse command-line parameter.

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Repository files navigation

Eclipse Import Projects Plug-in

This plug-in allows import of projects and preferences using Eclipse command-line parameters. It is useful in situations where Maven is producing the .project files and Eclipse would ideally import/refresh them when launched or for Eclipse provisioning.

Installation

Install from the update site:

https://robchallen.github.io/eclipse-import-projects-plugin/

In Eclipse go to Help > Install New Software..., press Add..., paste the URL above, and select Eclipse Import Projects. The same URL works with the p2 director for scripted provisioning:

eclipse -nosplash -application org.eclipse.equinox.p2.director \
  -repository https://robchallen.github.io/eclipse-import-projects-plugin/ \
  -installIU com.seeq.eclipse.importprojects.feature.feature.group

The update site is also published as a zip on each release, which can be added as a local repository for offline installs.

Usage

When launching Eclipse, add the -importProject <root project folder> command line parameter. This will cause Eclipse to recursively search the supplied folder for .project files and import them into the workspace. If they are already present in the workspace, they will be refreshed. The path supplied must be an absolute path.

You can also supply -importPreferences exported.epf to import Eclipse preferences exported earlier.

Additionally it's possible to supply multiple -importProject and -importPreferences directives to import multiple folders and/or preferences.

  • -importProject projectFolder1 -importProject projectFolder2
  • -importPreferences prefs1.epf -importPreferences prefs2.epf or even
  • -importProject projectFolder -importPreferences prefs.epf.

Preferences are merged into the workspace: values already present that the file does not mention are left alone. This matches File > Import... > General > Preferences in the IDE, which is the same API this plug-in calls. Note that Eclipse's other preference API, IPreferencesService.importPreferences(InputStream), instead treats each node in the file as a replacement and deletes every key the file does not list -- and a preference sitting at its default when the file was exported is not written to the file at all. Versions before 3.1.0 used that API and so could silently strip settings from the target workspace.

Preferences that are only read while Eclipse starts up -- the theme is the notable one -- are read before this plug-in gets to run, so they take effect from the next launch. To have them apply immediately, import headlessly first and then start the IDE (see below). The IDE's own import wizard has the same limitation, which is why it offers to restart afterwards.

The plugin will log activity and any errors to the Eclipse Error Log view (Window > Show View > Other > Error Log).

Note that a project is registered in the workspace under the <name> in its .project file, which need not match its directory name.

Headless

The aforementioned usage will import the projects on eclipse startup and will ultimately place you in the IDE. To perform a headless-import that does not actually start the IDE, run with -application com.seeq.eclipse.importprojects.headlessimport.
On Windows use eclipsec instead of eclipse launcher. (CMD also does not know about \ for breaking long lines, replace with ^. For PowerShell use `)

eclipsec.exe -nosplash -application com.seeq.eclipse.importprojects.headlessimport \
-data <workspace-folder> -importProject <import-folder>

Alternatively, use the Equinox launcher directly:

java -jar eclipse/plugins/org.eclipse.equinox.launcher_$VERSION.jar -nosplash -data $WORKSPACE \
-application com.seeq.eclipse.importprojects.headlessimport \
-importProject $PROJECT -importPreferences $PREFERENCES

Supported Configurations

Built and tested against Eclipse 4.39 (2026-03), which is also the minimum supported version, on Java 21. Older Eclipse releases are not supported by 3.x; use the 2.0.0 JAR if you need them.

Changes in 3.1.0

-importPreferences now merges rather than replaces, and applies preferences on the UI thread. See Usage for what merging means. Before 3.1.0 the import ran on the early-startup background thread, which made workbench preference listeners fail with Invalid thread access, reported as "Error notifying a preference change listener"; the listeners that failed never applied their preference.

Breaking Changes with 3.0.0

3.0.0 is distributed as an Eclipse feature from a p2 update site rather than as a bare JAR dropped into eclipse/plugins, and it raises the minimum platform to Eclipse 4.39 / Java 21. The -importProject and -importPreferences parameters and the headless application ID are unchanged, so no command lines need to be updated.

If you previously installed the JAR by hand, delete it from eclipse/plugins before installing from the update site, otherwise two copies of the bundle will be present.

Breaking Changes with 2.0.0

2.0.0, which also introduced preference imports, changed the -import parameter for importing projects to -importProject to match -importPreferences.

Building

The build uses Maven Tycho and needs Maven 3.9+ and a JDK 21. Build with a JDK matching Bundle-RequiredExecutionEnvironment — building on a newer JDK works, but makes Tycho publish an a.jre.javase unit that does not match the bundle's declared execution environment.

mvn clean verify

The resulting p2 update site is in com.seeq.eclipse.importprojects.site/target/repository, and the same content is zipped up next to it. To try it before publishing, add the local directory as a repository in Eclipse (Help > Install New Software... > Add... > Local...) or point the p2 director at it:

eclipse -nosplash -application org.eclipse.equinox.p2.director \
  -repository file:///path/to/com.seeq.eclipse.importprojects.site/target/repository \
  -installIU com.seeq.eclipse.importprojects.feature.feature.group

Layout

Module Purpose
com.seeq.eclipse.importprojects The OSGi bundle: the plug-in itself.
com.seeq.eclipse.importprojects.feature The installable feature that wraps the bundle.
com.seeq.eclipse.importprojects.site The p2 update site (category.xml plus the landing page in web/).

Tycho is loaded as a Maven core extension from .mvn/extensions.xml; keep its version in sync with the tycho.version property in the root pom.xml. The target platform is the Eclipse Platform release named by the eclipse.release property, which is the single place to change to move the minimum supported IDE version.

Publishing

.github/workflows/publish.yml builds the site on every push to master and deploys it to GitHub Pages, which is what serves the update site URL above. Pushing a v* tag additionally attaches the zipped site to a GitHub release.

This requires Settings > Pages > Build and deployment > Source to be set to GitHub Actions once, on the repository. Forks should also change the update site URL in this README and in com.seeq.eclipse.importprojects.feature/feature.xml to their own Pages URL; the landing page itself derives the URL from wherever it is served.

Debugging

The plug-in can be debugged from the "Eclipse IDE for Eclipse Committers" package (or any Eclipse with PDE installed):

  1. File > Import... > Maven > Existing Maven Projects and select the root of the repository. m2e and the Tycho connector will configure the three modules as PDE projects.
  2. Open ImportProjects.java and put a breakpoint in earlyStartup().
  3. Select Run > Debug Configurations... and create a new Eclipse Application configuration.
  4. On the Arguments tab, add -importProject <dir> to the Program arguments section.
  5. Click Apply and then Debug; the breakpoint should be hit as the inner Eclipse starts up.

License

MIT. See LICENSE.

About

Allows import of projects using an Eclipse command-line parameter.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages