用最小的 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 文件,其中只有依赖项(当然还有工件、groupid、版本),然后可以由外部各方导入到他们的 repo 中,而无需任何冲突。这可能吗?

唯一相关的是日食tycho pom generator plugin。然而,它是特定于日食的...

解决方法

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>