Search code examples
javaeclipsegitvs-web-application-project

linking git file to eclipse dynamic web project


I have a git repository which linked to a remote repository. I'm currently working on one of the folders present in this git repository. This folder contains src,META-INF,WEB-INF and jsp files. It doesn't contain .project file (to import it as a project in eclipse). I believe the reason is multiple developers use different IDEs. So uploading their settings file to git repository doesn't seem good. Question 1: How is this usually handled? What directory structure is used to share a web application in git?

To load this files into my eclipse project, i tried these 3 ways:

  1. Creating a new dynamic web project and copying the files from the git repository. After modifications copy these into the git repository. This is by far the easiest to setup and mundane task to do!

  2. Using git import of Eclipse. Import -> Git -> Projects from Git -> Existing local repositories -> (selecting the Repository) -> Import as general project -> Next -> Finish. This gives kind of a file view in eclipse. But navigating between java classes and other content assistant features of Eclipse are not working in this method!

  3. I tried creating a dynamic web project and linking the files. I could link the src folder easily. But mapping WEB-INF,META-INF folders inside WebContent folder and mapping .jsp files into direct path of the project doesn't seems to be working!

Question 2: Could you make any of these 3 steps better? Or is there any other way to map these files?

Here is the folder structure:

├───.gitFolder
│
├───AnotherProject
│   └───itsSubDirectories
└───DesiredProject
    ├───META-INF
    ├───src
    │   └───com
    │       └───pack
    │           ├───module1
    │           └───module2
    ├───WEB-INF
    │   ├───classes
    │   │   └───resources
    │   └───lib
    └───jspFiles

Solution

  • It's my first time to see java source folder under web app resource...

    In your 3rd way, the Wizard for creating dynamic web project does not allow empty Content directory. However, you can modify the config file .settings/org.eclipse.wst.common.component and change the value of source-path attribute to "/".

    <!-- following element represent the "Content directory" setting.  -->
    <wb-resource deploy-path="/" source-path="/WebContent"/>
    

    My solutions is:

    1. Create a temporary dynamic web project using Wizard. You have to modify config files if the project name is different than DesiredProject.
    2. Delete the project and modify .settings/org.eclipse.wst.common.component
    3. Copy Eclipse config files .eclipse,.eclipse.classpath.settings folder to DesiredProject
    4. Using git "Import exists projects" and select DesiredProject.

    A known side effect is deploying this web project will be slower, because the files under src will be copy.