问题
I have Java code managed by a Git repository. Currently, the directory structure is
myProject |
-- src
-- bin
-- lib
-- .git
Currently, each developer creates its own development environment under his desired tool (Eclipse/Netbeans). I would like to create a Eclipse project for this code and add it to my source repository, so that new Eclipse developers don't need to create a new project and set the dev environment manually. I'd like to have this:
myProject
|
-- src
-- bin
-- lib
-- .git
-- eclipse
|
-- .settings/
-- .project
-- .classpath
From what I've read in the web, I don't need to add the .metadata directory to the repository. Also, I know I could have dependency problems in some situations if I add the .classpath folder to the repository, but I prefer to not support these problematic situations (eg different Java compilers) than forcing the dev to manually set the classpath. Finally, I don't want to use Maven in this project.
Concisely, my requirements are - I don't want to put Eclipse project files in the root folder - I don't want to duplicate the code inside eclipse folder (that's what happens when I try to import existing code into an isolated project folder). I want it to reference the source files I have in the folder named 'src' - I want to configure Eclipse to put the compilation output (.class files) in the 'bin' folder.
That latter item I was able to set when creating the project, but I wasn't able to configure Eclipse to reference the source code (not duplicate it) without choosing a source parent directory as the project folder.
Any help is much appreciated.
回答1:
You will need to create a project in the place you want it, and then use 'linked source' directories to point to your actual source code.
more information:
Store eclipse .project files outside the project directory
回答2:
- Create your directory structure above with the eclipse subdirectory.
- Create a new Dynamic Web Application (or whatever, assuming based on .settings)
- Uncheck
Use default location
and specify youreclipse
directory, hit Next - Remove the lone source folder
- Leave
Generate web.xml...
unchecked - File > New > Folder and click Advanced>>
- Use
Link to alternate location (Linked Folder)
to create src and bin directories that are linked to the top-level src and bin. - Right-click on the project and use File > New > Source folder to add the linked src folder with an output directory of bin
- Move WebContent to WebContent.bak and create a new WebContent directory that is linked to the top level.
- Move the contents of WebContent.bak to WebContent
- Manually edit
eclipse/.settings/org.eclipse.wst.common.component
to change WebContent.bak to WebContent (is there a setting for this? couldn't find it) - Refresh the project
- Right-click the project and select Java EE Tools > Generate Deployment Descriptor Stub
来源:https://stackoverflow.com/questions/11847919/eclipse-project-directory-isolated-from-source-directory