Build pesky java project in Eclipse

I have a particular java project in Eclipse and every time I clone it fresh, I have to manually set up the build path and project properties.

Fix output folders

In Eclipse, I select the project and press Alt-Enter to bring up the Build path.

Let’s say my project is project and the source folder is project/src.

I change the Default output folder from project/bin to project/target/classes and check Allow output folders for source folders.

When prompted to remove the old output location and its content, I answer Yes.

A project build commences. Since I have more changes, I stop it.

Project facets

Under Project facets, I select Java 1.7 and Apply.

Once I get a chance, I stop validation because I still have more changes.

In Project facets, I select Dynamic web module 3.0.

Futher configuration is available. I click it and set

Context root = project
Content directory = src/main/webapp

I leave Generate web.xml unchecked.

Stop the project build.

In Project facets, I select Javascript and JAX-RS (REST web services).

Further configuration is available for JAX-RS but I do not make any changes at this time.

Apply and stop the project build.

Source folders

Select Java build path / Source.

Add folders for

  • src/main/java
  • src/main/resources
  • src/test/java
  • src/test/resources

Remove folder for

  • project/src
     

Apply and close and this time allow the build.

Maven update

Once the build finishes, I select Maven / Update project.

Package references should now be error free. Dependencies should now be resolved. The pom.xml should now be in target folder.

In project properties, select Deployment assembly. Add Java build path entries / Maven dependencies

Deply to tomcat

The project should now be ready to deploy to tomcat.

In Servers tab, right-click Tomcat and select Add or remove and add the project. Then right-click Tomcat and select Publish.

Then Start the project.

The project should be available at http://localhost:8080/project/