java - 如果操作系统不属于给定系列(例如 mac),如何激活 pom.xml?

标签 java macos maven pom.xml tools.jar

来自 Maven's website :

    ...
  <profiles>
    <profile>
      <id>default-tools.jar</id>
      <activation>
        <property>
          <name>java.vendor</name>
          <value>Sun Microsystems Inc.</value>
        </property>
      </activation>
      <dependencies>
        <dependency>
          <groupId>com.sun</groupId>
          <artifactId>tools</artifactId>
          <version>1.4.2</version>
          <scope>system</scope>
          <systemPath>${java.home}/../lib/tools.jar</systemPath>
        </dependency>
      </dependencies>
    </profile>
  </profiles>
  ...

tools.jar 已经包含在 Mac 上,与 classes.jar 一起嵌入。有没有办法在 pom.xml 的激活设置中指定 !mac(除了列出除 mac 之外的每个操作系统),而不是总是得到:

ERROR>warning: [path] bad path element ""/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/lib/tools.jar"": no such file or directory

最佳答案

您可以使用 '!'激活的 os 部分中的修饰符(尝试并与 Maven 3.0.3 一起使用)。使用与 enforcer 插件相同的算法,描述 here .

<profiles>
    <profile>
        <id>not-mac</id>
        <activation>
            <os>
                <family>!mac</family>
            </os>
        </activation>
        <properties>
            <!-- Define non-mac properties here -->
        </properties>
    </profile>
</profiles>

参见 this article有关在 Maven 中使用 tools.jar 的更完整说明。

关于java - 如果操作系统不属于给定系列(例如 mac),如何激活 pom.xml?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5132122/

相关文章:

java - 在 Android Manifest.xml 中接收短信

java - 如何自动化 Intellij 项目配置

java - Java libjli 库有什么用?

javax.el.PropertyNotWritableException :/index. xhtml @29,118 值 ="":集合操作的非法语法

c - 我用于实现 ls 的 C 代码在 Mac 上不起作用

macos - 为什么 unix locate 命令仍然显示不再存在的文件/文件夹?

c - 在 OS X 上获取 CPU 时间

java - 如何在没有 IDE 的情况下编译和运行 Intellij IDEA java 项目?

java - Spring Boot pom - 如何从聚合器 pom 继承配置文件和属性?

java - 如何将位图数组添加到 ArrayList?