如何配置Eclipse来运行外部构建器或shell命令? [英] How can I configure Eclipse to run an external builder or shell command?

查看:254
本文介绍了如何配置Eclipse来运行外部构建器或shell命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够在Eclipse中运行外部shell工具,尤其是构建器。如何设置Eclipse,以便外部命令在需要构建时运行?此外,我如何配置Eclipse,以便我可以让它根据需要手动运行一个外部命令?



什么引发了这个需要是我想要能够执行从Eclipse中构建一个sbt。我知道ScalaIDE,但它不适用于我的Android开发。

解决方案

这是我现在用sbt和android-plugin做的。这些说明将同样适用于您希望从Eclipse中运行的任何外部工具。



可能要求开发人员手动启动构建将构建视为Eclipse构建器。构建器可以配置为通过各种触发器(手动构建,清理构建,文件保存等)运行。



配置sbt以构建器的形式运行: p>


  1. 将您的sbt项目导入Eclipse。 (请参阅此答案。)


  2. 单击sbt项目,单击属性。


  3. 单击下的构建器项目类型过滤器文本。 / p>


  4. 取消选中或删除Java构建器。如果不这样做,它可能会干扰外部构建器。如果您的外部工具没有构建,而是进行后期制作,则可以离开Java构建器。


  5. 单击新建按钮。选择程序,然后单击确定。


  6. 在编辑配置窗口中,在名称字段中输入构建器的名称。


  7. 对于该位置,浏览到您的java可执行文件。如果您不确定其通常使用的是哪个Java可执行文件,请查看通常用于运行sbt的脚本。


  8. 选择您的工作目录字段中您的sbt项目的根目录。如果您已经在Eclipse中安装了sbt项目,您可以浏览工作区,否则浏览文件系统以查找它。


  9. 在参数字段中,粘贴Java参数,路径到您的 sbt-launch.jar (再次看到您通常的命令行sbt启动脚本)加上您要sbt执行的任何命令。例如,在Windows上,我使用:
    -Djline.terminal = jline.UnixTerminal -XX:MaxPermSize = 256m -Xmx512M -XX:+ CMSClassUnloadingEnabled -jar c:/ cygwin / home / [username ] /bin/sbt-launch.jar android:package-debug android:start-emulator


  10. Android,您需要创建一个新的环境变量来指示Android SDK所在的位置。单击环境选项卡,单击新建,然后使用 ANDROID_SDK_ROOT 填写名称字段,并输入Android SDK路径的值。


  11. 单击构建选项选项卡,然后选择要在何种条件下运行构建器。







要将sbt配置为作为仅在显式请求时才能运行的外部程序运行:


  1. 从Eclipse中,查看工具栏上的右下角有一个手提箱图片的运行按钮。单击它并选择外部工具配置。


  2. 在外部工具配置窗口中,单击类型过滤器文本框下的程序项目。


  3. 点击外部工具配置窗口左上角的新建启动配置图标。


  4. 在名称字段中输入配置的名称。


  5. 对于该位置,浏览到您的java可执行文件。如果您不确定其通常使用的是哪个Java可执行文件,请查看通常用于运行sbt的脚本。


  6. 选择您的工作目录字段中您的sbt项目的根目录。如果您已经在Eclipse中安装了sbt项目,您可以浏览工作区,否则浏览文件系统以查找它。


  7. 在参数字段中,粘贴Java参数,路径到您的 sbt-launch.jar (再次看到您通常的命令行sbt启动脚本)加上您要sbt执行的任何命令。例如,在Windows上,我使用:
    -Djline.terminal = jline.UnixTerminal -XX:MaxPermSize = 256m -Xmx512M -XX:+ CMSClassUnloadingEnabled -jar c:/ cygwin / home / [username ] /bin/sbt-launch.jar android:package-debug android:start-emulator


  8. Android,您需要创建一个新的环境变量来指示Android SDK所在的位置。单击环境选项卡,单击新建,然后使用 ANDROID_SDK_ROOT 填写名称字段,并输入Android SDK路径的值。


  9. 然后启动,只需单击应用,然后单击运行。将来,您可以再次单击手提箱的运行按钮,直接选择配置。



I want to be able to run external shell tools from within Eclipse, especially builders. How can I set up Eclipse so an external command gets run when a build is needed? Also, how can I configure Eclipse so that I can tell it to run an external command manually on demand?

What sparked this need was that I want to be able to perform an sbt build from within Eclipse. I am aware of ScalaIDE, but it doesn't work for my Android development.

解决方案

Here's how I am doing it with sbt and the android-plugin presently. These instructions will apply equally well to any kind of external tool you'd like to run from within Eclipse.

It's possible to require the developer to start the build manually or to treat the build as an Eclipse builder. The builder can be configured to run by various triggers (a manual build, clean build, after file save, etc.)

To configure sbt to run as builder:

  1. Import your sbt project into Eclipse. (See this answer.)

  2. Right-click on the sbt project, click properties.

  3. Click the builders item under type filter text.

  4. Uncheck or remove the Java builder. If you don't, it may interfere with the external builder. If your external tool isn't building, but doing something post-build, you can leave the Java builder.

  5. Click the New button. Select Program, and click OK.

  6. In the Edit Configuration window, enter a name for the builder in the name field.

  7. For the location, browse to your java executable. If you're not sure where it is or which java executable you normally use, take a look at the script you normally use to run sbt.

  8. Choose the root directory of your sbt project in the Working Directory field. If you already have your sbt project in Eclipse, you can browse workspace, otherwise browse the file system to find it.

  9. In the arguments field, paste Java parameters, the path to your sbt-launch.jar (again, see your usual command-line sbt launch script) plus whatever commands you want sbt to perform. For example, on Windows I use: -Djline.terminal=jline.UnixTerminal -XX:MaxPermSize=256m -Xmx512M -XX:+CMSClassUnloadingEnabled -jar c:/cygwin/home/[username]/bin/sbt-launch.jar android:package-debug android:start-emulator

  10. If you're building for Android, you'll need to create a new environment variable to indicate where the Android SDK is located. Click on the environment tab, click New, and then fill in the name field with ANDROID_SDK_ROOT and the value with the path to your Android SDK.

  11. Click on the build options tab and choose under what conditions you'd like to run the builder.


To instead configure sbt to run as an external program that will only be run when explicitly requested:

  1. From Eclipse, look on the toolbar for a run button that has a picture of a suitcase on the lower-right corner. Click it and select "External Tools Configurations".

  2. In the External Tools Configurations window, click the Program item under the "type filter text" box.

  3. Click the "New Launch Configuration" icon on the top-left corner of the External Tools Configurations window.

  4. Enter a name for the configuration in the name field.

  5. For the location, browse to your java executable. If you're not sure where it is or which java executable you normally use, take a look at the script you normally use to run sbt.

  6. Choose the root directory of your sbt project in the Working Directory field. If you already have your sbt project in Eclipse, you can browse workspace, otherwise browse the file system to find it.

  7. In the arguments field, paste Java parameters, the path to your sbt-launch.jar (again, see your usual command-line sbt launch script) plus whatever commands you want sbt to perform. For example, on Windows I use: -Djline.terminal=jline.UnixTerminal -XX:MaxPermSize=256m -Xmx512M -XX:+CMSClassUnloadingEnabled -jar c:/cygwin/home/[username]/bin/sbt-launch.jar android:package-debug android:start-emulator

  8. If you're building for Android, you'll need to create a new environment variable to indicate where the Android SDK is located. Click on the environment tab, click New, and then fill in the name field with ANDROID_SDK_ROOT and the value with the path to your Android SDK.

  9. Then to launch, just click apply then click run. In the future, you can just click the run button with the suitcase again and pick the configuration directly.

这篇关于如何配置Eclipse来运行外部构建器或shell命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆