How to add to the build path a folder via maven

3

I have an application using Jhipster, to make queries I added querydsl, I configured in maven to generate Q classes, these classes are being generated in the path: target / generated-sources

This folder is not in my buildpath so the project gets "broken" in eclipse, I know that via eclipse I can go to this folder and add it to the application classpath, but I would like to know if it has to be added via maven, so it would be transparent to other developers.

Thank you in advance.

    
asked by anonymous 16.04.2016 / 12:23

1 answer

2

Goal eclipse:eclipse is able to generate a valid configuration for Eclipse based on its pom.xml . Basically what it does is overwrite the .classpath file of your project.

The problem with this is that every time you change the pom.xml you need to run the command again and the build and execution run within Eclipse does not generally respect all Maven settings, since they are performed separately.

Integrating Maven into Eclipse is preferably done using the M2E plugin, which is installed in Eclipse and already comes in "Eclipse for Java EE". This plugin configures recognizes changes in Maven and manages to make the necessary updates in Eclipse. It also allows you to run self-generating code when you save your classes, as well as other facilities.

If M2E does not automatically add classpaths to the classpath, it is because you have to set up your pom.xml using build-helper-plugin to add the directory where classes are generated. See documentation examples .

Remember that the Eclipse classpath and the Maven classpath are different things. Be careful not to fall into the trap of altering the Eclipse project manually and thinking that everything is fine. In a Maven project, the Eclipse classpath is just something that must be derived from the Maven configuration and may not faithfully reproduce the classpath when you run Maven from the command line.

    
19.04.2016 / 06:05