当前位置:K88软件开发文章中心编程工具Maven → 文章内容

Apache Maven 构建配置文件

减小字体 增大字体 作者:佚名  来源:网上搜集  发布时间:2019-1-24 10:44:40

od检查构建的输出看看有什么不同。通过 Maven 设置激活 Profile打开 Maven 的 settings.xml 文件,该文件可以在 %USER_HOME%/.m2 目录下找到,%USER_HOME% 表示用户主目录。如果 settings.xml 文件不存在则需要创建一个。像在下面例子中展示的一样,使用 activeProfiles 节点添加 test 配置作为激活的 Profile。<settings xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <mirrors> <mirror> <id>maven.dev.snaponglobal.com</id> <name>Internal Artifactory Maven repository</name> <url>http://repo1.maven.org/maven2/</url> <mirrorOf>*</mirrorOf> </mirror> </mirrors> <activeProfiles> <activeProfile>test</activeProfile> </activeProfiles></settings>现在打开命令控制台,跳转到 pom.xml 所在目录,并执行下面的 mvn 命令。不要使用 -P 选项指定 Profile 的名称。Maven 将显示被激活的 test Profile 的结果。C:\MVN\project>mvn test通过环境变量激活 Profile现在从 maven 的 settings.xml 中删除激活的 Profile,并更新 pom.xml 中的 test Profile。将下面的内容添加到 profile 元素的 activation 元素中。当系统属性 “env” 被设置为 “test” 时,test 配置将会被触发。创建一个环境变量 “env” 并设置它的值为 “test”。<profile> <id>test</id> <activation> <property> <name>env</name> <value>test</value> </property> </activation></profile>现在打开命令控制台,跳转到 pom.xml 所在目录,并执行下面的 mvn 命令。C:\MVN\project>mvn test通过操作系统激活 Profileactivation 元素包含下面的操作系统信息。当系统为 windows XP 时,test Profile 将会被触发。<profile> <id>test</id> <activation> <os> <name>Windows XP</name> <family>Windows</family> <arch>x86</arch> <version>5.1.2600</version> </os> </activation></profile>现在打开命令控制台,跳转到 pom.xml 所在目录,并执行下面的 mvn 命令。不要使用 -P 选项指定 Profile 的名称。Maven 将显示被激活的 test Profile 的结果。C:\MVN\project>mvn test通过现存 / 缺失的文件激活 Profile现在使用 activation 元素包含下面的操作系统信息。当 target/generated-sources/axistools/wsdl2java/com/companyname/group 缺失时,test Profile 将会被触发。<profile> <id>test</id> <activation> <file> <missing>target/generated-sources/axistools/wsdl2java/ com/companyname/group</missing> </file> </activation></profile>现在打开命令控制台,跳转到 pom.xml 所在目录,并执行下面的 mvn 命令。不要使用 -P 选项指定 Profile 的名称。Maven 将显示被激活的 test Profile 的结果。C:\MVN\project>mvn test

上一页  [1] [2] 


Apache Maven 构建配置文件