我对maven还挺陌生的。我已经设置了一个pom.xml,它定义了用于运行单元测试的配置文件。我正在尝试设置路径环境变量。env变量名是用于Windows的Path和用于Linux的LD_LIBRARY_PATH。我不想继续改变这些环境。变量名取决于操作系统。我该如何做到这一点?
<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>发布于 2013-10-16 20:54:08
剖面活化也许能帮上忙。从集成测试配置文件中删除<environmentVariables>配置。然后添加下面的概要文件,调整<activation>部分以满足特定的需求。您不需要在命令行上显式地启用这些配置文件;Maven将根据运行构建的系统来激活正确的配置文件。
<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>https://stackoverflow.com/questions/19413466
复制相似问题