Search code examples
windowseclipsemavenjarcode-signing

Eclipse maven-jar-plugin not signing, because of duplicate entries pom.xml and pom.properties only on Windows


I searched a lot, but I have not found any solution for this.

Environment

*** Eclipse Java EE IDE for Web Developers. Version: Kepler Release - Build id: 20130614-0229 with m2e-wtp - Maven Integration for WTP
1.0.0.20130612-1742 
*** Windows 7 up to date
*** Java SDK 1.7.0-40
*** Maven: Embedded (3.0.4/1.4.0.20130531-2315)

Problem

Errors:

Signing jars with (apache)maven-jar-plugin:2.4:sign (signing) on Linux works fine! The same maven project on Windows leads to the following error:

[INFO] jar is unsigned. (signatures missing or not parsable)
[ERROR] jarsigner: unable to sign jar: java.util.zip.ZipException: duplicate entry: META-INF/maven/.../pom.xml

Other messages:

I spotted different outputs between Linux and Windows from (apache)maven-jar-plugin:2.4:jar (default-jar)

Linux-Eclipse skips both files, because were already added:

...
[INFO] META-INF/maven/com.xyz/abc-client/pom.xml already added, skipping
[INFO] META-INF/maven/com.xyz/abc-client/pom.properties already added, skipping
...

after that the signing works fine!

The Windows ouput is not showing these two lines!!

Additional Information:

  • I can not use the (apache)maven-jarsigner-plugin, because it will lead to following error - without solution:

    [ERROR] jarsigner: cannot rename file jarfile.jar to .orig`
    
  • This github-forum website tells me that the m2e-wtp-plugin of Eclipse causing the problem, and that I should use maven on command line .... this is the absolutely last option to use!!!

  • There is also a bug "MPIR-286" on codehouse for this, but still unresolved.
  • The clean part is done by the plugin and it's the same configuration for a client-module build before the one causing the problem.

Question:

Is there a possibility to get rid of this error? I cannot use the jarsigner-plugin, because of the "rename"-error and not the jar-plugin, because of the "duplicate entry"-error ... that is in fact a very strange situation.


Solution

  • This is the solution by the question's author, moved to the appropriate section.
    To question's author: if you want to gain reputation, feel free to write a new answer, then ping me to remove this answer.

    So I found it out myself. Here is what helped me to fix the problem.

    Research

    I found this question after more research and they stated, that the maven.archiver is the cause, because it wants to create the both files after they have been copied into the jar from m2e.mavenarchiver-plugin.

    "... the m2e.mavenarchiver is creating pom.xml files etc. in the target directory, then these get pulled in by the maven archiver maven plugin, which then also creates its own files - hence the duplicates."

    So the solution is also stated on this topic site.

    Solution

    Add

     <plugin>
       <artifactId>maven-jar-plugin</artifactId>
       <configuration>
         <archive>
           <addMavenDescriptor>false</addMavenDescriptor>
         </archive>
       </configuration>
     </plugin>
    

    to your pom.xml