change how to pass timeout parameter to use same pattern with InvocationRequest
Signed-off-by: olivier lamy <olamy@apache.org>
diff --git a/pom.xml b/pom.xml
index 7dd403f..615d7c2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -34,7 +34,7 @@
<!--
https://issues.apache.org/jira/browse/MSHARED-625
-->
- <version>4.0.0-SNAPSHOT</version>
+ <version>3.0.1-SNAPSHOT</version>
<name>Apache Maven Invoker</name>
<description>A component to programmatically invoke Maven.</description>
diff --git a/src/main/java/org/apache/maven/shared/invoker/DefaultInvocationRequest.java b/src/main/java/org/apache/maven/shared/invoker/DefaultInvocationRequest.java
index 782a269..ce19368 100644
--- a/src/main/java/org/apache/maven/shared/invoker/DefaultInvocationRequest.java
+++ b/src/main/java/org/apache/maven/shared/invoker/DefaultInvocationRequest.java
@@ -104,6 +104,8 @@
private String builderId;
+ private int timeoutInSeconds = NO_TIMEOUT;
+
public File getBaseDirectory()
{
return basedir;
@@ -584,4 +586,16 @@
return this.builderId;
}
+
+ @Override
+ public int getTimeoutInSeconds()
+ {
+ return timeoutInSeconds;
+ }
+
+ @Override
+ public void setTimeoutInSeconds( int timeoutInSeconds )
+ {
+ this.timeoutInSeconds = timeoutInSeconds;
+ }
}
diff --git a/src/main/java/org/apache/maven/shared/invoker/DefaultInvoker.java b/src/main/java/org/apache/maven/shared/invoker/DefaultInvoker.java
index 3ef26c3..e58d131 100644
--- a/src/main/java/org/apache/maven/shared/invoker/DefaultInvoker.java
+++ b/src/main/java/org/apache/maven/shared/invoker/DefaultInvoker.java
@@ -39,8 +39,6 @@
public static final String ROLE_HINT = "default";
- private static final int NO_TIMEOUT = 0;
-
private static final InvokerLogger DEFAULT_LOGGER = new SystemOutLogger();
private static final InvocationOutputHandler DEFAULT_OUTPUT_HANDLER = new SystemOutHandler();
@@ -62,12 +60,6 @@
private InvocationOutputHandler errorHandler = DEFAULT_OUTPUT_HANDLER;
public InvocationResult execute( InvocationRequest request )
- throws MavenInvocationException
- {
- return this.execute( request , NO_TIMEOUT );
- }
-
- public InvocationResult execute( InvocationRequest request, int timeoutInSeconds )
throws MavenInvocationException
{
MavenCommandLineBuilder cliBuilder = new MavenCommandLineBuilder();
@@ -116,7 +108,7 @@
try
{
- int exitCode = executeCommandLine( cli, request, timeoutInSeconds );
+ int exitCode = executeCommandLine( cli, request, request.getTimeoutInSeconds() );
result.setExitCode( exitCode );
}
diff --git a/src/main/java/org/apache/maven/shared/invoker/InvocationRequest.java b/src/main/java/org/apache/maven/shared/invoker/InvocationRequest.java
index 86f21a4..433bf5f 100644
--- a/src/main/java/org/apache/maven/shared/invoker/InvocationRequest.java
+++ b/src/main/java/org/apache/maven/shared/invoker/InvocationRequest.java
@@ -722,4 +722,17 @@
*/
String getBuilder();
+ int NO_TIMEOUT = 0;
+ /**
+ * @since 3.0.1
+ * @return the timeout in seconds to execute the project
+ */
+ int getTimeoutInSeconds();
+
+ /**
+ * @since 3.0.1
+ * @param timeoutInSeconds the timeout in seconds to execute the project
+ */
+ void setTimeoutInSeconds( int timeoutInSeconds );
+
}
diff --git a/src/main/java/org/apache/maven/shared/invoker/Invoker.java b/src/main/java/org/apache/maven/shared/invoker/Invoker.java
index 10574f6..580e7b3 100644
--- a/src/main/java/org/apache/maven/shared/invoker/Invoker.java
+++ b/src/main/java/org/apache/maven/shared/invoker/Invoker.java
@@ -48,19 +48,6 @@
throws MavenInvocationException;
/**
- * Executes Maven using the parameters specified by the given invocation request. Parameters not specified by the
- * invocation request will be derived from the state of this invoker instance. In case both the invoker instance and
- * the invocation request provide a value for a particular option, the value from the invocation request dominates.
- *
- * @param request The invocation request to execute, must not be <code>null</code>.
- * @param timeoutInSeconds If a value > 0 is specified, the goal might be interrupted after the timeout is reached.
- * @return The result of the Maven invocation, never <code>null</code>.
- * @throws MavenInvocationException
- */
- InvocationResult execute( InvocationRequest request, int timeoutInSeconds )
- throws MavenInvocationException;
-
- /**
* Gets the path to the base directory of the local repository to use for the Maven invocation.
*
* @return The path to the base directory of the local repository or <code>null</code> to use the location from
diff --git a/src/test/java/org/apache/maven/shared/invoker/DefaultInvokerTest.java b/src/test/java/org/apache/maven/shared/invoker/DefaultInvokerTest.java
index 00c4abb..ba51a16 100644
--- a/src/test/java/org/apache/maven/shared/invoker/DefaultInvokerTest.java
+++ b/src/test/java/org/apache/maven/shared/invoker/DefaultInvokerTest.java
@@ -99,6 +99,7 @@
request.setBaseDirectory( basedir );
request.setDebug( true );
request.setGoals( Arrays.asList( "clean", "package" ) );
+ request.setTimeoutInSeconds( 4 );
if ( !System.getProperty( "java.version" ).startsWith( "1." ) )
{
@@ -108,7 +109,7 @@
request.setProperties( properties );
}
- InvocationResult result = invoker.execute( request, 10 );
+ InvocationResult result = invoker.execute( request );
assertEquals( 1, result.getExitCode() );
}