Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing system variables with maven-surefire-plugin in Maven

I'd like to pass some system variables for a Maven build. If i use mvn clean install -Dfirst.variable=value -Dsecond.variable=second.value everything's fine. But this configuration in the pom.xml doesn't work:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.12.3</version>
            <executions>
                <execution>
                    <id>tests</id>
                    <phase>test</phase>
                    <goals>
                        <goal>test</goal>
                    </goals>
                    <configuration>
                        <includes>
                            <include>**/*Test.java</include>
                        </includes>
                        <systemPropertyVariables>
                            <first.variable>${value}</first.variable>
                            <second.variable>${second.value}</second.variable>
                        </systemPropertyVariables>
                    </configuration>
                </execution>
            </executions>
        </plugin> 

I tried to use this config without <id/>, <phase/> and <goals> but it didn't help. Is there a possibility the plugin doesn't run? Even hardcoded values of these variables don't pass. If so, what is a probable solution? Thanks in advance.

like image 247
John Doe Avatar asked Sep 03 '12 11:09

John Doe


1 Answers

You don´t need to create an <execution/>. The easy way:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
      <systemPropertyVariables>
        <my.property>propertyValue</my.property>
      </systemPropertyVariables>
    </configuration>
</plugin>
like image 144
Fabricio Lemos Avatar answered Oct 08 '22 07:10

Fabricio Lemos