繁体   English   中英

用最少的 pom / 父 pom.xml / flattened / regenerated pom 创建一个 jar 工件 [maven]

[英]Create a jar artifact with minimal pom / parent pom.xml / flattened / regenerated pom [maven]

我有一个多模块 maven 项目并将生成的 jar 文件分发给各方。 jar 文件的一部分是 pom.xml 文件(在 META-INF/maven/.../pom.xml 中)。

问题在于,缺少父 pom.xml 包含完整的依赖项列表和必要的依赖项版本等。所以我尝试了几件事:

解决方案 1 我在 jar 文件中添加了有效的 pom
问题 pom 文件太大,包含太多信息(部分是内部的、本地的等)
解决方案 2 我组合了两个插件,并设法将父 pom.xml 文件额外添加到 jar 中。
问题 这比 S1 好得多,但是父 pom 再次包含一个(祖)父级以及像<scm>这样的标签,这些标签是内部的,并且不应该交给外界

现在我想开始操作父 pom 并删除一些部分等。但是必须有更好的解决方案和其他有同样问题的人?

我需要的是(例如)一个插件,它可以创建一个干净的“可发布”pom.xml 文件,其中只有依赖项(当然还有工件、组ID、版本),然后可以由外部各方导入到他们的仓库中而没有任何冲突。 那可能吗?

唯一远程相关的是 eclipse tycho pom generator 插件 然而,它是 eclipse 特定的......

flatten-maven-plugin正是我所需要的! 感谢khmarbaise ,我使用了以下配置,并且 pom 看起来很漂亮:-)

          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>flatten-maven-plugin</artifactId>
            <version>1.2.2</version>
            <configuration>
                <pomElements>
                    <repositories>flatten</repositories>
                </pomElements>
            </configuration>
            <executions>
                <execution>
                    <id>flatten</id>
                    <phase>process-resources</phase>
                    <goals>
                        <goal>flatten</goal>
                    </goals>
                </execution>
                <execution>
                    <id>flatten.clean</id>
                    <phase>clean</phase>
                    <goals>
                        <goal>clean</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM