Maven custom archive extension - how do I use unpack-dependencies?

随声附和 提交于 2019-12-10 14:26:12

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!