Add the effective pom.xml in the META-INF directory

折月煮酒 提交于 2019-12-01 07:06:03

问题


When I build a JAR library using Maven 2 (version 2.0.9 or 2.2.1), the pom.xml of the library is copied in the META-INF/maven/[groupId]/[artifactId]/ directory of the JAR.

However, in my case, the pom.xml has a parent, and I would prefer to get the effective-pom instead of the original pom.xml file (or eventually, having both of them).

Is there a way to do that?


回答1:


You can generate the effective-pom.xml during install cycle

<plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-help-plugin</artifactId>
     <version>2.1.1</version>
     <executions>
        <execution>
           <phase>generate-resources</phase>
       <goals>
          <goal>effective-pom</goal>
       </goals>
       <configuration>
          <output>${project.build.outputDirectory}\effective-pom.xml</output>
       </configuration>
      </execution>
  </executions>
</plugin>

But to copy this effective-pom.xml to under META-INF/maven/[groupId]/[artifactId]/ directory of the JAR file, you will have to write a custom Jar mojo (just by extending org.apache.maven.plugin.jar.JarMojo) because the code that copies the pom.xml to META-INF is hard-coded in org.apache.maven.archiver.MavenArchiver (Line 487) (and i think there is no apparent way to set/override this behavior from pom.xml).



来源:https://stackoverflow.com/questions/4254812/add-the-effective-pom-xml-in-the-meta-inf-directory

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!