问题描述
我希望能够在Eclipse中运行外部shell工具,尤其是构建器。如何设置Eclipse,以便外部命令在需要构建时运行?此外,我如何配置Eclipse,以便我可以让它根据需要手动运行一个外部命令?
什么引发了这个需要是我想要能够执行从Eclipse中构建一个sbt。我知道ScalaIDE,但它不适用于我的Android开发。
这是我现在用sbt和android-plugin做的。这些说明将同样适用于您希望从Eclipse中运行的任何外部工具。
可能要求开发人员手动启动构建将构建视为Eclipse构建器。构建器可以配置为通过各种触发器(手动构建,清理构建,文件保存等)运行。
配置sbt以构建器的形式运行: p>
-
将您的sbt项目导入Eclipse。 (请参阅。)
-
单击sbt项目,单击属性。
-
单击
下的构建器项目类型过滤器文本
。 / p> -
取消选中或删除Java构建器。如果不这样做,它可能会干扰外部构建器。如果您的外部工具没有构建,而是进行后期制作,则可以离开Java构建器。
-
单击新建按钮。选择程序,然后单击确定。
-
在编辑配置窗口中,在名称字段中输入构建器的名称。
-
对于该位置,浏览到您的java可执行文件。如果您不确定其通常使用的是哪个Java可执行文件,请查看通常用于运行sbt的脚本。
-
选择您的工作目录字段中您的sbt项目的根目录。如果您已经在Eclipse中安装了sbt项目,您可以浏览工作区,否则浏览文件系统以查找它。
-
在参数字段中,粘贴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
-
Android,您需要创建一个新的环境变量来指示Android SDK所在的位置。单击环境选项卡,单击新建,然后使用
ANDROID_SDK_ROOT
填写名称字段,并输入Android SDK路径的值。 -
单击构建选项选项卡,然后选择要在何种条件下运行构建器。
要将sbt配置为作为仅在显式请求时才能运行的外部程序运行:
-
从Eclipse中,查看工具栏上的右下角有一个手提箱图片的运行按钮。单击它并选择外部工具配置。
-
在外部工具配置窗口中,单击类型过滤器文本框下的程序项目。
-
点击外部工具配置窗口左上角的新建启动配置图标。
-
在名称字段中输入配置的名称。
-
对于该位置,浏览到您的java可执行文件。如果您不确定其通常使用的是哪个Java可执行文件,请查看通常用于运行sbt的脚本。
-
选择您的工作目录字段中您的sbt项目的根目录。如果您已经在Eclipse中安装了sbt项目,您可以浏览工作区,否则浏览文件系统以查找它。
-
在参数字段中,粘贴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
-
Android,您需要创建一个新的环境变量来指示Android SDK所在的位置。单击环境选项卡,单击新建,然后使用
ANDROID_SDK_ROOT
填写名称字段,并输入Android SDK路径的值。 -
然后启动,只需单击应用,然后单击运行。将来,您可以再次单击手提箱的运行按钮,直接选择配置。
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:
Import your sbt project into Eclipse. (See this answer.)
Right-click on the sbt project, click properties.
Click the builders item under
type filter text
.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.
Click the New button. Select Program, and click OK.
In the Edit Configuration window, enter a name for the builder in the name field.
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.
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.
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
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.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:
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".
In the External Tools Configurations window, click the Program item under the "type filter text" box.
Click the "New Launch Configuration" icon on the top-left corner of the External Tools Configurations window.
Enter a name for the configuration in the name field.
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.
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.
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
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.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命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!