java如何为Maven创建新的打包类型?
我需要用Maven创建jar文件,但它们需要安装到带有“foobar”扩展的存储库中,如果它们可以有自己的打包类型,这样我们就可以通过打包来识别这些工件,那就太好了
我可以设置一种新的包装类型来实现这一点吗
你可以在下面搜索框中键入要查询的问题!
我需要用Maven创建jar文件,但它们需要安装到带有“foobar”扩展的存储库中,如果它们可以有自己的打包类型,这样我们就可以通过打包来识别这些工件,那就太好了
我可以设置一种新的包装类型来实现这一点吗
# 1 楼答案
如您所述,创建一个带有打包jar的Maven项目(如上所述here,因为没有mojo定义)。在src/main/resources/META-INF/plexus子文件夹中创建一个组件。包含以下内容的xml(假设您希望包装类型为“my custom type”,如果愿意,可以将其更改为“foobar”)
然后,在要进行定制打包的pom中,在packaging元素中声明所需的类型,并确保已指定插件,以便可以提供定制打包。声明<;扩展>;真的</扩展>;告诉Maven插件为Maven提供打包和/或类型处理程序
当项目打包时,它将是一个带有。然而,当安装/部署jar扩展时,Maven将使用组件中指定的“.foobar”扩展名将文件交付到存储库。xml
# 2 楼答案
跟进富商的原始答案:
如果按照他的建议,你使用一种包装类型
jar
,那么很可能在你引用插件的项目中,你会收到:这是因为您生成的JAR中不存在插件描述符
您可以使用以下方法绕过他提到的
No mojo definitions..
错误:这个配置可以在插件文档示例here中找到
包装类型生命周期的
maven-plugin
目标绑定到generate-resources
阶段。这是在Sonatype's official documentation中指定的