You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by br...@apache.org on 2006/11/10 08:03:12 UTC
svn commit: r473214 - in
/maven/sandbox/plugins/maven-nunit-plugin/src/main/java/org/apache/maven/plugin/nunit:
NUnitEnvironment.java NUnitMojo.java Property.java
Author: brett
Date: Thu Nov 9 23:03:11 2006
New Revision: 473214
URL: http://svn.apache.org/viewvc?view=rev&rev=473214
Log:
[MNG-2403] support systemProperties configuration
Submitted by: James Carpenter
Added:
maven/sandbox/plugins/maven-nunit-plugin/src/main/java/org/apache/maven/plugin/nunit/Property.java (with props)
Modified:
maven/sandbox/plugins/maven-nunit-plugin/src/main/java/org/apache/maven/plugin/nunit/NUnitEnvironment.java
maven/sandbox/plugins/maven-nunit-plugin/src/main/java/org/apache/maven/plugin/nunit/NUnitMojo.java
Modified: maven/sandbox/plugins/maven-nunit-plugin/src/main/java/org/apache/maven/plugin/nunit/NUnitEnvironment.java
URL: http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-nunit-plugin/src/main/java/org/apache/maven/plugin/nunit/NUnitEnvironment.java?view=diff&rev=473214&r1=473213&r2=473214
==============================================================================
--- maven/sandbox/plugins/maven-nunit-plugin/src/main/java/org/apache/maven/plugin/nunit/NUnitEnvironment.java (original)
+++ maven/sandbox/plugins/maven-nunit-plugin/src/main/java/org/apache/maven/plugin/nunit/NUnitEnvironment.java Thu Nov 9 23:03:11 2006
@@ -70,10 +70,15 @@
private String runtime = null;
+ private boolean inheritSystemProperties;
+
+ private Property[] systemProperties;
+
private List artifacts = null;
public NUnitEnvironment( Log log, File outputDir, List artifacts, File mainAssembly, File testAssembly,
- File unitTestConfig, String runtime )
+ File unitTestConfig, String runtime, boolean inheritSystemProperties,
+ Property[] systemProperties )
{
this.log = log;
this.outputDir = outputDir;
@@ -82,6 +87,8 @@
this.testAssembly = testAssembly;
this.unitTestConfig = unitTestConfig;
this.runtime = runtime;
+ this.inheritSystemProperties = inheritSystemProperties;
+ this.systemProperties = systemProperties;
}
public void create()
@@ -211,6 +218,33 @@
cli.createArgument().setValue( nunitConsoleFile.getName() );
}
cli.createArgument().setValue( testAssembly.getName() );
+
+ if ( this.systemProperties != null )
+ {
+ for ( int i = 0; i < this.systemProperties.length; i++ )
+ {
+ Property systemProperty = this.systemProperties[i];
+ getLog().info( nunitOutputPrefix + "adding systemProperty: " + systemProperty );
+ cli.addEnvironment( systemProperty.getKey(), systemProperty.getValue() );
+ }
+ }
+ //It turns out to be very important to place the call to cli.addSystemEnvironment() after
+ //all of the specified system properties have been added above.
+ //The choosen order ensures the specified system property values take precidence
+ //over any inherited values.
+ if ( this.inheritSystemProperties )
+ {
+ getLog().info( nunitOutputPrefix + "Inheriting system properties." );
+ try
+ {
+ cli.addSystemEnvironment();
+ }
+ catch ( Exception ex )
+ {
+ throw new MojoExecutionException( "Encountered problems adding system environment variables to runtime",
+ ex );
+ }
+ }
try
{
Modified: maven/sandbox/plugins/maven-nunit-plugin/src/main/java/org/apache/maven/plugin/nunit/NUnitMojo.java
URL: http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-nunit-plugin/src/main/java/org/apache/maven/plugin/nunit/NUnitMojo.java?view=diff&rev=473214&r1=473213&r2=473214
==============================================================================
--- maven/sandbox/plugins/maven-nunit-plugin/src/main/java/org/apache/maven/plugin/nunit/NUnitMojo.java (original)
+++ maven/sandbox/plugins/maven-nunit-plugin/src/main/java/org/apache/maven/plugin/nunit/NUnitMojo.java Thu Nov 9 23:03:11 2006
@@ -60,6 +60,13 @@
private String testOutputFileName;
/**
+ * A list of system properties to be passed..
+ *
+ * @parameter
+ */
+ private Property[] systemProperties;
+
+ /**
* This is the filename to invoke the runtime environment. On windows
* using csc & MS dotnet this should be null.
* <p/>
@@ -88,6 +95,19 @@
*/
private File outputDirectory;
+ /**
+ * Specifies whether system environment variables should be inherited
+ * from the environment in which maven was run.
+ * If this value is set to true (default), then environment variables such as
+ * ${java.home} will be available without having to explictly specify
+ * them within the systemProperties configuration element. As you
+ * would expect any property values specified in the systemProperties
+ * configuration element take precedence.
+ *
+ * @parameter default-value="true"
+ */
+ private boolean inheritSystemProperties;
+
public void execute()
throws MojoExecutionException
{
@@ -126,7 +146,8 @@
}
NUnitEnvironment env = new NUnitEnvironment( this.getLog(), testOutputDirectory, dependencyartifacts,
- mainAssembly, testAssembly, configFile, runtimeExecutable );
+ mainAssembly, testAssembly, configFile, runtimeExecutable,
+ this.inheritSystemProperties, this.systemProperties );
env.create();
@@ -202,5 +223,5 @@
}
return exe;
- }
+ }
}
Added: maven/sandbox/plugins/maven-nunit-plugin/src/main/java/org/apache/maven/plugin/nunit/Property.java
URL: http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-nunit-plugin/src/main/java/org/apache/maven/plugin/nunit/Property.java?view=auto&rev=473214
==============================================================================
--- maven/sandbox/plugins/maven-nunit-plugin/src/main/java/org/apache/maven/plugin/nunit/Property.java (added)
+++ maven/sandbox/plugins/maven-nunit-plugin/src/main/java/org/apache/maven/plugin/nunit/Property.java Thu Nov 9 23:03:11 2006
@@ -0,0 +1,43 @@
+package org.apache.maven.plugin.nunit;
+
+import org.codehaus.plexus.util.StringUtils;
+
+/**
+ * Wrapper class for the systemPropery argument type.
+ */
+
+public class Property
+{
+ private String key;
+
+ private String value;
+
+ public String getKey()
+ {
+ return key;
+ }
+
+ public void setKey( String key )
+ {
+ this.key = key;
+ }
+
+ public String getValue()
+ {
+ return value;
+ }
+
+ public void setValue( String value )
+ {
+ this.value = value;
+ }
+
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer();
+ sb.append( StringUtils.defaultString( this.key, "NULL" ) );
+ sb.append( ":" );
+ sb.append( StringUtils.defaultString( this.value, "NULL" ) );
+ return sb.toString();
+ }
+}
Propchange: maven/sandbox/plugins/maven-nunit-plugin/src/main/java/org/apache/maven/plugin/nunit/Property.java
------------------------------------------------------------------------------
svn:eol-style = native