如何确定特定包装类型的阶段

时间:2016-01-04 10:14:22

标签: java maven pom.xml

在Maven中,当我使用<packaging>jar</packaging>时,我可以看到

中定义的默认阶段
 ~/.m2/repository/org/apache/maven/maven-core/3.0.3/maven-core-3.0.3.jar/META-INF/plexus/components.xml

但是,当我使用<packaging>kar</packaging>构建Apache Karaf项目时,如何知道kar的包类型的阶段,components.xml中没有定义?

2 个答案:

答案 0 :(得分:0)

这是在karaf-maven-plugin内定义的。这个插件声明了自己的components.xml

采用代码from GitHub,这是kar包装的生命周期:

<component>
    <role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
    <role-hint>kar</role-hint>
    <implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation>
    <configuration>
        <lifecycles>
            <lifecycle>
                <id>default</id>
                <phases>
                    <process-resources>
                        org.apache.maven.plugins:maven-resources-plugin:resources
                    </process-resources>
                    <compile>
                        org.apache.karaf.tooling:karaf-maven-plugin:features-generate-descriptor
                    </compile>
                    <package>
                        org.apache.karaf.tooling:karaf-maven-plugin:kar
                    </package>
                    <install>
                        org.apache.maven.plugins:maven-install-plugin:install
                    </install>
                    <deploy>
                        org.apache.maven.plugins:maven-deploy-plugin:deploy
                    </deploy>
                </phases>
            </lifecycle>
        </lifecycles>
    </configuration>
</component>

所以这会调用:

  • process-resourcesorg.apache.maven.plugins:maven-resources-plugin:resources
  • compileorg.apache.karaf.tooling:karaf-maven-plugin:features-generate-descriptor
  • packageorg.apache.karaf.tooling:karaf-maven-plugin:kar
  • installorg.apache.maven.plugins:maven-install-plugin:install
  • deployorg.apache.maven.plugins:maven-deploy-plugin:deploy

如果您想在m2 repo中查看它,您应该查看内部(假设您使用的是4.0.3版本)

 ~/.m2/repository/org/apache/karaf/tooling/4.0.3/karaf-maven-plugin-4.0.3.jar/META-INF/plexus/components.xml

答案 1 :(得分:0)

查看META-INF/plexus/components.xml中的karaf-maven-plugin.jar

<component>
        <role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
        <role-hint>kar</role-hint>
        <implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation>
        <configuration>
            <lifecycles>
                <lifecycle>
                    <id>default</id>
                    <phases>
                        <process-resources>
                            org.apache.maven.plugins:maven-resources-plugin:resources
                        </process-resources>
                        <compile>
                            org.apache.karaf.tooling:karaf-maven-plugin:features-generate-descriptor
                        </compile>
                        <package>
                            org.apache.karaf.tooling:karaf-maven-plugin:kar
                        </package>
                        <install>
                            org.apache.maven.plugins:maven-install-plugin:install
                        </install>
                        <deploy>
                            org.apache.maven.plugins:maven-deploy-plugin:deploy
                        </deploy>
                    </phases>
                </lifecycle>
            </lifecycles>
        </configuration>
    </component>

角色org.apache.maven.lifecycle.mapping.LifecycleMapping定义生命周期配置。 role-hint是您在pom中使用的包装类型。