In my maven2 project I have a directory ${basedir}/autogen
that contains some autogenerated source code files produced by wsdl2java
.
When running mvn compile
I get an compilation error, because of duplicate classes, that lives in ${basedir}/autogen
. This is true. But what is the compilation phase doing in ${basedir}/autogen
? I have not told maven to add this directory as a source directory.
And there seems to be no way of telling maven to ignore the directory.
I had a similar problem with JPA model generator. It occurred on this dependency:
I wrongly added the scope=provided and that resulted in:
I my case helped this:
I've seen this a few times. In almost all cases, it is due to the generated classes being added to the main src tree then checked into version control.
I had the same problem when using the maven-processor-plugin and found that the solution was to configure the maven-compiler plugin as follows:
-proc:none means that compilation takes place without annotation processing and therefore no duplicate classes (which are typically generated in the generate-sources phase)
I hope that helps.
In my case, it worked when I changed source directory.
New POM looks like,
Pointing just a src folder with sourceDirectory tag.
Earlier it was
Note that earlier it was working in IntellIJ, but not on cmd. Now it works on both.
I had the exact same issue. In my case the problem was that I called maven with
-f=./pom.xml
. I have no idea why this leads to a different result (would be nice if someone can explain) but maybe good to know if someone else has the same issue.