2011-02-27 45 views
1

Maven's website如何激活一个pom.xml如果os不是给定的家庭(例如mac)?

... 
    <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已经inclduded在Mac上,嵌有classes.jar。当时有没有办法来指定MAC的激活设置(除除MAC每个操作系统上市)在pom.xml,而不是总是让:

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

回答

0

我发现了另一个方法。在“activeByDefault”配置文件中拥有依赖关系。有另一个配置文件(配置文件-2),如果操作系统是mac,它将被激活。根据this,如果任何其他配置文件被激活,“activeByDefault”配置文件将被取消激活。因此,如果操作系统是mac,则profile-2将被激活,从而禁用“activeByDefault”配置文件。

+0

不会这样做。该财产并不缺席。 – simpatico 2011-02-27 14:27:30

+0

我编辑了答案。看看这是否有效。 – 2011-02-28 15:11:14

+0

用代码证明它,任何人? – simpatico 2011-03-06 07:15:32

1

您可以使用'!'修改器在激活的os部分中(尝试并使用Maven 3.0.3)。使用与执行者插件相同的算法,描述为here

<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的更完整说明,请参阅this article