Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create an Eclipse project on the command line?

I would like to have a shell script create an entire CDT project on the command line and add it to a workspace. I'm willing to generate the .project and .cproject files myself, but I'd like something that would actually do the adding of the project to the workspace, because that is an opaque binary file that I'd rather not have to mess with.

I looked at both Buckminster and the Monkey Project, but I wasn't sure if either would do what I wanted. Anyone have any experience on this front and know what a good solution is?

Thanks,

Nathan

like image 999
Nathan Avatar asked Nov 11 '09 22:11

Nathan


People also ask

Does Eclipse have a command line?

TM TerminalA fully working command-line Terminal inside Eclipse. Just press Ctrl+Alt+T to open a local command prompt (Terminal).


1 Answers

What version of CDT are you using?

If you have the recent CDT 6+ installed, you can perform a project import (as well as build), from the command line. To do this:

eclipse -nosplash 
    -application org.eclipse.cdt.managedbuilder.core.headlessbuild 
    -import {[uri:/]/path/to/project} 
    -build {project_name | all} 
    -cleanBuild {projec_name | all}

The import switch can be used by itself. You'll need to specify the workspace you wish to import into with -data as normal to Eclipse. The switches illustrated above are provided by the CDT managedbuild plugin, but should work with non-CDT projects (if not, let me know -- I wrote the feature ;) ).

See this question on headless build for more details on the other switches.

like image 180
James Blackburn Avatar answered Oct 03 '22 20:10

James Blackburn