如何从脚本安装eclipse插件列表?

时间:2013-03-07 03:29:47

标签: eclipse eclipse-plugin eclipse-cdt

我需要一种方法来从linux中的脚本以完全无人值守的方式设置高度自定义的eclipse编码环境。定制的eclipse环境需要安装来自各种来源的大约10种不同的插件(protobuf,pydev,cmakeed,openinterminal,egit,yaml,webpageeditor等)。每次使用gui手动执行此操作需要20-30分钟。我想在脚本中自动安装插件,这样任何运行linux的人都可以使用一组自定义插件重新创建我的eclipse环境,而无需人工干预。任何人都有关于如何做到这一点的建议?

2 个答案:

答案 0 :(得分:20)

以下是安装我最喜欢的一些插件的命令行片段(在Eclipse Indigo 3.7上测试过)...诀窍是弄清楚包的“installIU”参数的值... Eclipse GUI将如果在安装程序窗口中选择了所需的包时单击“更多”链接,则显示此信息。

cmakeed - CMake editor

eclipse -nosplash -application org.eclipse.equinox.p2.director -repository http://download.eclipse.org/releases/indigo/,http://cmakeed.sourceforge.net/eclipse/ -installIU com.cthing.cmakeed.feature.feature.group

OpenInTerminal - Add option in context menu

eclipse -nosplash -application org.eclipse.equinox.p2.director -repository http://download.eclipse.org/releases/indigo/,http://eclipse-openinterminal.googlecode.com/svn/trunk/site/ -installIU OpenInTerminal.feature.group

protobuf-dt - Google Protobuffer editor

eclipse -nosplash -application org.eclipse.equinox.p2.director -repository http://download.eclipse.org/releases/indigo/,http://download.eclipse.org/modeling/tmf/xtext/updates/composite/releases/,http://protobuf-dt.googlecode.com/git/update-site -installIU com.google.eclipse.protobuf.feature.group

yedit - YAML Editor

eclipse -nosplash -application org.eclipse.equinox.p2.director -repository http://download.eclipse.org/releases/indigo/,http://dadacoalition.org/yedit -installIU org.dadacoalition.yedit.feature.group

shelled - Bash Script Editor

eclipse -nosplash -application org.eclipse.equinox.p2.director -repository http://download.eclipse.org/releases/indigo/,http://download.eclipse.org/technology/dltk/updates/,https://sourceforge.net/projects/shelled/files/shelled/update/ -installIU net.sourceforge.shelled.feature.group

网页编辑器

eclipse -nosplash -application org.eclipse.equinox.p2.director -repository http://download.eclipse.org/releases/indigo/ -installIU org.eclipse.jst.webpageeditor.feature.feature.group

<强> Pydev的
Pydev很棘手,因为它需要先安装证书......这是一个自动执行该步骤的脚本:

#!/usr/bin/python
# Add PyDev's certificate to Java's key and certificate database
# Certificate file here: http://pydev.org/pydev_certificate.cer
import os, sys, pexpect, urllib2
def main():
  # NOTE: You may have to update the path to your system's cacerts file
  certs_file = '/usr/lib/jvm/default-java/jre/lib/security/cacerts'  
  pydev_certs_url = 'http://pydev.org/pydev_certificate.cer'
  print "Adding pydev_certificate.cer to %s" % (certs_file)
  pydev_cert = open('pydev_certificate.cer', 'w')
  pydev_cert.write(urllib2.urlopen(pydev_certs_url).read())
  pydev_cert.close()
  cmd = "keytool -import -file ./pydev_certificate.cer -keystore %s" % (certs_file)
  child = pexpect.spawn(cmd)
  child.expect("Enter keystore password:")
  child.sendline("changeit")
  if child.expect(["Trust this certificate?", "already exists"]) == 0:
    child.sendline("yes")
  try:
    child.interact()
  except OSError:
    pass  
  print "done"

if __name__ == "__main__":
  main()

然后你可以运行:

eclipse -nosplash -application org.eclipse.equinox.p2.director -repository http://download.eclipse.org/releases/indigo/,http://pydev.org/updates/ -installIU org.python.pydev.feature.feature.group

答案 1 :(得分:8)

您可以使用p2 director application通过脚本安装Eclipse功能。以下是一些可能有帮助的more links