When building an ear through the Maven ear plugin, I experienced that applying package without clean can lead to inconsistent results: If I change the version of a dependency, the dependency now appears twice in the ear, in the old and the new version. If I build the ear without version numbers in the jar names, I get just one jar, but old versions are not replaced properly.
I looked at the source code
Especially the lines from 436 are interesting: There checks whether to update files in target, but apparently only checks for the absolute path and the lastmodified date.
Summarized: Am I right that changing the dependencies (or their versions) always requires to call clean before the build? Or is there some intelligence in package which I missed?
See if the issue persists by compiling the latest version of maven-ear-plugin (3.0.0, more recent than 2.10.2, itself more recent than the official 2.12.1)
As you can see in the latest code
EarMojo.java, the functioncopyModules()has changed from the 2.10.1 implementation, and might be more robust.