Here's a short story that may be of interest :-) While checking the uimaj build, I noticed that when run with apache-release, it builds the xxx-sources.jar, and I was seeing messages like:
[INFO] --- maven-source-plugin:2.1.2:jar-no-fork (attach-sources-nf) @ uimaj-test-util --- [INFO] META-INF already added, skipping [INFO] META-INF\DEPENDENCIES already added, skipping [INFO] META-INF\LICENSE already added, skipping [INFO] META-INF\NOTICE already added, skipping [INFO] Building jar: C:\au\svnCheckouts\trunks\uimaj\uimaj-test-util\target\uimaj-test-util-2.3.2-SNAPSHOT-sources.jar [INFO] META-INF already added, skipping [INFO] META-INF\DEPENDENCIES already added, skipping [INFO] META-INF\LICENSE already added, skipping [INFO] META-INF\NOTICE already added, skipping This seemed peculiar, so I went looking for what was happening. Looking at the docs gave no clue, and looking at the maven source plugin sources also didn't help. I decided to try and see if I could run the build with that plugin in the Eclipse debugger. It turns out it was very easy to do, with m2eclipse. You right click the project you want to build (in this case, uimaj-test-util), and pick "Run as" -> Maven Build ... This brings up a configuration screen, where I set the profile to apache-release, and debug mode (not really needed), and clicked on Resolve Workspace Artifacts. (I had previously used m2eclipse to checkout as a maven project the maven-sources-plugin). Then I put a breakpoint in the sources plugin in the execute(), and launched in debug mode. >From there I was able to single step and found out what was happening, which is quite complex. The sources plugin creates a Jar from sources. But sources is not just what's in /src. In our builds, we use the maven-remote-resources plugin to pull in standard LICENSE/NOTICES files; that plugin puts these into .../target/maven-shared-archive-resources. That plugin *also* does some maven trick to get maven thinking that that directory is one of the "sources". The maven-sources-plugin, when it first creates an instance of the "archiver", has special code which looks through the resources to see if one is a directory ending in "maven-shared-archive-resources", as a special case. If it finds one, it adds that directory to the set of things to be zipped. Later, when the sources plugin is operating on all the "sources" in the project, it also adds this same directory to the set (no de-duplication is done yet) - so there are now two of these. When all have been added, the sources plugin does a test to see if any files were created, using: if(!archiver.getArchiver().getFiles().isEmpty()) ... Well, the getFiles() method actually gets an iterator over the set of things to be archived, and then runs the hasNext() / next() calls to get all of those. The iterator has code in it which checks for duplicates, and if found gives the warning message that started this investigation. After this statement is finished, the sources plugin goes ahead and actually runs the archiver to make the Jar. In this process, it re-does the operation of getting an iterator, and doing the hasNext() / next() methods again. So we see the messages twice. The nice discovery in this story was how easy it was to set up a maven plugin to run in debug mode :-). -Marshall
