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

add betaExpand maven mojo parameter #595

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* [CHG] Separate digest settings for creating the deb and signing it
* [CHG] Upgraded deps
* [FIX] Removed invalid Maven Mojo Deprecation
* [ADD] betaExpand to control rc, alpha and beta version processing

## Version 1.10, released 30.11.2021

Expand Down
1 change: 1 addition & 0 deletions docs/maven.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ attach | Attach artifact to project
snapshotExpand | Expand SNAPSHOT into the content of an environment variable or timestamp. | No; defaults to `false`
snapshotEnv | Name of the environment variable. If it's empty defaults to a timestamp. | No; defaults to `SNAPSHOT`
snapshotTemplate | Template for replacing the SNAPSHOT value. A timestamp format can be provided in brackets. | No;
betaExpand | Prepend rc, alpha or beta version with `~`. | No; defaults to `true`
verbose | Verbose logging | No; defaults to `true`, will be `false` in the future
skip | Indicates if an execution should be skipped | No; defaults to `false`
skipSubmodules | Skip goal on all submodules | No; defaults to `false`
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/org/vafer/jdeb/maven/DebMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,12 @@ public class DebMojo extends AbstractMojo {
@Parameter
private String snapshotTemplate;

/**
* When enabled the separator before a rc, alpha or beta version is replaced with '~'.
*/
@Parameter(defaultValue = "true")
private boolean betaExpand;

/**
* If verbose is true more build messages are logged.
*/
Expand Down Expand Up @@ -440,7 +446,7 @@ protected VariableResolver initializeVariableResolver( Map<String, String> varia
* @return the Maven project version
*/
private String getProjectVersion() {
return Utils.convertToDebianVersion(getProject().getVersion(), this.snapshotExpand, this.snapshotEnv, this.snapshotTemplate, session.getStartTime());
return Utils.convertToDebianVersion(getProject().getVersion(), this.snapshotExpand, this.snapshotEnv, this.snapshotTemplate, session.getStartTime(), this.betaExpand);
}

/**
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/org/vafer/jdeb/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,9 @@ private static String formatSnapshotTemplate( String template, Date timestamp )
* @param template the template used to replace -SNAPSHOT, the timestamp format is in brackets,
* the rest of the string is preserved (prefix[yyMMdd]suffix -> prefix151230suffix)
* @param timestamp the UTC date used as the timestamp to replace the SNAPSHOT suffix.
* @param betaExpand whether to process the rc, alpha or beta version
*/
public static String convertToDebianVersion( String version, boolean apply, String envName, String template, Date timestamp ) {
public static String convertToDebianVersion( String version, boolean apply, String envName, String template, Date timestamp, boolean betaExpand ) {
Matcher matcher = SNAPSHOT_PATTERN.matcher(version);
if (matcher.matches()) {
version = matcher.group(1) + "~";
Expand All @@ -270,7 +271,7 @@ public static String convertToDebianVersion( String version, boolean apply, Stri
} else {
version += "SNAPSHOT";
}
} else {
} else if (betaExpand) {
matcher = BETA_PATTERN.matcher(version);
if (matcher.matches()) {
if (matcher.group(1) != null) {
Expand Down
Loading