java – maven相同的属性每个配置文件
发布时间:2020-05-24 01:32:11 所属栏目:Java 来源:互联网
导读:我面临着每个配置文件的maven属性问题.我有两个配置文件,每个配置文件具有相同的属性’prop.key’,具有不同的值.当我调用mvn clean package -PA -PB或mvn clean package -PB -PA时,两者都使用相同的值’B-1.0-SNAPSHOT’.我正在使用maven 3.0.4. 在我的POM下
|
我面临着每个配置文件的maven属性问题.我有两个配置文件,每个配置文件具有相同的属性’prop.key’,具有不同的值.当我调用mvn clean package -PA -PB或mvn clean package -PB -PA时,两者都使用相同的值’B-1.0-SNAPSHOT’.我正在使用maven 3.0.4. 在我的POM下面: <?xml version="1.0" encoding="UTF-8"?>
<project 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/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test.module</groupId>
<artifactId>test-module</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<prop.key>UNKNOWN</prop.key>
</properties>
<profiles>
<profile>
<id>A</id>
<properties>
<prop.key>A-${project.version}</prop.key>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<id>A</id>
<phase>package</phase>
<configuration>
<tasks name="a" description="a-desc">
<echo message="RUN A = ${prop.key}" level="info"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>B</id>
<properties>
<prop.key>B-${project.version}</prop.key>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<id>B</id>
<phase>package</phase>
<configuration>
<tasks name="b" description="b-desc">
<echo message="RUN B = ${prop.key}" level="info"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
我找到了‘similar topic’但结果相反! 感谢您的任何建议和帮助. 解决方法你可以写mvn包-PA,B 简而言之. 结果是一样的: 这是maven的正确行为. 一个属性每次运行只能有一个特定值.您可以使用配置文件中的版本覆盖“默认值”.但是如果你在两个配置文件中重新定义并激活两个配置文件,其中一个配置文件“获胜”. 对于同一个属性,每个配置文件不可能有一个值.配置文件没有自己的变量范围.属性始终是全局的. (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
