Maven generates duplicate pom.xml and pom.properties files in a jar

前端 未结 6 936
北海茫月
北海茫月 2020-12-15 04:50

I package my Maven-based Spring app with:

mvn install-DskipTests -Peverything. 

And something strange arises. In META-INF of generated jar,

相关标签:
6条回答
  • 2020-12-15 05:25

    Not sure what you mean by duplicate but the jar created by maven does come with pom.xml and pom.properties in META-INF folder. See this section of the maven getting started guide.

    0 讨论(0)
  • 2020-12-15 05:27

    I know this issue is a bit old, but I thought I'd share an obscure bit of information on this subject. I was running across the same issue, and I found that when I ran maven with Eclipse open, AND my workspace preferences were set to refresh the workspace using native hooks or polling, the extra pom.xml and pom.properties files were added by eclipse! Closing eclipse or removing the refresh workspace option solved the problem for me. This was a hard one to track down, so hopefully someone else will benefit from this.

    0 讨论(0)
  • Add

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

    to your pom.xml

    0 讨论(0)
  • 2020-12-15 05:32

    You need to do "mvn clean" and the do "mvn package" after that or just do "mvn clean package". if "mvn clean" fails due to any reason and if you do "mvn package" after that , you will see this issue again.

    0 讨论(0)
  • 2020-12-15 05:36

    It seems like this is a somewhat common problem that arises from a conflict in Eclipse, especially with the m2e-wtp integration.

    Some people are indicating that it can be fixed by including clean in the list of goals to run, e.g. mvn clean package.

    Also try to update your m2e installation and make sure you don't have multiple versions of m2e or m2eclipse (the pre-Indigo version) installed.

    Some references to other people facing this problem:

    • http://dev.eclipse.org/mhonarc/lists/m2e-users/msg01995.html
    • https://issues.sonatype.org/browse/MECLIPSEWTP-209
    • https://issuetracker.springsource.com/browse/STS-2349
    • https://github.com/sonatype/m2eclipse-extras/issues/9
    0 讨论(0)
  • 2020-12-15 05:38

    Follow up to @Dan's work around:

    I tried your solution and it appears to work -- at first blush. However, it's just delaying the eventual failure.

    It appears than anytime the workspace is refreshed the pom.xml and pom.properties files are created in the /classes directory. After that any later "package" goal will include the duplicate files in the .jar and thus break any later signing.

    If the polling is on - you "fail-fast". If it's off you can fail at arbitrary times in future builds.

    0 讨论(0)
提交回复
热议问题