How to set an environment variable in maven depending on the OS

cooltechnomax

I am fairly new to maven. I have setup a pom.xml which defines a profile for running my unit tests. I am trying to set Path environment variable. The env variable name is Path for Windows and LD_LIBRARY_PATH for Linux. I don't want to keep on changing these env. variable names depending on the OS. How should I achieve this?

<profile>
        <id>integration-tests</id>
        <build>
         <plugins>
            <plugin>
                <groupId>org.eclipse.tycho</groupId>
                <artifactId>tycho-surefire-plugin</artifactId>
                <version>${tychoVersion}</version>
                <configuration combine.self="override">
                    <argLine>${tycho.testArgLine} ${global.test.vmargs} ${bundle.test.vmargs}</argLine>
                    <forkMode>${bundle.test.forkMode}</forkMode>
                    <useUIHarness>${bundle.test.useUIHarness}</useUIHarness>
                    <useUIThread>${bundle.test.useUIThread}</useUIThread>
                    <environmentVariables>
                      <!--For windows change LD_LIBRARY_PATH to PATH-->
                        <LD_LIBRARY_PATH>${dependenciesDir}${path.separator}{env.LD_LIBRARY_PATH}</LD_LIBRARY_PATH>

                    </environmentVariables>
                </configuration>
            </plugin>
        </plugins>
        </build>

    </profile>
user944849

Profile activation might help here. Remove the <environmentVariables> config from the integration tests profile. Then add the profiles below, tweaking the <activation> sections to meet the specific requirements. You do not need to explicitly enable these profiles on the command line; Maven will activate the right profile based on which system is running the build.

<profile>
  <id>windows-tests</id>
  <activation>
      <os>
        <family>Windows</family>
      </os>
  </activation>
  <build>
     <plugins>
        <plugin>
            <groupId>org.eclipse.tycho</groupId>
            <artifactId>tycho-surefire-plugin</artifactId>
            <version>${tychoVersion}</version>
            <configuration>
                <environmentVariables>
                    <PATH>${dependenciesDir}${path.separator}{env.PATH}</PATH>
                </environmentVariables>
            </configuration>
        </plugin>
    </plugins>
    </build>
</profile>
<profile>
  <id>linux-tests</id>
  <activation>
      <os>
        <family>Linux</family>
      </os>
  </activation>
  <build>
     <plugins>
        <plugin>
            <groupId>org.eclipse.tycho</groupId>
            <artifactId>tycho-surefire-plugin</artifactId>
            <version>${tychoVersion}</version>
            <configuration>
                <environmentVariables>
                    <LD_LIBRARY_PATH>${dependenciesDir}${path.separator}{env.LD_LIBRARY_PATH}</LD_LIBRARY_PATH>

                </environmentVariables>
            </configuration>
        </plugin>
    </plugins>
    </build>
</profile>

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

How can I set environment variable for runComment() in Rhino?

来自分类Dev

Set Logging Level in Spring Boot via Environment Variable

来自分类Dev

In Octopus Deploy, can you use a variable set per environment as the value for feed?

来自分类Dev

How to set context path to root("/") in Tomcat 7.0 when using Maven

来自分类Dev

GHC flags environment variable

来自分类Dev

How to set Gradle `options.bootClasspath` in an os independent manner?

来自分类Dev

Importing creating an environment variable in Python?

来自分类Dev

How to get and set Local Variable List for a process in JBPM 6?

来自分类Dev

how to show content depending on domain/subdomain

来自分类Dev

How to position button depending on what content is on the page

来自分类Dev

可变的android.os.Environment.DIRECTORY_WHATEVER?

来自分类Dev

Set range variable = printarea

来自分类Dev

AWS EC2 set environment variables

来自分类Dev

如何为 db:environment:set 定义环境?

来自分类Dev

"DART_SDK" environment variable is officially removed?

来自分类Dev

基于OS的Maven antrun插件集属性

来自分类Dev

Maven构建失败Mac OS 10

来自分类Dev

PhantomJS; If I set a variable inside page.evaluate(), how can I access the value of that variable outside of page.evaluate()

来自分类Dev

Set string variable content in princexml

来自分类Dev

Django-AttributeError:模块“ os”没有属性“ environment”

来自分类Dev

引发ImportError“无法导入设置” ENVIRONMENT_VARIABLE

来自分类Dev

get_environment_variable 与 gfortran 的意外行为

来自分类Dev

在OS X Eclipse上使用Maven安装Mahout

来自分类Dev

make rpm-maven-plugin work on MAC OS(mavericks)

来自分类Dev

使rpm-maven-plugin在MAC OS上工作(小牛)

来自分类Dev

在OS X Eclipse上使用Maven安装Mahout

来自分类Dev

set global variable in ajax get success

来自分类Dev

Bash: set a shell variable in the middle of the pipeline

来自分类Dev

Get/Set Workflow Variable from uiTypeEditor

Related 相关文章

  1. 1

    How can I set environment variable for runComment() in Rhino?

  2. 2

    Set Logging Level in Spring Boot via Environment Variable

  3. 3

    In Octopus Deploy, can you use a variable set per environment as the value for feed?

  4. 4

    How to set context path to root("/") in Tomcat 7.0 when using Maven

  5. 5

    GHC flags environment variable

  6. 6

    How to set Gradle `options.bootClasspath` in an os independent manner?

  7. 7

    Importing creating an environment variable in Python?

  8. 8

    How to get and set Local Variable List for a process in JBPM 6?

  9. 9

    how to show content depending on domain/subdomain

  10. 10

    How to position button depending on what content is on the page

  11. 11

    可变的android.os.Environment.DIRECTORY_WHATEVER?

  12. 12

    Set range variable = printarea

  13. 13

    AWS EC2 set environment variables

  14. 14

    如何为 db:environment:set 定义环境?

  15. 15

    "DART_SDK" environment variable is officially removed?

  16. 16

    基于OS的Maven antrun插件集属性

  17. 17

    Maven构建失败Mac OS 10

  18. 18

    PhantomJS; If I set a variable inside page.evaluate(), how can I access the value of that variable outside of page.evaluate()

  19. 19

    Set string variable content in princexml

  20. 20

    Django-AttributeError:模块“ os”没有属性“ environment”

  21. 21

    引发ImportError“无法导入设置” ENVIRONMENT_VARIABLE

  22. 22

    get_environment_variable 与 gfortran 的意外行为

  23. 23

    在OS X Eclipse上使用Maven安装Mahout

  24. 24

    make rpm-maven-plugin work on MAC OS(mavericks)

  25. 25

    使rpm-maven-plugin在MAC OS上工作(小牛)

  26. 26

    在OS X Eclipse上使用Maven安装Mahout

  27. 27

    set global variable in ajax get success

  28. 28

    Bash: set a shell variable in the middle of the pipeline

  29. 29

    Get/Set Workflow Variable from uiTypeEditor

热门标签

归档