How to remove Eclipse project related files without deleteing the source from Eclipse

杀马特。学长 韩版系。学妹 提交于 2019-12-09 05:46:08

问题


Whenever we want to create an Eclipse project with an existing source location, we will choose the existing source location(root) as the project location. Eclipse will create all the project specific files in the root directory of that source.

Now, for some reason if we want to re-create the project with different setting, how should we tell Eclipse to not remove the source but all the project related files? It's basically cleaning up all the Eclipse related files. For example, I want to create the project in some other IDE, do I have to go to the project directory and manually identify all the Eclipse related files and remove them?

When we try to delete the project from Eclipse, we are left with two choices, delete everything from the project (when checkbox is checked) or retain everything in the project (this would only remove the project from the project explorer but retains all the project related files in the root source directory).

Every time, manually deleting project related files is cumbersome. It would be good if there is anyway to delete only Eclipse related project files right from Eclipse.

Any thoughts?


回答1:


On UNIX/Linux you can do it "manually" - Open Terminal and navigate to your project's root directory then execute the following command:

find . \( -name .classpath -o -name .project -o -name .settings \) -exec rm -rf {} \;

And if someone likes aliases:

alias show_eclipse_files='find . \( -name .classpath -o -name .project -o -name .settings \)'
alias delete_eclipse_files='find . \( -name .classpath -o -name .project -o -name .settings \) -exec rm -rf {} \;'

NOTE: You'd better remove the project first from Eclipse so it won't get confused by the missing configuration.




回答2:


I've faced same problem recently and the most reasonable solution was to use export wizard with additional setup of filter types. So steps to obtain project files without eclipse settings:

  1. Right click on desired project and select Export;
  2. Choose General > File System;
  3. In opened tab select destination directory, choose file extensions to export (.html, .css and .js in my case) with Filter Types option and click Finish

Hope that my answer helps to someone




回答3:


For Windows the problem could be solved with PowerShell:

Get-ChildItem -include  .settings -recurse | Remove-Item -force -recurse
Get-ChildItem -include  .classpath -recurse | Remove-Item -force -recurse



回答4:


Thanks for this thread. I would like to do exactly the same. I am following these steps now. 1. Delete project from the Project Explorer (do not delete from disk) 2. Remove .cproject .project .metadata .settings and other eclipse configuration files manually from the disk. This is a way-around and would appreciate if there is a better way to do the same (but everything from within Eclipse). Thanks



来源:https://stackoverflow.com/questions/16586514/how-to-remove-eclipse-project-related-files-without-deleteing-the-source-from-ec

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!