Maven自定义归档扩展 - 如何使用unpack-dependencies?

时间:2013-03-13 18:06:17

标签: maven maven-2 unpack maven-dependency-plugin

我有自定义artfiact类型web-module;只是一个ZIP,但有自定义扩展名。

然后我有一个项目取决于它,我想要解压缩这个自定义类型的依赖项。 maven-dependency-plugin unpack-dependencies目标似乎符合要求,但我不断收到错误:

[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)
    ...

我已经完成了一些Googling,并了解我可以在自定义插件的 components.xml 中指定自定义unarchiver类型。以下是我的 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>

一旦安装了我的自定义插件,我再次尝试,仍然没有运气!谁知道我哪里出错?

我还尝试使用<extensions>true</extensions>将自定义扩展插件添加到错误模块的POM中。

1 个答案:

答案 0 :(得分:0)

试试这样:

<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>