2016-07-19 11 views
2

ich einige Eigenschaften von dem Betriebssystem auf Basis einstellen wollen, so habe ich folgendes in meinem pom.xml:Wählen Sie Maven Profil von OS Familie

<project ...> 
    <profiles> 
     <profile> 
      <id>KenMacbook</id> 
      <activation> 
       <os><family>mac</family></os> 
      </activation> 
      <properties> 
       <test.r.version>3.3</test.r.version> 
      </properties> 
     </profile> 
     <profile> 
      <id>LinuxBox</id> 
      <activation> 
       <os><family>unix</family></os> 
      </activation> 
      <properties> 
       <test.r.version>3.2</test.r.version> 
      </properties> 
     </profile> 
    </profiles> 
    ... 
</project> 

Auf meinem Mac, ich überprüfen, welche Profile sind aktiv:

So sieht es aus wie das <activation> für das LinuxBox Profil dieses Profil auf Mac nicht erfolgreich ausschließt. Missverstehe ich etwas darüber, wie die Profilauswahl funktioniert?

Maven Details:

% mvn --version 
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T10:41:47-06:00) 
Maven home: /usr/local/Cellar/maven/3.3.9/libexec 
Java version: 1.7.0_75, vendor: Oracle Corporation 
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre 
Default locale: en_US, platform encoding: UTF-8 
OS name: "mac os x", version: "10.11.5", arch: "x86_64", family: "mac" 

Antwort

0

Wie ich von this Schnipsel sehen, validiert sie beide Profile

+0

Ja, wie auch durch meine 'mvn Hilfe gezeigt: aktiv-profiles' ausgegeben. Wie wählt man nicht-Mac Unix? Die Datei-Layouts sind ziemlich unterschiedlich, so dass dies ein allgemeines Bedürfnis sein muss. –

+1

Ich lehne Mavens kanonischen Test für eine Unix-ähnliche Plattform auch energisch ab: 'OS_NAME.endsWith (" x ")'. Deshalb wird "mac os x" hier hereingezogen. –

+0

vielleicht unterscheiden es mit der Version? nicht die netteste Lösung, aber ich kann nicht an etw sonst denken – Apostolos

2

Die richtige Lösung ist Namen angeben.

<activation> 
      <os> 
       <family>unix</family> 
       <name>Linux</name> 
      </os> 
</activation> 

Eine vollständige plattformübergreifende Lösung ist:

<profile> 
    <id>mac</id> 
    <activation> 
    <os> 
     <family>mac</family> 
    </os> 
    </activation> 
     <modules> 
     <module>tests/org.eclipse.swt.tests.cocoa</module> 
     </modules> 
</profile> 
<profile> 
    <id>unix</id> 
    <activation> 
    <os> 
     <family>unix</family> 
     <name>Linux</name> 
    </os> 
    </activation> 
     <modules> 
     <module>tests/org.eclipse.swt.tests.gtk</module> 
     </modules> 
</profile> 
<profile> 
    <id>windows</id> 
    <activation> 
    <os> 
     <family>windows</family> 
    </os> 
    </activation> 
     <modules> 
     <module>tests/org.eclipse.swt.tests.win32</module> 
     </modules> 
</profile> 

Quelle: http://maven.40175.n5.nabble.com/Profile-activation-for-mac-and-linux-td3263043.html