简体   繁体   English

如何在pom插件中将pom设置为默认工件?

[英]How do I set the pom as the default artifact in a maven plugin?

I am writing a Maven plugin, and I don't need to attach any real artifacts to the project (it is a product, with no intention to have anything depend on it). 我正在编写一个Maven插件,不需要在项目中附加任何实际的构件(这是一种产品,无意依赖于此)。 The final artifact (a tgz package, for a firmware installation), is quite large, and thus I don't want it in local or our nexus repository taking up space for no reason -- we push it to other services where it is retrieved from in operations. 最终的工件(用于固件安装的tgz软件包)非常大,因此我不希望它在本地或我们的nexus存储库中无故占用空间-我们将其推送到其他服务中以进行检索从操作中

Therefore, I want to tell Maven that there is no default artifact, or that just the pom itself needs to be deployed. 因此,我想告诉Maven,没有默认的工件,或者只是pom本身需要部署。 In the plugin, I have tried setting the default artifact (MavenProject.setArtifact) to the pom itself, but this leads to issues on release because then Maven tries to deploy the pom twice, which we have Nexus set up to not allow for non-snapshot versions. 在该插件中,我尝试将默认工件(MavenProject.setArtifact)设置为pom本身,但这会导致发行时出现问题,因为Maven尝试两次部署pom,我们将Nexus设置为不允许非快照版本。

If I don't setArtifact at all, I get: 如果我完全不设置setArtifact ,我将得到:

The packaging for this project did not assign a file to the build artifact

My project is using a plugin with a custom lifecycle, defined in a components.xml . 我的项目正在使用具有自定义生命周期的插件,该插件在components.xml定义。 I have tried to set the extension and packaging to pom , but that didn't help. 我试图将扩展名和包装设置为pom ,但这没有帮助。

<component> ... <configuration> <extension>pom</extension> <packaging>pom</packaging> <addedToClasspath>false</addedToClasspath> <lifecycles> ... </configuration> </component>

Is there a way to tell Maven that the pom is the only artifact to deploy? 有没有办法告诉Maven pom是唯一要部署的工件?

Digging into the source code of maven, specifically DefaultProjectInstaller which is used by the maven-install-plugin , it looks like this is not currently possible. 深入研究maven的源代码,特别是maven-install-plugin使用的DefaultProjectInstaller ,看来目前无法实现。

The only way Maven allows just the pom file itself as the artifact is if the packaging of the project itself is pom . 只有这样,Maven的允许在POM文件本身作为神器是,如果项目本身的包装是pom Even if the artifact packaging is pom , it tries to add it again (hence my error above). 即使artifact包装是pom ,它也会尝试再次添加它(因此出现了我上面的错误)。

So the only workaround for me seems to be to add another, perhaps empty, file as my artifact and let it push that file instead. 因此,对我而言,唯一的解决方法似乎是添加另一个(可能为空)文件作为我的工件,并让其推送该文件。

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

相关问题 编辑:如何从Maven插件在Project pom中设置变量? - Edit: How do I set variables in a Project pom from a Maven Plugin? 如何在不使用依赖项的情况下在命令行下载 Maven 工件:get 或 maven-download-plugin? - How do I download a Maven artifact at the command line without using dependency:get or maven-download-plugin? 如何跳过Maven默认部署而不是在pom中使用deploy插件? - How to skip maven default deploy rather using deploy plugin in pom? 如何解决pom.xml中的缺少工件问题 - How do I solve the Missing Artifact problem in pom.xml maven-help-plugin:评估失败,并显示“无法获取工件的POM” - maven-help-plugin:evaluate fails with “Unable to get the POM for the artifact” 实现插件时如何设置比较器以比较Maven工件版本? - How to set comparator for comparing maven artifact versions when implementing a plugin? 我如何在使用Maven为Linux上的Jenkins编译cobertura-plugin时解决丢失的工件 - How do i resolve missing artifact while using maven to compile cobertura-plugin for Jenkins on linux 如何使用Maven的Java API访问Maven Artifact POM? - How can I access Maven Artifact POM using Maven's Java API? 如何在 maven pom 中为缺少的环境变量设置默认值 - How to set default values for missing environment variables in maven pom 如何将版本 maven 插件添加到 pom.xml? - How do to add versions maven plugin to pom.xml?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM