Search code examples
linuxmavenpluginsplatform

How to run a plugin only on a particular platform


I have a maven plugin that only needs to execute on linux. I found this configuration that seems to work

How do I make this plugin run only on non-Windows platforms?

<profiles>
  <profile>
    <activation>
      <os>
        <family>!mac</family>
      </os>
    </activation>
    <build>
      <plugins>
        <plugin>
          ...
        </plugin>
      </plugins>
    </build>
    ...
  </profile>
</profiles>

How do I modify it so that it executes only on linux?


Solution

  • There is no OS <family> value that distinguishes Linux from Unixes, but you can use <name> instead.

    <profiles>
      <profile>
        <activation>
          <os>
            <name>Linux</name>
          </os>
        </activation>
        <build>
          <plugins>
            <plugin>
              ...
            </plugin>
          </plugins>
        </build>
        ...
      </profile>
    </profiles>
    

    FYI, to double-check the value for <name> on your Linux machine, execute java -XshowSettings:properties and look for the os.name property. (On all Linux distributions I have checked, this is just Linux.)