简体   繁体   English

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

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

I have a multimodule maven project and distribute the resulting jar file to different parties.我有一个多模块 maven 项目并将生成的 jar 文件分发给各方。 Part of the jar file is the pom.xml file (in META-INF/maven/.../pom.xml). jar 文件的一部分是 pom.xml 文件(在 META-INF/maven/.../pom.xml 中)。

The problem with that is, that the parent pom.xml is missing which contains a complete list of the dependencies and the necessary dependency-versions etc. So I tried several things:问题在于,缺少父 pom.xml 包含完整的依赖项列表和必要的依赖项版本等。所以我尝试了几件事:

Solution 1解决方案 1 I added the effective pom to the jar file我在 jar 文件中添加了有效的 pom
Problem问题 the pom file is way too big, with too much information (partly internal, local etc) pom 文件太大,包含太多信息(部分是内部的、本地的等)
Solution 2解决方案 2 I combined two plugins and managed to additionally add the parent pom.xml file to the jar.我组合了两个插件,并设法将父 pom.xml 文件额外添加到 jar 中。
Problem问题 This is way better than S1 however the parent pom again contains a (grand)parent and also tags like <scm> which are internal and could & should not be handed to the outside world这比 S1 好得多,但是父 pom 再次包含一个(祖)父级以及像<scm>这样的标签,这些标签是内部的,并且不应该交给外界

Now I wanted to start to manipulate the parent pom and remove some parts etc. However there must be a better solution and others who have the same problem?现在我想开始操作父 pom 并删除一些部分等。但是必须有更好的解决方案和其他有同样问题的人?

What I need is (eg) a plugin which creates a clean "releasable" pom.xml file with only the dependencies (and of course artifact, groupid, version) and can then be imported by external parties into their repo without any conflicts.我需要的是(例如)一个插件,它可以创建一个干净的“可发布”pom.xml 文件,其中只有依赖项(当然还有工件、组ID、版本),然后可以由外部各方导入到他们的仓库中而没有任何冲突。 Is that possible?那可能吗?

The only thing remotely related is the eclipse tycho pom generator plugin .唯一远程相关的是 eclipse tycho pom generator 插件 It is however eclipse specific...然而,它是 eclipse 特定的......

The flatten-maven-plugin is exactly what I needed! flatten-maven-plugin正是我所需要的! Thanks to khmarbaise I use the following configuration and the pom is looking beautiful:-)感谢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