Ida
Ida

Reputation: 2999

How to import multiple projects into Eclipse using command line?

Is there anyway that I can use command line to import multiple projects into Eclipse workspace all at once? I noticed that someone suggests using command line as follows:

eclipse -nosplash -application org.eclipse.cdt.managedbuilder.core.headlessbuild -importAll {[uri:/]/path/to/project}

But I cannot figure out the {[uri:/]/path/to/project} part correctly. Any example? Also, is the above command line the only way I can achieve this? (it seems like to depend on CDT?) Is there any other way I can do this in command line?

Thank you!

Upvotes: 11

Views: 9712

Answers (5)

shrewmouse
shrewmouse

Reputation: 6030

A few things to note:

  1. You can specify the -import option multiple times
  2. Use Linux file path separators instead of the evil DOS separators (i.e. / instead of \).
  3. The uri should point to a directory and not a project name. So, if you have a project called foo in the directory path/to/FooBar, the option would be -import path/to/FooBar

Here is a real world example that I use.

eclipsec -noSplash -data "WORKSPACE2" -application org.eclipse.cdt.managedbuilder.core.headlessbuild  -no-indexer  -import 21-6912-xx-xpathparser -import 21-6912-xx-xpathparser/lib

output:

Create.
Opening 'libxpathparser'.
Create.
Opening '21-6912-xx-xpathparser'.
Saving workspace.

Upvotes: 1

cmd
cmd

Reputation: 11841

The Eclipse CDT provides tools to import projects via the command line. You can use the following command / options to do so.

eclipse -nosplash 
  -application org.eclipse.cdt.managedbuilder.core.headlessbuild 
  -import     {[uri:/]/path/to/project} 
  -importAll  {[uri:/]/path/to/projectTreeURI} Import all projects under URI
  -build      {project_name | all} 
  -cleanBuild {project_name | all} 

Upvotes: 2

James
James

Reputation: 999

The only documentation of headlessbuild I've found so far is the source. This reveals that the argument to -importAll should be the path to a directory containing all your projects. You can use -importAll repeatedly to import multiple trees of projects.

e.g. if you have the structure

tree/
  core/
    alpha/
      .project
    beta/
      .project
  edge/
    one/
      .project
    two/
      .project

Then this will build the four projects in a workspace tree/workspace:

cd tree
eclipse -nosplash -data workspace -application org.eclipse.cdt.managedbuilder.core.headlessbuild -importAll core -importAll edge -build

On Windows, use eclipsec.exe.

Upvotes: 9

Marc
Marc

Reputation: 479

Try using the absolute path for the url. e.g. /usr/fred/foo

Upvotes: 1

Chandrayya G K
Chandrayya G K

Reputation: 8849

You can find list of eclipse runtime options here: Help > Workbench User Guide > Tasks. Format : eclipse [platform options] [-vmargs [Java VM arguments]]

Upvotes: -3

Related Questions