From 38bd3636ef80a3118545cbdaaceb208fef121189 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Fri, 6 May 2022 20:27:43 +0200 Subject: [PATCH] [MRELEASE-1088] Remove parsing of CLI arguments --- maven-release-manager/pom.xml | 11 - .../config/ReleaseDescriptorBuilder.java | 36 +- .../release/exec/InvokerMavenExecutor.java | 414 +----------------- .../config/ReleaseDescriptorBuilderTest.java | 62 +++ .../exec/InvokerMavenExecutorTest.java | 97 +--- .../prepare/MRELEASE-667/verify.groovy | 1 + 6 files changed, 129 insertions(+), 492 deletions(-) create mode 100644 maven-release-manager/src/test/java/org/apache/maven/shared/release/config/ReleaseDescriptorBuilderTest.java diff --git a/maven-release-manager/pom.xml b/maven-release-manager/pom.xml index 717b5b2e3..60b10618b 100644 --- a/maven-release-manager/pom.xml +++ b/maven-release-manager/pom.xml @@ -113,17 +113,6 @@ commons-lang3 3.12.0 - - commons-cli - commons-cli - 1.5.0 - - - commons-lang - commons-lang - - - org.eclipse.aether diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseDescriptorBuilder.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseDescriptorBuilder.java index 0d7399955..60ab0fa18 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseDescriptorBuilder.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseDescriptorBuilder.java @@ -20,9 +20,13 @@ */ import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.apache.maven.model.Scm; import org.apache.maven.shared.release.util.ReleaseUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** *

ReleaseDescriptorBuilder class.

@@ -32,6 +36,10 @@ */ public class ReleaseDescriptorBuilder { + private static final Pattern PROPERTY_PATTERN = Pattern.compile( "\\$\\{[^}]+}" ); + + private final Logger logger; + /** * Hides inner logic of the release descriptor * @@ -50,9 +58,18 @@ private BuilderReleaseDescriptor() *

Constructor for ReleaseDescriptorBuilder.

*/ public ReleaseDescriptorBuilder() + { + this( LoggerFactory.getLogger( ReleaseDescriptorBuilder.class ) ); + } + + /** + * Constructor for testing purpose. + */ + ReleaseDescriptorBuilder( Logger logger ) { this.releaseDescriptor = new BuilderReleaseDescriptor(); this.releaseDescriptor.setLineSeparator( ReleaseUtil.LS ); + this.logger = logger; } /** @@ -99,7 +116,24 @@ public ReleaseDescriptorBuilder setAddSchema( boolean addSchema ) */ public ReleaseDescriptorBuilder setAdditionalArguments( String additionalArguments ) { - releaseDescriptor.setAdditionalArguments( additionalArguments ); + if ( additionalArguments != null ) + { + Matcher matcher = PROPERTY_PATTERN.matcher( additionalArguments ); + StringBuffer buf = new StringBuffer(); + while ( matcher.find() ) + { + matcher.appendReplacement( buf, "" ); + logger.warn( "arguments parameter contains unresolved property: '{}'", + matcher.group() ); + } + matcher.appendTail( buf ); + + releaseDescriptor.setAdditionalArguments( buf.toString() ); + } + else + { + releaseDescriptor.setAdditionalArguments( null ); + } return this; } diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/InvokerMavenExecutor.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/InvokerMavenExecutor.java index bed98cbd5..b118c4df9 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/InvokerMavenExecutor.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/InvokerMavenExecutor.java @@ -26,18 +26,12 @@ import java.io.File; import java.io.FileWriter; import java.io.IOException; -import java.util.Arrays; +import java.util.ArrayList; import java.util.List; -import java.util.Properties; -import org.apache.commons.cli.CommandLine; -import org.apache.commons.cli.DefaultParser; -import org.apache.commons.cli.Option; -import org.apache.commons.cli.Options; import org.apache.maven.settings.io.xpp3.SettingsXpp3Writer; import org.apache.maven.shared.invoker.DefaultInvocationRequest; import org.apache.maven.shared.invoker.DefaultInvoker; -import org.apache.maven.shared.invoker.InvocationOutputHandler; import org.apache.maven.shared.invoker.InvocationRequest; import org.apache.maven.shared.invoker.InvocationResult; import org.apache.maven.shared.invoker.Invoker; @@ -46,7 +40,6 @@ import org.apache.maven.shared.release.ReleaseResult; import org.apache.maven.shared.release.env.ReleaseEnvironment; import org.apache.maven.shared.release.util.MavenCrypto; -import org.codehaus.plexus.util.cli.CommandLineUtils; import org.slf4j.Logger; /** @@ -57,376 +50,37 @@ public class InvokerMavenExecutor extends AbstractMavenExecutor { - - private static final Options OPTIONS = new Options(); - - private static final String SET_SYSTEM_PROPERTY = "D"; - - private static final String OFFLINE = "o"; - - private static final String REACTOR = "r"; - - private static final String QUIET = "q"; - - private static final String DEBUG = "X"; - - private static final String ERRORS = "e"; - - private static final String NON_RECURSIVE = "N"; - - private static final String UPDATE_SNAPSHOTS = "U"; - - private static final String ACTIVATE_PROFILES = "P"; - - private static final String CHECKSUM_FAILURE_POLICY = "C"; - - private static final String CHECKSUM_WARNING_POLICY = "c"; - - private static final String ALTERNATE_USER_SETTINGS = "s"; - - private static final String ALTERNATE_GLOBAL_SETTINGS = "gs"; - - private static final String FAIL_FAST = "ff"; - - private static final String FAIL_AT_END = "fae"; - - private static final String FAIL_NEVER = "fn"; - - private static final String ALTERNATE_POM_FILE = "f"; - - private static final String THREADS = "T"; - - private static final String BATCH_MODE = "B"; - - public static final String ALTERNATE_USER_TOOLCHAINS = "t"; - - static - { - OPTIONS.addOption( - Option.builder( SET_SYSTEM_PROPERTY ) - .longOpt( "define" ) - .numberOfArgs( 2 ) - .valueSeparator( '=' ) - .desc( "Define a system property" ) - .build() ); - - OPTIONS.addOption( - Option.builder( OFFLINE ) - .longOpt( "offline" ) - .desc( "Work offline" ) - .build() ); - - OPTIONS.addOption( - Option.builder( QUIET ) - .longOpt( "quiet" ) - .desc( "Quiet output - only show errors" ) - .build() ); - - OPTIONS.addOption( - Option.builder( DEBUG ) - .longOpt( "debug" ) - .desc( "Produce execution debug output" ) - .build() ); - - OPTIONS.addOption( - Option.builder( ERRORS ) - .longOpt( "errors" ) - .desc( "Produce execution error messages" ) - .build() ); - - OPTIONS.addOption( - Option.builder( REACTOR ) - .longOpt( "reactor" ) - .desc( "Execute goals for project found in the reactor" ) - .build() ); - - OPTIONS.addOption( - Option.builder( NON_RECURSIVE ) - .longOpt( "non-recursive" ) - .desc( "Do not recurse into sub-projects" ) - .build() ); - - OPTIONS.addOption( - Option.builder( UPDATE_SNAPSHOTS ) - .longOpt( "update-snapshots" ) - .desc( "Forces a check for updated releases and snapshots on remote repositories" ) - .build() ); - - OPTIONS.addOption( - Option.builder( ACTIVATE_PROFILES ) - .longOpt( "activate-profiles" ) - .desc( "Comma-delimited list of profiles to activate" ) - .hasArg() - .build() ); - - OPTIONS.addOption( - Option.builder( CHECKSUM_FAILURE_POLICY ) - .longOpt( "strict-checksums" ) - .desc( "Fail the build if checksums don't match" ) - .build() ); - - OPTIONS.addOption( - Option.builder( CHECKSUM_WARNING_POLICY ) - .longOpt( "lax-checksums" ) - .desc( "Warn if checksums don't match" ) - .build() ); - - OPTIONS.addOption( - Option.builder( ALTERNATE_USER_SETTINGS ) - .longOpt( "settings" ) - .desc( "Alternate path for the user settings file" ) - .hasArg() - .build() ); - - OPTIONS.addOption( - Option.builder( ALTERNATE_GLOBAL_SETTINGS ) - .longOpt( "global-settings" ) - .desc( "Alternate path for the global settings file" ) - .hasArg() - .build() ); - - OPTIONS.addOption( - Option.builder( FAIL_FAST ) - .longOpt( "fail-fast" ) - .desc( "Stop at first failure in reactorized builds" ) - .build() ); - - OPTIONS.addOption( - Option.builder( FAIL_AT_END ) - .longOpt( "fail-at-end" ) - .desc( "Only fail the build afterwards; allow all non-impacted builds to continue" ) - .build() ); - - OPTIONS.addOption( - Option.builder( FAIL_NEVER ) - .longOpt( "fail-never" ) - .desc( "NEVER fail the build, regardless of project result" ) - .build() ); - - OPTIONS.addOption( - Option.builder( ALTERNATE_POM_FILE ) - .longOpt( "file" ) - .desc( "Force the use of an alternate POM file." ) - .hasArg() - .build() ); - - OPTIONS.addOption( - Option.builder( THREADS ) - .longOpt( "threads" ) - .desc( "Thread count, for instance 2.0C where C is core multiplied" ) - .hasArg() - .build() ); - - OPTIONS.addOption( - Option.builder( BATCH_MODE ) - .longOpt( "batch-mode" ) - .desc( "Run in non-interactive (batch) mode" ) - .build() ); - - OPTIONS.addOption( - Option.builder( ALTERNATE_USER_TOOLCHAINS ) - .longOpt( "toolchains" ) - .desc( "Alternate path for the user toolchains file" ) - .hasArg() - .build() ); - } - @Inject public InvokerMavenExecutor( MavenCrypto mavenCrypto ) { super( mavenCrypto ); } - // TODO: Configuring an invocation request from a command line could as well be part of the Invoker API - - /** - *

setupRequest.

- * - * @param req a {@link org.apache.maven.shared.invoker.InvocationRequest} object - * @param bridge a {@link org.apache.maven.shared.invoker.InvokerLogger} object - * @param additionalArguments a {@link java.lang.String} object - * @throws org.apache.maven.shared.release.exec.MavenExecutorException if any. - */ - protected void setupRequest( InvocationRequest req, - InvokerLogger bridge, - String additionalArguments ) - throws MavenExecutorException - { - try - { - String[] args = CommandLineUtils.translateCommandline( additionalArguments ); - CommandLine cli = new DefaultParser().parse( OPTIONS, args ); - - if ( cli.hasOption( SET_SYSTEM_PROPERTY ) ) - { - String[] properties = cli.getOptionValues( SET_SYSTEM_PROPERTY ); - Properties props = new Properties(); - for ( String property : properties ) - { - String name, value; - int sep = property.indexOf( "=" ); - if ( sep <= 0 ) - { - name = property.trim(); - value = "true"; - } - else - { - name = property.substring( 0, sep ).trim(); - value = property.substring( sep + 1 ).trim(); - } - props.setProperty( name, value ); - } - - req.setProperties( props ); - } - - if ( cli.hasOption( OFFLINE ) ) - { - req.setOffline( true ); - } - - if ( cli.hasOption( QUIET ) ) - { - req.setQuiet( true ); - } - else if ( cli.hasOption( DEBUG ) ) - { - req.setDebug( true ); - } - else if ( cli.hasOption( ERRORS ) ) - { - req.setShowErrors( true ); - } - - if ( cli.hasOption( REACTOR ) ) - { - req.setRecursive( true ); - } - else if ( cli.hasOption( NON_RECURSIVE ) ) - { - req.setRecursive( false ); - } - - if ( cli.hasOption( UPDATE_SNAPSHOTS ) ) - { - req.setUpdateSnapshots( true ); - } - - if ( cli.hasOption( ACTIVATE_PROFILES ) ) - { - String[] profiles = cli.getOptionValues( ACTIVATE_PROFILES ); - - if ( profiles != null ) - { - req.setProfiles( Arrays.asList( profiles ) ); - } - } - - if ( cli.hasOption( CHECKSUM_FAILURE_POLICY ) ) - { - req.setGlobalChecksumPolicy( InvocationRequest.CheckSumPolicy.Fail ); - } - else if ( cli.hasOption( CHECKSUM_WARNING_POLICY ) ) - { - req.setGlobalChecksumPolicy( InvocationRequest.CheckSumPolicy.Warn ); - } - - if ( cli.hasOption( ALTERNATE_USER_SETTINGS ) ) - { - req.setUserSettingsFile( new File( cli.getOptionValue( ALTERNATE_USER_SETTINGS ) ) ); - } - - if ( cli.hasOption( ALTERNATE_GLOBAL_SETTINGS ) ) - { - req.setGlobalSettingsFile( new File( cli.getOptionValue( ALTERNATE_GLOBAL_SETTINGS ) ) ); - } - - if ( cli.hasOption( FAIL_AT_END ) ) - { - req.setReactorFailureBehavior( InvocationRequest.ReactorFailureBehavior.FailAtEnd ); - } - else if ( cli.hasOption( FAIL_FAST ) ) - { - req.setReactorFailureBehavior( InvocationRequest.ReactorFailureBehavior.FailFast ); - } - if ( cli.hasOption( FAIL_NEVER ) ) - { - req.setReactorFailureBehavior( InvocationRequest.ReactorFailureBehavior.FailNever ); - } - if ( cli.hasOption( ALTERNATE_POM_FILE ) ) - { - if ( req.getPomFileName() != null ) - { - getLogger().info( "pomFileName is already set, ignoring the -f argument" ); - } - else - { - req.setPomFileName( cli.getOptionValue( ALTERNATE_POM_FILE ) ); - } - } - - if ( cli.hasOption( THREADS ) ) - { - req.setThreads( cli.getOptionValue( THREADS ) ); - } - - if ( cli.hasOption( BATCH_MODE ) ) - { - req.setBatchMode( true ); - } - - if ( cli.hasOption( ALTERNATE_USER_TOOLCHAINS ) ) - { - req.setToolchainsFile( new File( cli.getOptionValue( ALTERNATE_USER_TOOLCHAINS ) ) ); - } - - } - catch ( Exception e ) - { - throw new MavenExecutorException( "Failed to re-parse additional arguments for Maven invocation.", e ); - } - } - @Override public void executeGoals( File workingDirectory, List goals, ReleaseEnvironment releaseEnvironment, boolean interactive, String additionalArguments, String pomFileName, ReleaseResult result ) throws MavenExecutorException { - InvocationOutputHandler handler = getOutputHandler(); InvokerLogger bridge = getInvokerLogger(); - File mavenPath; - // if null we use the current one - if ( releaseEnvironment.getMavenHome() != null ) - { - mavenPath = releaseEnvironment.getMavenHome(); - } - else - { - String mavenHome = System.getProperty( "maven.home" ); - if ( mavenHome == null ) - { - mavenHome = System.getenv( "MAVEN_HOME" ); - } - if ( mavenHome == null ) - { - mavenHome = System.getenv( "M2_HOME" ); - } - mavenPath = mavenHome == null ? null : new File( mavenHome ); - } - Invoker invoker = new DefaultInvoker() - .setMavenHome( mavenPath ) + .setMavenHome( releaseEnvironment.getMavenHome() ) + .setLocalRepositoryDirectory( releaseEnvironment.getLocalRepositoryDirectory() ) .setLogger( bridge ); InvocationRequest req = new DefaultInvocationRequest() .setDebug( getLogger().isDebugEnabled() ) .setBaseDirectory( workingDirectory ) .setBatchMode( !interactive ) - .setOutputHandler( handler ) - .setErrorHandler( handler ); + .setOutputHandler( getLogger()::info ) + .setErrorHandler( getLogger()::error ); + + // for interactive mode we need some inputs stream + if ( interactive ) + { + req.setInputStream( System.in ); + } if ( pomFileName != null ) { @@ -453,17 +107,18 @@ public void executeGoals( File workingDirectory, List goals, ReleaseEnvi throw new MavenExecutorException( "Could not create temporary file for release settings.xml", e ); } } + try { - File localRepoDir = releaseEnvironment.getLocalRepositoryDirectory(); - if ( localRepoDir != null ) + List targetGoals = new ArrayList<>( goals ); + + if ( additionalArguments != null && !additionalArguments.isEmpty() ) { - req.setLocalRepositoryDirectory( localRepoDir ); + // additionalArguments will be parsed be MavenInvoker + targetGoals.add( additionalArguments ); } - setupRequest( req, bridge, additionalArguments ); - - req.setGoals( goals ); + req.setGoals( targetGoals ); try { @@ -472,13 +127,14 @@ public void executeGoals( File workingDirectory, List goals, ReleaseEnvi if ( invocationResult.getExecutionException() != null ) { throw new MavenExecutorException( "Error executing Maven.", - invocationResult.getExecutionException() ); + invocationResult.getExecutionException() ); } + if ( invocationResult.getExitCode() != 0 ) { throw new MavenExecutorException( - "Maven execution failed, exit code: '" + invocationResult.getExitCode() + "'", - invocationResult.getExitCode() ); + "Maven execution failed, exit code: " + invocationResult.getExitCode(), + invocationResult.getExitCode() ); } } catch ( MavenInvocationException e ) @@ -505,32 +161,6 @@ protected InvokerLogger getInvokerLogger() return new LoggerBridge( getLogger() ); } - /** - *

getOutputHandler.

- * - * @return a {@link org.apache.maven.shared.invoker.InvocationOutputHandler} object - */ - protected InvocationOutputHandler getOutputHandler() - { - return new Handler( getLogger() ); - } - - private static final class Handler - implements InvocationOutputHandler - { - private final Logger logger; - - Handler( Logger logger ) - { - this.logger = logger; - } - - public void consumeLine( String line ) - { - logger.info( line ); - } - } - private static final class LoggerBridge implements InvokerLogger { diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/config/ReleaseDescriptorBuilderTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/config/ReleaseDescriptorBuilderTest.java new file mode 100644 index 000000000..907033c8e --- /dev/null +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/config/ReleaseDescriptorBuilderTest.java @@ -0,0 +1,62 @@ +package org.apache.maven.shared.release.config; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.junit.Test; +import org.mockito.Mockito; +import org.slf4j.Logger; + +import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.reset; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.verifyZeroInteractions; + +public class ReleaseDescriptorBuilderTest +{ + private final Logger logger = Mockito.mock( Logger.class ); + + @Test + public void testCleanupArguments() + { + setAdditionalArguments( "abc abc -Dxxx", "abc abc -Dxxx"); + verifyZeroInteractions( logger ); + reset( logger ); + + setAdditionalArguments( "abc abc ${arguments}", "abc abc " ); + verify( logger ).warn( anyString(), eq( "${arguments}" ) ); + verifyNoMoreInteractions( logger ); + reset( logger ); + + setAdditionalArguments( "abc ${first} abc ${arguments}", "abc abc " ); + verify( logger ).warn( anyString(), eq( "${first}" ) ); + verify( logger ).warn( anyString(), eq( "${arguments}" ) ); + verifyNoMoreInteractions( logger ); + } + + private void setAdditionalArguments(String input, String expected) + { + ReleaseDescriptorBuilder builder = new ReleaseDescriptorBuilder( logger ); + builder.setAdditionalArguments( input ); + assertEquals( expected, builder.build().getAdditionalArguments() ); + } +} diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/exec/InvokerMavenExecutorTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/exec/InvokerMavenExecutorTest.java index b8afc8b12..73da65af8 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/exec/InvokerMavenExecutorTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/exec/InvokerMavenExecutorTest.java @@ -19,17 +19,6 @@ * under the License. */ -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.isA; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - import java.io.File; import java.io.Writer; @@ -37,18 +26,23 @@ import org.apache.maven.settings.Server; import org.apache.maven.settings.Settings; import org.apache.maven.settings.io.xpp3.SettingsXpp3Writer; -import org.apache.maven.shared.invoker.DefaultInvocationRequest; -import org.apache.maven.shared.invoker.InvocationRequest; import org.apache.maven.shared.release.PlexusJUnit4TestCase; import org.apache.maven.shared.release.ReleaseResult; import org.apache.maven.shared.release.env.DefaultReleaseEnvironment; import org.apache.maven.shared.release.util.MavenCrypto; -import org.codehaus.plexus.PlexusTestCase; -import org.codehaus.plexus.logging.Logger; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.sonatype.plexus.components.sec.dispatcher.SecDispatcher; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotSame; +import static org.mockito.Matchers.isA; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + public class InvokerMavenExecutorTest extends PlexusJUnit4TestCase { @@ -67,77 +61,6 @@ public void setUp() secDispatcher = lookup( SecDispatcher.class ); } - @Test - public void testThreads() - throws Exception - { - InvokerMavenExecutor executor = new InvokerMavenExecutor( mavenCrypto ); - - InvocationRequest req = new DefaultInvocationRequest(); - executor.setupRequest( req, null, "-T 3" ); - assertEquals( "3", req.getThreads() ); - - req = new DefaultInvocationRequest(); - executor.setupRequest( req, null, "-T4" ); - assertEquals( "4", req.getThreads() ); - - req = new DefaultInvocationRequest(); - executor.setupRequest( req, null, "\"-T5\"" ); - assertEquals( "5", req.getThreads() ); - } - - @Test - public void testBatch() - throws Exception - { - InvokerMavenExecutor executor = new InvokerMavenExecutor( mavenCrypto ); - - InvocationRequest req = new DefaultInvocationRequest(); - - req.setBatchMode( false ); - executor.setupRequest( req, null, "-B" ); - assertTrue( req.isBatchMode() ); - - req = new DefaultInvocationRequest(); - req.setBatchMode( false ); - executor.setupRequest( req, null, "\"-B\"" ); - assertTrue( req.isBatchMode() ); - } - - @Test - public void testUserToolchains() - throws Exception - { - InvokerMavenExecutor executor = new InvokerMavenExecutor( mavenCrypto ); - - InvocationRequest req = new DefaultInvocationRequest(); - executor.setupRequest( req, null, "-t mytoolchains.xml" ); - assertEquals( new File( "mytoolchains.xml" ), req.getToolchainsFile() ); - - req = new DefaultInvocationRequest(); - executor.setupRequest( req, null, "-tmytoolchains.xml" ); - assertEquals( new File( "mytoolchains.xml" ), req.getToolchainsFile() ); - - req = new DefaultInvocationRequest(); - executor.setupRequest( req, null, "\"-tmytoolchains.xml\"" ); - assertEquals( new File( "mytoolchains.xml" ), req.getToolchainsFile() ); - } - - @Test - public void testGlobalSettings() - throws Exception - { - InvokerMavenExecutor executor = new InvokerMavenExecutor( mavenCrypto ); - - InvocationRequest req = new DefaultInvocationRequest(); - executor.setupRequest( req, null, "-gs custom-settings.xml" ); - assertEquals( "custom-settings.xml", req.getGlobalSettingsFile().getPath() ); - - req = new DefaultInvocationRequest(); - executor.setupRequest( req, null, "--global-settings other-settings.xml" ); - assertEquals( "other-settings.xml", req.getGlobalSettingsFile().getPath() ); - } - public void testEncryptSettings() throws Exception { @@ -167,8 +90,6 @@ public void testEncryptSettings() ArgumentCaptor encryptedSettings = ArgumentCaptor.forClass( Settings.class ); when( executorSpy.getSettingsWriter() ).thenReturn( settingsWriter ); - when( executorSpy.getOutputHandler() ).thenReturn( null ); - when( executorSpy.getInvokerLogger() ).thenReturn( null ); try { diff --git a/maven-release-plugin/src/it/projects/prepare/MRELEASE-667/verify.groovy b/maven-release-plugin/src/it/projects/prepare/MRELEASE-667/verify.groovy index 1440a7a0b..bd42e6d58 100644 --- a/maven-release-plugin/src/it/projects/prepare/MRELEASE-667/verify.groovy +++ b/maven-release-plugin/src/it/projects/prepare/MRELEASE-667/verify.groovy @@ -25,3 +25,4 @@ assert buildLog.exists() //assert 1 == buildLog.getText().count("[DEBUG] Profile with id: 'mrelease-677' has been explicitly activated.") assert 1 == buildLog.getText().count(" Profile Id: mrelease-677 (Active: false , Source: settings.xml)") +assert buildLog.getText().contains("[WARNING] arguments parameter contains unresolved property: '\${arguments}'")