Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting environment variable with maven 2.x

Is it possible to set environment variable with maven (OS: Linux)?

I already have user-defined properties (in the pom and in profiles.xml)....my problem is, how to execute following from Maven

export GGA_FRE=/path

So will be possible, that every developer can set his own path for the GGA_FRE.

like image 255
cupakob Avatar asked Aug 17 '10 08:08

cupakob


1 Answers

This answer is not correct, at least not completely (see comments).
Unfortunately I can't delete it as it has been accepted. Your milage may vary.


Use the exec:exec mojo.

  <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>

now call it like this mvn install -Dmy.path=/var/users/groucho

like image 183
Sean Patrick Floyd Avatar answered Oct 22 '22 03:10

Sean Patrick Floyd