Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MRELEASE-1088] Remove parsing of CLI arguments #120

Merged
merged 1 commit into from
May 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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