2

来自Maven 的网站

    ...
  <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
4

2 回答 2

1

您可以使用“!” 激活的 os 部分中的修饰符(已尝试并与 Maven 3.0.3 一起使用)。使用与执行器插件相同的算法,在此处描述。

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

有关在 Maven 中使用 tools.jar 的更完整描述,请参阅本文

于 2011-04-12T05:17:05.917 回答
0

我找到了另一种方法。在“activeByDefault”配置文件中具有依赖关系。如果操作系统是 mac,则有另一个配置文件 (profile-2) 被激活。据此,如果任何其他配置文件被激活,“activeByDefault”配置文件将被停用。因此,如果操作系统是 mac,profile-2 将被激活,这将停用“activeByDefault”配置文件。

于 2011-02-27T13:58:00.623 回答