且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何运行两次构建,以便可以使用不同的依赖项获得两个工件?

更新时间:2022-11-29 08:41:13

这可以通过在配置文件中指定依赖项来完成,例如 this答案.尽管要创建两个工件,您都必须构建项目两次.您可能还应该为每个配置文件配置 jar插件为工件分配不同的分类器.

This can be done by specifying the dependencies in profiles like in this answer. You would have to build your project two times though to create both artifacts. You should probably also configure the jar plugin per profile to give different classifiers to the artifacts.

您也可以只在配置文件中设置一个属性,然后在依赖项部分中使用该属性,而不是环境变量.

You could also just set a property in the profiles ant use this later in the dependency section instead of the environment variable.

您还可以根据当前系统的体系结构激活配置文件,以使默认情况有效:

You can also activate the profiles based on the architecture of the current system, to have a working default case:

<profile>
    <activation>
        <os>
            <arch>x86</arch>
        </os>
    </activation>
    ...
</profile>

所有激活选项均在此页面中进行了描述.

All activation options are described on this page.