使用maven 2.x设置环境变量

cup*_*kob 8 linux variables environment maven-2 setting

是否可以使用maven(OS:Linux)设置环境变量?

我已经有了用户定义的属性(在pom和profiles.xml中)....我的问题是,如何从Maven执行以下操作

export GGA_FRE=/path
Run Code Online (Sandbox Code Playgroud)

因此,每个开发人员都可以设置自己的路径GGA_FRE.

Sea*_*oyd 4

这个答案不正确,至少不完全正确(见评论)。
不幸的是我无法删除它,因为它已被接受。您的里程可能会有所不同。


使用exec:exec魔力。

  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.1</version>
    <executions>
      <execution>
        <id>exportVar</id>
        <phase>initialize</phase>
        <goals>
          <goal>exec</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
      <executable>export</executable>
      <arguments>
        <argument>GGA_FRE=${my.path}</argument>
      </arguments>
    </configuration>
  </plugin>
Run Code Online (Sandbox Code Playgroud)

现在这样称呼它mvn install -Dmy.path=/var/users/groucho

  • 我不明白为什么错误的答案会被 a) 投票赞成和 b) 接受。 (6认同)