21

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

4

2 回答 2

22

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

cmakeed - CMake 编辑器

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 - 在上下文菜单中添加选项

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 编辑器

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 编辑器

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 脚本编辑器

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
于 2013-03-07T08:11:35.980 回答
8

您可以使用p2 director 应用程序通过脚本安装 Eclipse 功能。这里还有一些可能会有所帮助 链接。

于 2013-03-07T05:06:44.207 回答