在META-INF目录中添加有效的pom.xml [英] Add the effective pom.xml in the META-INF directory

查看:610
本文介绍了在META-INF目录中添加有效的pom.xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用Maven 2(版本2.0.92.2.1)构建JAR库时,该库的pom.xml被复制到JAR的META-INF/maven/[groupId]/[artifactId]/目录中.

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.

但是,在我的情况下,pom.xml有一个父母,我希望获得

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).

有办法吗?

推荐答案

您可以在安装周期内生成有效的pom.xml

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>

但是要将这个有效的pom.xml复制到JAR文件的META-INF/maven/[groupId]/[artifactId]/目录下,您将不得不编写一个自定义的Jar mojo(仅通过扩展org.apache.maven.plugin.jar.JarMojo),因为将pom.xml复制到的代码META-INF硬编码在

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).

这篇关于在META-INF目录中添加有效的pom.xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆