title: Is there a Maven plugin or configuration that will verify the Java package declaration matches the source directory?
body: <p>I've ran into an issue with Maven a few times now where the build does not fail if there's an inconsistency between the package declaration and the path of the source file. From other Stackoverflow questions, there are several examples that shows Eclipse catches this type of error no problem and explains why Maven doesn't:</p>
  
  <p><a href="https://stackoverflow.com/questions/16773385/eclipse-says-package-declaration-does-not-match-expected-package">Eclipse says package declaration does not match expected package &quot;&quot;</a>
  <a href="https://stackoverflow.com/questions/7628686/eclipse-the-declared-package-does-not-match-the-expected-package">Eclipse: The declared package does not match the expected package</a>
  <a href="https://stackoverflow.com/questions/13414638/maven-java-package-declaration">Maven + Java package declaration</a></p>
  
  <p>There are a few different issue that can arise when Maven doesn't catch this inconsistency including run-time failures to load classes or unit tests omitted from a build without flagging any errors.</p>
  
  <p>Although Maven doesn't catch this with the compiler, is there any Maven plugin out there that will validate the package name to the source path? Or possibly some other configuration value that can be set in the pom.xml or settings.xml to get Maven to verify these are consistent?</p>