Maven 条件依赖

2023-12-28

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


您可以通过将所需的依赖项放入特定于供应商的依赖项来实现此目的profiles http://maven.apache.org/guides/introduction/introduction-to-profiles.html在你的 pom 中:

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

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

mvn -PJackrabbit install
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Maven 条件依赖 的相关文章

随机推荐