为什么 属性 激活 Maven 不起作用?
why maven activation by property doesn't work?
我有一个 Maven 配置文件,它由在同一文件中设置的 属性 激活:
<properties>
<platform>vanilla</platform>
</properties>
<profile>
<id>spark-2.2</id>
<activation>
<property>
<name>platform</name>
<value>vanilla</value>
</property>
</activation>
<modules>
<module>dependency/preload</module>
</modules>
</profile>
然而,当我 运行 mvn install 时,dependency/preload 没有出现在最终导致编译错误的 reactor 构建序列中。为什么同一个文件中的 属性 没有用,我应该如何修复它?
让它发挥作用有什么意义吗?为什么要静态地修复它以使其与 pom 相同?
通常当您有很多个人资料时,您可能希望拥有一个:
<activation>
<activeByDefault>true</activeByDefault>
</activation>
但当然不一定。然后明确触发其他配置文件或稍后介绍的几种方式。
我附上了 Introduction to Build Profiles
中的以下部分
A profile can be triggered/activated in several ways:
- Explicitly
- Through Maven settings
- Based on environment variables
- OS settings
- Present or missing files
环境变量部分是我认为您正在尝试使用的部分。为了让它更混乱一点,它后来被称为 system 属性。所以它是一个系统属性。稍后在同一文档中您将看到用法:
<activation>
<property>
<name>debug</name>
</property>
</activation>
将通过(例如)激活:
mvn install -Ddebug
但是,例如,以下不起作用:
export debug=true
mvn install
那么为什么 pom 属性没有作为系统应用 属性 或任何 属性。我认为这是因为 profile 应该能够覆盖 pom 属性 values 然后可以将其视为默认值。
但稍后在同一文档中,几行:
Profiles in POMs
...
Profiles specified in the POM can modify the following POM elements:
...
<properties> (not actually available in the main POM, but used behind the scenes)
我有一个 Maven 配置文件,它由在同一文件中设置的 属性 激活:
<properties>
<platform>vanilla</platform>
</properties>
<profile>
<id>spark-2.2</id>
<activation>
<property>
<name>platform</name>
<value>vanilla</value>
</property>
</activation>
<modules>
<module>dependency/preload</module>
</modules>
</profile>
然而,当我 运行 mvn install 时,dependency/preload 没有出现在最终导致编译错误的 reactor 构建序列中。为什么同一个文件中的 属性 没有用,我应该如何修复它?
让它发挥作用有什么意义吗?为什么要静态地修复它以使其与 pom 相同?
通常当您有很多个人资料时,您可能希望拥有一个:
<activation>
<activeByDefault>true</activeByDefault>
</activation>
但当然不一定。然后明确触发其他配置文件或稍后介绍的几种方式。
我附上了 Introduction to Build Profiles
中的以下部分A profile can be triggered/activated in several ways:
- Explicitly
- Through Maven settings
- Based on environment variables
- OS settings
- Present or missing files
环境变量部分是我认为您正在尝试使用的部分。为了让它更混乱一点,它后来被称为 system 属性。所以它是一个系统属性。稍后在同一文档中您将看到用法:
<activation>
<property>
<name>debug</name>
</property>
</activation>
将通过(例如)激活:
mvn install -Ddebug
但是,例如,以下不起作用:
export debug=true
mvn install
那么为什么 pom 属性没有作为系统应用 属性 或任何 属性。我认为这是因为 profile 应该能够覆盖 pom 属性 values 然后可以将其视为默认值。
但稍后在同一文档中,几行:
Profiles in POMs
...
Profiles specified in the POM can modify the following POM elements:
...
<properties> (not actually available in the main POM, but used behind the scenes)