Maven 条件依赖 [英] maven conditional dependencies

查看:123
本文介绍了Maven 条件依赖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们希望根据客户的选择捆绑来自(Alfresco 或 Jackrabbit 或 ...)的库依赖项.依赖项的数量实际上因所选供应商而异.我们如何在 Maven 级别提供钩子,以便最终产品仅包含根据客户选择的依赖 jar.

We would like to bundle library dependencies from (Alfresco or Jackrabbit or ...) based on the customer choice. The number of dependencies actually varies based on the chosen vendor. How do we provide hooks at the maven level, so that the final product just includes the dependent jars as per customer selection.

推荐答案

您可以通过将所需的依赖项放入特定于供应商的 profiles 在你的 pom 中:

You could achieve this by putting the needed dependencies into vendor-specific profiles in your pom:

<profiles>
    <profile>
        <id>Alfresco</id>
        <dependencies>
            ...
        </dependencies>
    </profile>
    <profile>
        <id>Jackrabbit</id>
        <dependencies>
            ...
        </dependencies>
    </profile>
</profiles>

然后您可以为您的构建激活所需的配置文件,例如:

Then you can activate the desired profile for your build like:

mvn -PJackrabbit install

这篇关于Maven 条件依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆