22

I want to create a script to checkout some projects from cvs and automatically import them into eclipse. I can checkout everything into the workspace folder, but the projects don't appear in eclipse. I have to manually import them. Is there a way to import the projects using the command line?

Thanks

Kelly

Kelly Goedert
  • 1,027
  • 2
  • 11
  • 37
  • Possible duplicate: http://stackoverflow.com/questions/1718456/create-an-eclipse-project-on-the-command-line – amcnabb Feb 20 '13 at 21:39
  • 2
    This is not duplicate because in that question CDT was mentioned and solution depending on CDT was proposed and is currently the most voted for. – Paul Verest Feb 19 '14 at 05:29

4 Answers4

5

I wanted something simple without any dependencies and a plugin seemed to be the best answer. I wrote one and posted it here:

https://github.com/seeq12/eclipse-import-projects-plugin

mpderbec
  • 354
  • 3
  • 7
4

You use the -import argument:

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

This link to Eclipse documentation may be helpful:

Checking out a project from a CVS repository

Kyle Strand
  • 15,941
  • 8
  • 72
  • 167
NovusMobile
  • 1,813
  • 2
  • 21
  • 48
  • no it did not work... an exception happened and the project was not imported. The begining of the error on the log file is this... !SESSION 2012-01-18 16:25:03.424 ----------------------------------------------- eclipse.buildId=M20110909-1335 java.version=1.6.0_30 java.vendor=Sun Microsystems Inc. BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US Framework arguments: -product org.eclipse.epp.package.jee.product -application org.eclipse.cdt.managedbuilder.core.headlessbuild -import ../../workspace/subwire/ -build all -cleanBuild all – Kelly Goedert Jan 18 '12 at 18:30
  • Command-line arguments: -os linux -ws gtk -arch x86_64 -product org.eclipse.epp.package.jee.product -application org.eclipse.cdt.managedbuilder.core.headlessbuild -import ../../workspace/subwire/ -build all -cleanBuild all !ENTRY org.eclipse.osgi 4 0 2012-01-18 16:25:34.013 !MESSAGE Application error !STACK 1 java.lang.RuntimeException: Application "org.eclipse.cdt.managedbuilder.core.headlessbuild" could not be found in the registry. – Kelly Goedert Jan 18 '12 at 18:31
  • I think its CSV format instead of cvs. and you want to display data where? in your SQLite or anything else? – NovusMobile Jan 19 '12 at 05:22
  • 1
    Hey Guys, any progress on that issue? I think lots of people would need it. Thx. – Denis Jan 14 '13 at 12:11
3

A possible approach would be from Ant+Groovy: First create a build.xml file with the following content:

<?xml version="1.0" encoding="UTF-8"?>
<project name="project" default="default">  
<taskdef name="groovy"
         classname="org.codehaus.groovy.ant.Groovy"
         classpath="/home/me/workspace/Groovy/lib/groovy-all-2.1.4.jar" />  
<target name="default">
    <groovy>
        bundle = org.eclipse.core.runtime.Platform.getBundle("org.eclipse.core.resources");
        resPlugin = bundle.loadClass("org.eclipse.core.resources.ResourcesPlugin");
        root =  resPlugin.getWorkspace().getRoot();
        project = root.getProject("new");
        project.create(null);
        project.open(null);
        resPlugin.getWorkspace().save(true, null);
    </groovy>
</target>
    </project>

Then run by executing:

./eclipse -nosplash -data /home/me/workspace -application org.eclipse.ant.core.antRunner -buildfile /home/me/build.xml 

Of course, a full-fledged script will contain some more code, perhaps run using an IWorkspaceRunnable and so on but the basics is here. Just be sure that any classes that you want to use from Eclipse are located using the Platform.getBundle + bundle.loadClass mechanism.

Robert
  • 31
  • 4
2

With Eclipse 4.12, June 2019, seven years later... you do have project import by passing it as command-line argument!

https://www.eclipse.org/eclipse/news/4.12/images/pass-directory-to-launcher.png

You can import a project into Eclipse by passing its path as a parameter to the launcher.

The command would look like:

  • eclipse /path/to/project on Linux and Windows, or
  • open Eclipse.app -a /path/to/project on macOS.
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • this is useful! but how can I make it also choose a project? Especially if there is only one project in the specified path. – m4l490n Jan 19 '23 at 15:49
  • @m4l490n I suppose all you need to do is to select the parent folder of that project. – VonC Jan 19 '23 at 20:08