问题
I have a custom artfiact type web-module
; just a ZIP but with a custom extension.
I then have a project depending on it, I want its dependencies of this custom type to be unpacked. The maven-dependency-plugin unpack-dependencies goal seemed to fit the bill, however I keep getting the error:
[INFO] Unknown archiver type
Embedded error: No such archiver: 'web-module'.
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Unknown archiver type
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
...
I've done some Googling and understood that I can specifiy a custom unarchiver type in my custom plugin's components.xml. The following is now in my components.xml:
<component>
<role>org.codehaus.plexus.archiver.UnArchiver</role>
<role-hint>web-module</role-hint>
<implementation>org.codehaus.plexus.archiver.zip.ZipUnArchiver</implementation>
<instantiation-strategy>per-lookup</instantiation-strategy>
</component>
Once an install of my custom plugin was performed I tried again, still no luck! Anyone know where I'm going wrong?
I have also tried adding the custom extension plugin to the erroring module's POM with <extensions>true</extensions>
.
回答1:
Try it like this:
<component-set>
<components>
<!-- Life-cycle mappings -->
<component>
<role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
<role-hint>web-module</role-hint>
<implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation>
<configuration>
<phases>
<!-- You might need these as well. -->
</phases>
</configuration>
</component>
<!-- Artifact Handlers -->
<component>
<role>org.apache.maven.artifact.handler.ArtifactHandler</role>
<role-hint>web-module</role-hint>
<implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
<configuration>
<extension>web-module</extension>
<type>web-module</type>
<packaging>web-module</packaging>
</configuration>
</component>
</components>
</component-set>
来源:https://stackoverflow.com/questions/15393110/maven-custom-archive-extension-how-do-i-use-unpack-dependencies