Eclipse / Maven and "Allow dependencies on workspace projects" can't mix banks and source?

I have what seems angular for Eclipse / Maven and "Allow workspace project dependencies." My project contains a combination of the written code and the generated code, with the generated code coming from a dependency that uses JAXWS.

The problem is that if I check "Allow Dependencies", Eclipse / Maven ignores any JAR dependencies and tries to resolve everything only by looking at the workspace, which leads to Eclipse showing errors like "Package / Class not found" (linked to the generated code), even if the project will build perfectly with Maven from the command line.

On the other hand, if I take it off, it will resolve everything just by looking at the JARs in the Maven repository. The second option usually works, but when I do something like Ctrl-click on a class or variable, I get a class file editor and "Source not found", which is not very useful. In addition, it may go out of sync if I edit the code in the IDE, but after that I do not run "maven install".

I believe this is basically a nuisance with Eclipse, but it is annoying. I consider this solution by modifying Maven dependencies to create using the source (or debugging), but I can't do it with everything. The option "Allow Dependencies" is designed to work exclusively anyway, as I described?

+6
source share
3 answers

You might want to take a look at the build helper maven plugin.

You can configure it as follows:

<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <version>1.5</version> <executions> <execution> <id>add-source</id> <phase>generate-sources</phase> <goals> <goal>add-source</goal> </goals> <configuration> <sources> <source>target/generated-sources</source> <source>target/jaxws/wsimport/java</source> </sources> </configuration> </execution> </executions> </plugin> 

This will tell your eclipse maven plugin to look at the generated sources and include it in its project path.

You can also add the generated sources manually to your class path in eclipse. (right click on the generated folder -> add build path)

+3
source

I think that since you want to link to files that exist only after the build, which you somehow force to build before you need a permitted link. You can fool just by building from Eclipse. This would leave the generated source files in place ready for reference. I think, however, that the maven philosophy could completely move the generated code to another maven artifact. This will allow you to separate the life cycle of the two groups of code, so that when you are ready to use Eclipse to edit the code with manual encoding, references to the generated classes will be allowed, because you already generated this code in the assembly a separate, independent module.

0
source

I know this is an old problem. But I met the same thing in Juno with the updated "m2e-wtp" plugin. Therefore, I am solely responsible for the benefit of other readers.

This happened only in military projects. The only thing that allowed, in the end, was to delete the ".settings" folder in the military project folder and restart eclipse.

0
source

Source: https://habr.com/ru/post/946228/


All Articles