Skip to content

Commit

Permalink
[MRELEASE-1088] Remove parsing of CLI arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
slawekjaranowski committed May 6, 2022
1 parent dafdd7f commit 26cd6f6
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 492 deletions.
11 changes: 0 additions & 11 deletions maven-release-manager/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,6 @@
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.5.0</version>
<exclusions>
<exclusion>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.eclipse.aether</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
* <p>ReleaseDescriptorBuilder class.</p>
Expand All @@ -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
*
Expand All @@ -50,9 +58,18 @@ private BuilderReleaseDescriptor()
* <p>Constructor for ReleaseDescriptorBuilder.</p>
*/
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;
}

/**
Expand Down Expand Up @@ -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;
}

Expand Down
Loading

0 comments on commit 26cd6f6

Please sign in to comment.