要做到你所描述的,创建一个Maven项目与包装jar(如所述
here,因为将不会有mojo定义)。在src / main / resources / META-INF / plexus子文件夹中创建一个components.xml,其中包含以下内容(假设您希望打包类型为“my-custom-type”,如果您想要将其更改为“foobar”希望)。
org.apache.maven.lifecycle.mapping.LifecycleMapping
my-custom-type
org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping
org.apache.maven.plugins:maven-resources-plugin:resources
org.apache.maven.plugins:maven-jar-plugin:jar
org.apache.maven.plugins:maven-install-plugin:install
org.apache.maven.plugins:maven-deploy-plugin:deploy
org.apache.maven.artifact.handler.ArtifactHandler
my-custom-type
org.apache.maven.artifact.handler.DefaultArtifactHandler
foobar
my-custom-type
my-custom-type
然后在具有定制包装的pom中,在包装元素中声明所需类型,并确保您已指定插件,以便可以提供定制包装。声明< extensions> true< / extensions>告诉Maven插件提供打包和/或类型处理程序到Maven。
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
name.seller.rich
test
0.0.1-SNAPSHOT
my-custom-type
name.seller.rich.maven.plugins
maven-foobar-plugin
0.0.1
true
当项目打包时,它将是一个jar文件,扩展名为.jar,但是当它被安装/部署时,Maven会将文件传递到repository,并在components.xml中指定扩展名为“.foobar”