views:

259

answers:

3

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

+1  A: 

I believe all you need is to do is create a folder here:

WORKSPACE_DIR\.metadata\.plugins\org.eclipse.core.resources\.projects\YOUR_PROJECT_NAME

and a .location file in it.

You can either use the Eclipse Resources API, or try to implement it yourself based on the current implementation

I don't know if there's an easiest way

Alexandre Pauzies
So basically what you're saying is that I need to roll it myself rather than making eclipse do it for me?Also, in that directory I notice a lot more project folders than I have actual projects, which suggests to me that there's also a separate registry of projects somewhere that I'd have to add my own project to.
Nathan
Alexandre Pauzies
+1  A: 

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.

James Blackburn
I looked briefly at this, but I didn't realize that 'import' meant 'import from source directory'. This seems like it might be at least on the right track. A couple questions: Is there a way to specify a project name? What is the default? Also, this doesn't appear to work when eclipse is running. Am I doing something wrong?Thanks!
Nathan
A: 

This page contains also some convenience script: http://lugendal.wordpress.com/2009/07/22/eclipse-ctd-new-project-fast/

ff