Search code examples
javaeclipsemavenbuildm2eclipse

Eclipse build automatically to do maven build?


I have my main web application(has its own POM) that is dependent on module A((has its own POM). When i make a build using mvn install on web application, it dependent modules are also built in to jar file and ultimately included under WEB-INF/lib folder of main web app.

But that does not happen in when i make build using eclipse kepler (containing both maven projects i.e main web app and its dependent module A). When building with eclipse, it just put the modified classes under moduleA/target/classes/ folder but does not make any updated jar file and put it under WEB-INF/lib folder of main web app.

Is there a setting where i can configure eclipse building the project same way as maven does (which will really save lot of time and help in hot deployment) ?. It used to work in one of my projects looks like some configuration is required for this.

looks like m2e connector(i have SonarQube) needs some configuration to make eclipse build in the same fashion as maven build

When i do the project > right click > mvn install , i am able to make jar file.

But what i want is eclipse build automatically option do the build for project/module wherever modification is done , construct the jar and include it in parent WEB-INF/lib folder if it is dependent module ?


Solution

  • Assuming you're using the Java EE flavour of Eclipse, you can easily deploy Maven based web applications to a local server (like Tomcat, Wildfly...) from the server view.

    m2e-wtp, included in recent Eclipse Java EE distros, takes care of configuring all Eclipse settings based on your project pom.xml configuration and dependencies.

    See this screencast to see how simple it is : https://www.youtube.com/watch?v=TksoKkSP208

    For the record, deployment/publishing is performed by each server adapter differently. They're responsible for publishing the proper jars under the WEB-INF/lib folder of the deployed application. Dependent jar projects are automatically zipped and deployed to WEB-INF/lib without user interaction