Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
337 views
in Technique[技术] by (71.8m points)

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

I package my Maven-based Spring app with:

mvn install-DskipTests -Peverything. 

And something strange arises. In META-INF of generated jar, I find duplicate pom.xml and pom.properties files. Can someone explain it? Thanks.

enter image description here

Here is extracted pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.abc.xyz</groupId>
<artifactId>migrate-app</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>migrate-app</name>
<url>http://maven.apache.org</url>
<dependencies>

..

</dependencies>

<profiles>
  <profile>
    <id>everything</id>
    <build>
      <plugins>
        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.5</source>
          <target>1.5</target>          
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.5</version>
        <configuration>
          <skipTests>true</skipTests>
        </configuration>
      </plugin>            
      </plugins>
    </build>
  </profile>
  </profiles>   

Output for command:

mvn -version

Apache Maven 3.0.4 (r1232337; 2012-01-17 15:44:56+0700) Maven home: C:apache-maven-3.0.4in.. Java version: 1.6.0_30, vendor: Sun Microsystems Inc. Java home: C:Program Files (x86)Javajdk1.6.0_30jre Default locale: en_US, platform encoding: Cp1252 OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Add

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

to your pom.xml


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...