我正在尝试配置 maven 构建配置文件,我的目的是在每次 is 与some_id不匹配时添加以下依赖项。
由于某种原因这不起作用,我怀疑使用 ! logical operator
不适用于 id。 有什么想法吗?
<profiles>
<profile>
<id>!some_id</id>
<dependencies>
<dependency>
<groupId>com.project.apps</groupId>
<artifactId>apps-cf</artifactId>
<version>${apps.version}</version>
</dependency>
<dependency>
<groupId>com.project.apps</groupId>
<artifactId>apps-core</artifactId>
<version>${apps.version}</version>
</dependency>
</dependencies>
</profile>
</profiles>
不确定我是否正确理解了您,但我想您正在寻找配置文件激活。
看看这里:http://maven.apache.org/guides/introduction/introduction-to-profiles.html
您可能希望采用属性方法。
对于激活部分,您需要执行以下操作:
<profile>
<id>my_id</id>
<activation>
<property>
<name>!some_property</name>
</property>
</activation>
...
</profile>
但是,如某些注释中所述,您可能对依赖项的范围感兴趣。例如,仅在编译时(提供(。有关更多详细信息,请参阅:https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope