Java 如何跨工作区保存 Eclipse 启动配置文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/952290/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I save Eclipse launch profiles across workspaces?
提问by Jared
When I copy an Eclipse project directory, it contains the .classpath and .project files so that when I take that same directory to another Eclipse instance, I don't have to setup my build path and such (assuming that all the resources are contained in the project, and not external.)
当我复制 Eclipse 项目目录时,它包含 .classpath 和 .project 文件,因此当我将同一目录带到另一个 Eclipse 实例时,我不必设置我的构建路径等(假设所有资源都包含在项目中,而不是外部。)
However, this procedure doesn't cause launch profiles to "travel" with the directory.
但是,此过程不会导致启动配置文件随目录“移动”。
Is there some other file/directory structure I can "carry around" to another instance of Eclipse that will include my launch profiles?
是否有其他一些文件/目录结构我可以“携带”到另一个包含我的启动配置文件的 Eclipse 实例?
采纳答案by Cagatay
Try choosing a shared file location inside your workspace from the "Common" tab of the launch configurations (profiles).
尝试从启动配置(配置文件)的“通用”选项卡中选择工作区中的共享文件位置。
回答by VonC
The .launch xml files (launcher definition) are found in
.launch xml 文件(启动器定义)位于
[eclipse-workspace]\.metadata\.plugins\org.eclipse.debug.core\.launches
Just copy them into your <project>/.settings
directory.
Refresh your project, and there you have it: those launcher configuration are available, and you can copy them along the rest of your project files.
只需将它们复制到您的<project>/.settings
目录中即可。
刷新您的项目,您就拥有了:这些启动器配置可用,您可以将它们与项目文件的其余部分一起复制。
Warning: do uncheck the option "Delete configurations when associated resource is deleted"in the Run/Launching/Launch Configuration preference panel: it is common ot soft-delete a project in order to import it back again, to force a reinitialization of the eclipse metadata,... but this option, if checked, will removed your detailed launch parameters!
警告:请取消选中“运行/启动/启动配置”首选项面板中的“删除关联资源时删除配置”选项:软删除项目以再次导入它是很常见的,以强制重新初始化 eclipse元数据,...但是如果选中此选项,将删除您的详细启动参数!
See also Which eclipse files belong under Version Control, and where are the external tools launch configurations in Eclipse.
另请参阅哪些 eclipse 文件属于版本控制,以及Eclipse 中的外部工具启动配置在哪里。
Jaredadds:
贾里德补充说:
There is no .settings directory in my project directory - I created it and put the .launch file in there, refreshed my project, and it doesn't have any Run profiles. Do you have to mirror the directory structure under .metadata?
我的项目目录中没有 .settings 目录 - 我创建了它并将 .launch 文件放在那里,刷新了我的项目,它没有任何运行配置文件。.metadata下的目录结构一定要镜像吗?
Just create the .settings
directory (it is actually created when you have project specific settings as illustrated in the question "Maintaining a common set of Eclipse preferences").
Then delete the same .launch
file from the .metadata
directory.
Then refresh your project and go to the "Run Configurations" Panel: you will see your launch configurations still available, except they are stored where they belong: within your project directory and not buried under an obscure workspace metadata thingy.
只需创建.settings
目录(它实际上是在您具有项目特定设置时创建的,如问题“维护一组通用的 Eclipse 首选项”中所示)。
然后.launch
从.metadata
目录中删除相同的文件。
然后刷新您的项目并转到“运行配置”面板:您将看到您的启动配置仍然可用,除非它们存储在它们所属的位置:在您的项目目录中,而不是隐藏在模糊的工作区元数据下。
Update June 2012
2012 年 6 月更新
I always seen my launch configurations, saved under PROJECT_LOC/.settings
, automatically imported when reloading the Eclipse workspace.
However, as described in "Tip: Creating and Sharing Launch Configurations (2007)", you should be able to reference a launch configuration saved into any subdirectory of your project if you go to the "Common" tab of your "Run Configurations" wizard.
我总是看到我的启动配置,保存在PROJECT_LOC/.settings
,重新加载 Eclipse 工作区时自动导入。
但是,如“提示:创建和共享启动配置 (2007)”中所述,如果您转到“运行配置”向导的“通用”选项卡,您应该能够引用保存在项目任何子目录中的启动配置.
So saving your launcher anywhere in the project won't display them automaticallyin the "Run Configurations" section of the preferences.
But declaring a new one, sharing its launcher as a "Shared file" (as illustrated above), and then overwriting that launcher with the actual one you had previously saved would update that run configuration.
因此,将启动器保存在项目中的任何位置不会在首选项的“运行配置”部分自动显示它们。
但是声明一个新的,将其启动器共享为“共享文件”(如上图所示),然后用您之前保存的实际启动器覆盖该启动器将更新该运行配置。
回答by mkamowski
Depending on the amount of moving around you do and the number locations you move to, storing your launch files in an online storage space and then setting up folders at the new locations to synchronize with it may be a viable solution.
根据您四处走动的数量和您移动到的位置数量,将您的启动文件存储在在线存储空间中,然后在新位置设置文件夹以与其同步可能是一个可行的解决方案。
Dropboxis a decent online storage system that gives users up to 2 gigabytes of storage.
Dropbox是一款不错的在线存储系统,可为用户提供高达 2 GB 的存储空间。
Here is an example of how you can synchronize folders out side the Dropbox folder curtiousy of LifeHacker.com :
以下是如何同步 LifeHacker.com 的 Dropbox 文件夹之外的文件夹的示例:
Use either the JUNCTION utility from Sysinternals, or the MKLINK command built in to Windows Vista and Server 2008, for example:
使用 Sysinternals 的 JUNCTION 实用程序,或 Windows Vista 和 Server 2008 中内置的 MKLINK 命令,例如:
junction "C:\Documents and Settings\User\My Documents\My Dropbox\DesiredFolder" "C:\Path\To\DesiredFolder"
mklink /D "C:\Users\Steve\Documents\Dropbox\DesiredFolder" "C:\Path\To\DesiredFolder"
junction "C:\Documents and Settings\User\My Documents\My Dropbox\DesiredFolder" "C:\Path\To\DesiredFolder"
mklink /D "C:\Users\Steve\Documents\Dropbox\DesiredFolder" "C:\Path\To\DesiredFolder"
Or, if you prefer a GUI, install Link Shell Extension.
或者,如果您更喜欢 GUI,请安装 Link Shell 扩展。
[eclipse-workspace].metadata.plugins\org.eclipse.debug.core.launches
would be the DesiredFolder.
[eclipse-workspace].metadata.plugins\org.eclipse.debug.core.launches
将是 DesiredFolder。
You could also use SyncToy to echo changes from another folder to your Dropbox folder. This keeps 2 copies on disk though.
您还可以使用 SyncToy 将更改从另一个文件夹回显到您的 Dropbox 文件夹。不过,这会在磁盘上保留 2 个副本。
On OS X or Linux, try the following:
在 OS X 或 Linux 上,请尝试以下操作:
Use the ln command, for example:
使用 ln 命令,例如:
ln -s /path/to/desired-folder ~/Dropbox/desired-folder
ln -s /path/to/desired-folder ~/Dropbox/desired-folder
This works with files too:
这也适用于文件:
ln -s /path/to/desired-file ~/Dropbox/desired-file
ln -s /path/to/desired-file ~/Dropbox/desired-file
Another easy way to do this with Terminal is type the ln -s part, then from Finder drag the folder/file that you want into the Terminal window then drag the Dropbox folder and hit return.
使用终端执行此操作的另一种简单方法是键入 ln -s 部分,然后从 Finder 中将您想要的文件夹/文件拖到终端窗口中,然后拖动 Dropbox 文件夹并按回车键。
Note that an Alias file or folder does not work.
请注意,别名文件或文件夹不起作用。
Another solution could be to keep your launch files in an svn repository. Search for How to run Eclipse launch configurations programmatically?on this site. Sorry can only post one url so I used it on Dropbox.
另一种解决方案可能是将您的启动文件保存在 svn 存储库中。搜索如何以编程方式运行 Eclipse 启动配置?在这个网站上。抱歉只能发布一个网址,所以我在 Dropbox 上使用了它。
回答by Thorbj?rn Ravn Andersen
I have had good use of creating a /launch folder, and then setting the launch configuration to be "Shared file:" (the Commons panel) to the above mentioned launch folder.
我很好地使用了创建 /launch 文件夹,然后将启动配置设置为“共享文件:”(Commons 面板)到上述启动文件夹。
The resulting launch file can be checked into e.g. CVS and be pulled into a fresh workspace.
生成的启动文件可以被检入例如 CVS 并被拉入一个新的工作区。
回答by Kajal
Create a Launch Configuration with Shared File option selected under Common Tab. This will create a configuration file with .launch extension. Now in another workspace just go to Import and select Launch Configurations, choose the configurations from the directory and finish. It will appear in the Run configuration now.
使用在公共选项卡下选择的共享文件选项创建启动配置。这将创建一个扩展名为 .launch 的配置文件。现在在另一个工作区中,只需转到导入并选择启动配置,从目录中选择配置并完成。它现在将出现在运行配置中。
回答by Hari
There is an another clean way to share the launch configurations in Eclipse.
还有另一种干净的方式来共享 Eclipse 中的启动配置。
- Create a java project. For instance lets name it Launches-Configs.
- Now create a new Run Configuration for a project that you need to run.
- On the Run Configurations window navigate to Common tab. Ensure Shared File option is selected and input the Shared File location is set to \Launches-Configs\src
- Check in Launches-Configs to a VCS and share with other teams