You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by leojhartiv <Le...@FMR.COM> on 2008/09/24 19:17:45 UTC

Pass Command-Line Param to Surefire Plugin

Hello,

I searched the archive, but was not able to find an answer to my question.

I am running maven as follows:

mvn clean test -Dsomeparameter=somevalue

someparameter will vary per mvn call.

It does not appear that my surefire tests are able to find this variable
when they execute, so I'm assuming Maven does not pass all command-line
variables to plugins by default.

My question is, how do I pass surefire a command-line argument?  My first
thought was to do so in the configuration:

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-surefire-plugin</artifactId>
	<version>2.4.3</version>
	<configuration>
		<systemProperties>
			<property>
				<name>someparameter</name>
				<value>${someparameter}</value>
			</property>
		</systemProperties>
	</configuration>
</plugin>

However, looking at this page, it seems that this will not work:

http://maven.apache.org/plugins/maven-surefire-plugin/examples/system-properties.html

Any solution you have is appreciated.

Thanks,
Leo
-- 
View this message in context: http://www.nabble.com/Pass-Command-Line-Param-to-Surefire-Plugin-tp19653694p19653694.html
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Pass Command-Line Param to Surefire Plugin

Posted by leojhartiv <Le...@FMR.COM>.
Thanks for your reply.

Well, it looks like you are hard-coding the -D line into the plugin config. 
In my situation, would this work?

<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.4.3</version>
        <configuration>
                <argline>-Dsomeparameter=${someparameter}</argline>
        </configuration>
</plugin>

If so, then yes, that solves my problem!


Kalle Korhonen-2 wrote:
> 
> We do it like this:
>                 <artifactId>maven-surefire-plugin</artifactId>
>                 <configuration>
>                     <forkMode>once</forkMode>
>                     <workingDirectory>target</workingDirectory>
>                     <argLine>-Djava.library.path=lib</argLine>
> 
> 
> On Wed, Sep 24, 2008 at 10:17 AM, leojhartiv <Le...@fmr.com> wrote:
> 
>>
>> Hello,
>>
>> I searched the archive, but was not able to find an answer to my
>> question.
>>
>> I am running maven as follows:
>>
>> mvn clean test -Dsomeparameter=somevalue
>>
>> someparameter will vary per mvn call.
>>
>> It does not appear that my surefire tests are able to find this variable
>> when they execute, so I'm assuming Maven does not pass all command-line
>> variables to plugins by default.
>>
>> My question is, how do I pass surefire a command-line argument?  My first
>> thought was to do so in the configuration:
>>
>> <plugin>
>>        <groupId>org.apache.maven.plugins</groupId>
>>        <artifactId>maven-surefire-plugin</artifactId>
>>        <version>2.4.3</version>
>>        <configuration>
>>                <systemProperties>
>>                        <property>
>>                                <name>someparameter</name>
>>                                <value>${someparameter}</value>
>>                        </property>
>>                </systemProperties>
>>        </configuration>
>> </plugin>
>>
>> However, looking at this page, it seems that this will not work:
>>
>>
>> http://maven.apache.org/plugins/maven-surefire-plugin/examples/system-properties.html
>>
>> Any solution you have is appreciated.
>>
>> Thanks,
>> Leo
>> --
>> View this message in context:
>> http://www.nabble.com/Pass-Command-Line-Param-to-Surefire-Plugin-tp19653694p19653694.html
>> Sent from the Maven - Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Pass-Command-Line-Param-to-Surefire-Plugin-tp19653694p19654123.html
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Pass Command-Line Param to Surefire Plugin

Posted by Kalle Korhonen <ka...@gmail.com>.
We do it like this:
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <forkMode>once</forkMode>
                    <workingDirectory>target</workingDirectory>
                    <argLine>-Djava.library.path=lib</argLine>


On Wed, Sep 24, 2008 at 10:17 AM, leojhartiv <Le...@fmr.com> wrote:

>
> Hello,
>
> I searched the archive, but was not able to find an answer to my question.
>
> I am running maven as follows:
>
> mvn clean test -Dsomeparameter=somevalue
>
> someparameter will vary per mvn call.
>
> It does not appear that my surefire tests are able to find this variable
> when they execute, so I'm assuming Maven does not pass all command-line
> variables to plugins by default.
>
> My question is, how do I pass surefire a command-line argument?  My first
> thought was to do so in the configuration:
>
> <plugin>
>        <groupId>org.apache.maven.plugins</groupId>
>        <artifactId>maven-surefire-plugin</artifactId>
>        <version>2.4.3</version>
>        <configuration>
>                <systemProperties>
>                        <property>
>                                <name>someparameter</name>
>                                <value>${someparameter}</value>
>                        </property>
>                </systemProperties>
>        </configuration>
> </plugin>
>
> However, looking at this page, it seems that this will not work:
>
>
> http://maven.apache.org/plugins/maven-surefire-plugin/examples/system-properties.html
>
> Any solution you have is appreciated.
>
> Thanks,
> Leo
> --
> View this message in context:
> http://www.nabble.com/Pass-Command-Line-Param-to-Surefire-Plugin-tp19653694p19653694.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>