You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2009/02/22 19:24:55 UTC
svn commit: r746791 - in /maven/plugins/trunk/maven-invoker-plugin/src:
it/invocation-multiple/src/it/project/
main/java/org/apache/maven/plugin/invoker/
Author: bentmann
Date: Sun Feb 22 18:24:55 2009
New Revision: 746791
URL: http://svn.apache.org/viewvc?rev=746791&view=rev
Log:
[MINVOKER-83] Allow to configure different system properties for multi-invocation builds
Added:
maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-multiple/src/it/project/system1.properties (with props)
maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-multiple/src/it/project/system2.properties (with props)
Modified:
maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-multiple/src/it/project/invoker.properties
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerProperties.java
Modified: maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-multiple/src/it/project/invoker.properties
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-multiple/src/it/project/invoker.properties?rev=746791&r1=746790&r2=746791&view=diff
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-multiple/src/it/project/invoker.properties (original)
+++ maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-multiple/src/it/project/invoker.properties Sun Feb 22 18:24:55 2009
@@ -3,11 +3,12 @@
#######################################
invoker.goals = install
invoker.profiles = plugin,profile0
-invoker.mavenOpts = -Dmaven.invoker.test=UTF-8
+invoker.systemPropertiesFile = system1.properties
#######################################
# First build
#######################################
+# goals should fall back to invoker.goals
invoker.profiles.1 =
#######################################
@@ -15,11 +16,11 @@
#######################################
invoker.goals.2 = test:test-maven-plugin:0.1-SNAPSHOT:test
invoker.profiles.2 = plugin,profile1
-# maven opts should fall back to invoker.mavenOpts
+# system properties file should fall back to invoker.systemPropertiesFile
#######################################
# Third build
#######################################
invoker.goals.3 = test:test-maven-plugin:0.1-SNAPSHOT:test
# profiles should fall back to invoker.profiles
-invoker.mavenOpts.3 = -Dmaven.invoker.test=ISO-8859-1
+invoker.systemPropertiesFile.3 = system2.properties
Added: maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-multiple/src/it/project/system1.properties
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-multiple/src/it/project/system1.properties?rev=746791&view=auto
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-multiple/src/it/project/system1.properties (added)
+++ maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-multiple/src/it/project/system1.properties Sun Feb 22 18:24:55 2009
@@ -0,0 +1 @@
+maven.invoker.test = UTF-8
Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-multiple/src/it/project/system1.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-multiple/src/it/project/system1.properties
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-multiple/src/it/project/system2.properties
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-multiple/src/it/project/system2.properties?rev=746791&view=auto
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-multiple/src/it/project/system2.properties (added)
+++ maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-multiple/src/it/project/system2.properties Sun Feb 22 18:24:55 2009
@@ -0,0 +1 @@
+maven.invoker.test = ISO-8859-1
Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-multiple/src/it/project/system2.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-multiple/src/it/project/system2.properties
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java?rev=746791&r1=746790&r2=746791&view=diff
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java (original)
+++ maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java Sun Feb 22 18:24:55 2009
@@ -471,6 +471,11 @@
* # Since plugin version 1.4
* invoker.offline = true
*
+ * # The path to the properties file from which to load system properties, defaults to the
+ * # filename given by the plugin parameter testPropertiesFile
+ * # Since plugin version 1.4
+ * invoker.systemPropertiesFile = test.properties
+ *
* # An optional human friendly name for this build job to be included in the build reports.
* # Since plugin version 1.4
* invoker.name = Test Build 01
@@ -1186,8 +1191,6 @@
List profiles = getProfiles( basedir );
- Properties systemProperties = getTestProperties( basedir );
-
Map context = new LinkedHashMap();
FileLogger logger = setupLogger( basedir );
@@ -1202,8 +1205,6 @@
request.setUserSettingsFile( settingsFile );
- request.setProperties( systemProperties );
-
request.setInteractive( false );
request.setShowErrors( showErrors );
@@ -1247,16 +1248,23 @@
request.setOffline( false );
+ Properties systemProperties =
+ getSystemProperties( basedir, invokerProperties.getSystemPropertiesFile( invocationIndex ) );
+ request.setProperties( systemProperties );
+
invokerProperties.configureInvocation( request, invocationIndex );
- try
- {
- getLog().debug( "Using MAVEN_OPTS: " + request.getMavenOpts() );
- getLog().debug( "Executing: " + new MavenCommandLineBuilder().build( request ) );
- }
- catch ( CommandLineConfigurationException e )
+ if ( getLog().isDebugEnabled() )
{
- getLog().debug( "Failed to display command line: " + e.getMessage() );
+ try
+ {
+ getLog().debug( "Using MAVEN_OPTS: " + request.getMavenOpts() );
+ getLog().debug( "Executing: " + new MavenCommandLineBuilder().build( request ) );
+ }
+ catch ( CommandLineConfigurationException e )
+ {
+ getLog().debug( "Failed to display command line: " + e.getMessage() );
+ }
}
InvocationResult result;
@@ -1328,10 +1336,12 @@
* Gets the system properties to use for the specified project.
*
* @param basedir The base directory of the project, must not be <code>null</code>.
+ * @param filename The filename to the properties file to load, may be <code>null</code> to use the default path
+ * given by {@link #testPropertiesFile}.
* @return The system properties to use, may be empty but never <code>null</code>.
* @throws MojoExecutionException If the properties file exists but could not be read.
*/
- private Properties getTestProperties( final File basedir )
+ private Properties getSystemProperties( final File basedir, final String filename )
throws MojoExecutionException
{
Properties collectedTestProperties = new Properties();
@@ -1346,30 +1356,34 @@
collectedTestProperties.putAll( properties );
}
- if ( testPropertiesFile != null )
+ File propertiesFile = null;
+ if ( filename != null )
{
- final File testProperties = new File( basedir, testPropertiesFile );
+ propertiesFile = new File( basedir, filename );
+ }
+ else if ( testPropertiesFile != null )
+ {
+ propertiesFile = new File( basedir, testPropertiesFile );
+ }
- if ( testProperties.exists() )
+ if ( propertiesFile != null && propertiesFile.isFile() )
+ {
+ InputStream fin = null;
+ try
{
- InputStream fin = null;
- try
- {
- fin = new FileInputStream( testProperties );
+ fin = new FileInputStream( propertiesFile );
- Properties loadedProperties = new Properties();
- loadedProperties.load( fin );
- collectedTestProperties.putAll( loadedProperties );
- }
- catch ( IOException e )
- {
- throw new MojoExecutionException( "Error reading system properties for test: "
- + testPropertiesFile );
- }
- finally
- {
- IOUtil.close( fin );
- }
+ Properties loadedProperties = new Properties();
+ loadedProperties.load( fin );
+ collectedTestProperties.putAll( loadedProperties );
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( "Error reading system properties from " + propertiesFile );
+ }
+ finally
+ {
+ IOUtil.close( fin );
}
}
Modified: maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerProperties.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerProperties.java?rev=746791&r1=746790&r2=746791&view=diff
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerProperties.java (original)
+++ maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerProperties.java Sun Feb 22 18:24:55 2009
@@ -77,6 +77,11 @@
private static final String OFFLINE = "invoker.offline";
/**
+ * The constant for the invoker property.
+ */
+ private static final String SYSTEM_PROPERTIES_FILE = "invoker.systemPropertiesFile";
+
+ /**
* Creates a new facade for the specified invoker properties. The properties will not be copied, so any changes to
* them will be reflected by the facade.
*
@@ -125,7 +130,8 @@
*/
public boolean isInvocationDefined( int index )
{
- String[] keys = { PROJECT, GOALS, PROFILES, MAVEN_OPTS, FAILURE_BEHAVIOR, NON_RECURSIVE, OFFLINE };
+ String[] keys =
+ { PROJECT, GOALS, PROFILES, MAVEN_OPTS, FAILURE_BEHAVIOR, NON_RECURSIVE, OFFLINE, SYSTEM_PROPERTIES_FILE };
for ( int i = 0; i < keys.length; i++ )
{
if ( properties.getProperty( keys[i] + '.' + index ) != null )
@@ -213,6 +219,17 @@
}
/**
+ * Gets the path to the properties file used to set the system properties for the specified execution.
+ *
+ * @param index The index of the invocation for which to check the exit code, must not be negative.
+ * @return The path to the properties file or <code>null</code> if not set.
+ */
+ public String getSystemPropertiesFile( int index )
+ {
+ return get( SYSTEM_PROPERTIES_FILE, index );
+ }
+
+ /**
* Gets a value from the invoker properties. The invoker properties are intended to describe the invocation settings
* for multiple builds of the same project. For this reason, the properties are indexed. First, a property named
* <code>key.index</code> will be queried. If this property does not exist, the value of the property named