English 中文(简体)
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

问题回答

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.

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

WORKSPACE_DIR.metadata.pluginsorg.eclipse.core.resources.projectsYOUR_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

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

There is a ant+groovy script in a different post, see https://stackoverflow.com/a/16949573/2457383

Disclaimer: The other post is also mine :)





相关问题
What does it mean "to write a web service"?

I just asked a question about whether it was possible to write a web-page-checking code and run it from free web server, and one supporter answered and said that it was possible only if I run "a web ...

How can I use exit codes to run shell scripts sequentially?

Since cruise control is full of bugs that have wasted my entire week, I have decided the existing shell scripts I have are simpler and thus better. Here is what I have so far svn update /var/www/...

Dynamically building a command in bash

I am construcing a command in bash dynamically. This works fine: COMMAND="java myclass" ${COMMAND} Now I want to dynamically construct a command that redirectes the output: LOG=">> myfile.log ...

Why does Scala create a ~/tmp directory when I run a script?

When I execute a Scala script from the command line, a directory named "tmp" is created in my home directory. It is always empty, so I simply deleted it without any apparent problem. Of course, when I ...

Ivy, ant and start scripts

I have a project that uses ant to build and ivy for dependencies. I would like to generate the start scripts for my project, with the classpath, based on the dependencies configured in Ivy, ...

热门标签