Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
324 views
in Technique[技术] by (71.8m points)

java - How do I save Eclipse launch profiles across workspaces?

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.)

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The .launch xml files (launcher definition) are found in

[eclipse-workspace].metadata.pluginsorg.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.

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!

See also Which eclipse files belong under Version Control, and where are the external tools launch configurations in Eclipse.


Jared adds:

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?

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.


Update June 2012

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.

shared file for launcher

So saving your launcher anywhere in the project won't display them automatically in 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...