I’m trying to automate importing projects to an Eclipse workspace via commandline (using a bash script). I have seen many posts suggesting using the CDT headless build even for non-C/C++ projects, but I want to avoid having to download CDT as my projects are all Java/Android projects and I want to be able to automate this for many people without having to make them all download CDT. I have tried the following with the JDT headless build with no avail:
eclipse -nosplash \
-application org.eclipse.jdt.apt.core.aptBuild \
-data [absolute_path_to_desired_workspace] \
-import [absolute_path_to_project_directories]
Output shows “Building workspace” and then “logout,” but opening a session of Eclipse in the workspace shows nothing in the Package explorer.
Looking at the ./metadata/.log file in the workspace doesn’t seem to show any errors with the import.
Is it not possible to automate the import of existing Java Eclipse projects into Eclipse without using the CDT headless build?
Unfortunately, JDT distribution doesn’t have any application that would support -import argument, like CDT’s
org.eclipse.cdt.managedbuilder.core.headlessbuild. But you can easily write a simple one:Your plugin.xml should contain something like:
Create, and export your plug-in as “test.myapp_1.0.0.jar”. Then you can use it as follows:
Copy all needed plug-ins to the target workspace directory:
cp -r projects/* NewWorkspace/
Import needed projects into the workspace:
eclipse -nosplash -application test.myapp.App -data NewWorkspace -import /path/to/NewWorkspace/project1 -import /path/to/NewWorkspace/project2 etc…
Now, you can safely remove test.myapp_1.0.0.jar from the Eclipse/dropins/ folder.
I’ve uploaded all the code, including the exported plug-in here: https://github.com/spektom/eclipse-import