I got this inherited project using Maven/m2e as the build automation tool. All nice & cool except that this project, checked out of SVN as is, is broken… meaning it fails to build, with several duplicate class errors:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.1:compile (default-compile) on project myproj: Compilation failure: Compilation failure:
[ERROR] \Users\Daniel\workspace\myproj\target\generated-sources\cxf\org\package1\services\ClassA.java:[36,7] duplicate class: org.package1.services.ClassA
Now, it’s true that ClassA exists in the build environment 3 times:
c:/Users/Daniel/workspace/myproj/src/main/java/org/package1/services/ClassA.java
c:/Users/Daniel/workspace/myproj/src/main/java/org/package1/www/services/ClassA.java
c:/Users/Daniel/workspace/myproj/target/generated-sources/cxf/org/package1/services/ClassA.java
But they belong to different packages:
- package org.package1.services;
- package org.package1.www.services;
So, why would the compiler complain about a duplicate class?
(Or is it Maven that’s complaining?)
I am not familiar with the design considerations of the original author, so any idea how to resolve these duplicates would be much appreciated.
You’ve got three classes, in two packages. Therefore two of the classes are in the same package. These two files:
… are both contributing
org.package1.services.ClassA(which is the fully-qualified class name the compiler is complaining about, note). It’s not clear which one you should be using, based on the information you’ve given.