[英]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.