You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2021/02/02 15:53:19 UTC
[maven-invoker] 01/02: Adjust to catch new CommandLineException
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch MSHARED-976
in repository https://gitbox.apache.org/repos/asf/maven-invoker.git
commit 14b12776ee1487cb2215686e826133bf1d431a66
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Tue Feb 2 16:43:09 2021 +0100
Adjust to catch new CommandLineException
---
.../apache/maven/shared/invoker/MavenCommandLineBuilder.java | 12 ++++++++++--
.../maven/shared/invoker/MavenCommandLineBuilderTest.java | 8 +++-----
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/src/main/java/org/apache/maven/shared/invoker/MavenCommandLineBuilder.java b/src/main/java/org/apache/maven/shared/invoker/MavenCommandLineBuilder.java
index 57021a0..3e21919 100644
--- a/src/main/java/org/apache/maven/shared/invoker/MavenCommandLineBuilder.java
+++ b/src/main/java/org/apache/maven/shared/invoker/MavenCommandLineBuilder.java
@@ -30,6 +30,7 @@ import org.apache.maven.shared.invoker.InvocationRequest.CheckSumPolicy;
import org.apache.maven.shared.invoker.InvocationRequest.ReactorFailureBehavior;
import org.apache.maven.shared.utils.Os;
import org.apache.maven.shared.utils.StringUtils;
+import org.apache.maven.shared.utils.cli.CommandLineException;
import org.apache.maven.shared.utils.cli.CommandLineUtils;
import org.apache.maven.shared.utils.cli.Commandline;
@@ -253,13 +254,20 @@ public class MavenCommandLineBuilder
}
- protected void setGoals( InvocationRequest request, Commandline cli )
+ protected void setGoals( InvocationRequest request, Commandline cli ) throws CommandLineConfigurationException
{
List<String> goals = request.getGoals();
if ( ( goals != null ) && !goals.isEmpty() )
{
- cli.createArg().setLine( StringUtils.join( goals.iterator(), " " ) );
+ try
+ {
+ cli.createArg().setLine( StringUtils.join( goals.iterator(), " " ) );
+ }
+ catch ( CommandLineException e )
+ {
+ throw new CommandLineConfigurationException( "Problem to set goals: " + e.getMessage(), e );
+ }
}
}
diff --git a/src/test/java/org/apache/maven/shared/invoker/MavenCommandLineBuilderTest.java b/src/test/java/org/apache/maven/shared/invoker/MavenCommandLineBuilderTest.java
index f9e29bb..e41d51d 100644
--- a/src/test/java/org/apache/maven/shared/invoker/MavenCommandLineBuilderTest.java
+++ b/src/test/java/org/apache/maven/shared/invoker/MavenCommandLineBuilderTest.java
@@ -665,8 +665,7 @@ public class MavenCommandLineBuilderTest
}
@Test
- public void testShouldSpecifySingleGoalFromRequest()
- throws IOException
+ public void testShouldSpecifySingleGoalFromRequest() throws CommandLineConfigurationException
{
List<String> goals = new ArrayList<String>();
@@ -678,8 +677,7 @@ public class MavenCommandLineBuilderTest
}
@Test
- public void testShouldSpecifyTwoGoalsFromRequest()
- throws IOException
+ public void testShouldSpecifyTwoGoalsFromRequest() throws CommandLineConfigurationException
{
List<String> goals = new ArrayList<String>();
goals.add( "test" );
@@ -989,7 +987,7 @@ public class MavenCommandLineBuilderTest
super.setFlags( request, cli );
}
- public void setGoals( InvocationRequest request, Commandline cli )
+ public void setGoals( InvocationRequest request, Commandline cli ) throws CommandLineConfigurationException
{
super.setGoals( request, cli );
}