Skip to content

Commit ec90523

Browse files
authored
Merge pull request #97 from egineering-llc/release/2.1.0
Release/2.1.0
2 parents cf96b50 + 62683b0 commit ec90523

File tree

6 files changed

+21
-12
lines changed

6 files changed

+21
-12
lines changed

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,11 +256,15 @@ Can be replaced with the following plugin configuration, which also introduces t
256256

257257
In addition to setting up repository targets for release branches, the `retarget-depoy` branch can deploy other branches
258258
matching the `otherDeploymentBranchPattern` as -SNAPSHOT artifacts which include the branch name as build metadata.
259-
This is loosely based on the [semVer](https://semver.org) semantic version scheme, in that the plugin will reversion any
260-
artifacts to be produced with `+feature-branch-name-normalized-SNAPSHOT` where any characters not in `[0-9A-Za-z-.]` will
261-
be replaced with `-`. Artifact versions for feature branches will _always_ be -SNAPSHOT, and will _always_ target the
259+
By default this is loosely based on the [semVer](https://semver.org) semantic version scheme, in that the plugin will
260+
reversion any artifacts to be produced with `+feature-branch-name-normalized-SNAPSHOT` where any characters not in
261+
`[0-9A-Za-z-.]` will be replaced with `-`. In cases where the `+` delimiter is problematic, you can override that default
262+
by specifying `<otherBranchVersionDelimiter>` in your configuration block.
263+
264+
Using this feature, artifact versions for feature branches will _always_ be -SNAPSHOT, and will _always_ target the
262265
Snapshots repository. The intent for this configuration setting is to provide a way for long-running branches (matching
263-
a naming convention you define) can be published to a SNAPSHOT repo for use by other projects.
266+
a naming convention you define) can be published to a SNAPSHOT repo for use by other projects, and to prevent feature
267+
branches forked from release branches from mangling the test release in an artifact repository.
264268

265269
## Goal: `update-stage-dependencies` (Force update of dependency staged Releases)
266270

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<groupId>com.e-gineering</groupId>
1010
<artifactId>gitflow-helper-maven-plugin</artifactId>
11-
<version>2.0.0</version>
11+
<version>2.1.0</version>
1212

1313
<packaging>maven-plugin</packaging>
1414

src/main/java/com/e_gineering/maven/gitflowhelper/AbstractGitflowBasedRepositoryMojo.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ private static PrintWriter newPrintWriter(File catalog) throws FileNotFoundExcep
8787
@Parameter(property = "otherDeployBranchPattern", required = false)
8888
String otherDeployBranchPattern;
8989

90+
@Parameter(defaultValue = "+", required = true)
91+
String otherBranchVersionDelimiter;
92+
9093
@Component
9194
private EnhancedLocalRepositoryManagerFactory localRepositoryManagerFactory;
9295

src/main/java/com/e_gineering/maven/gitflowhelper/RetargetDeployMojo.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ protected void execute(final GitBranchInfo gitBranchInfo) throws MojoExecutionEx
4747
updateArtifactVersion(a, gitBranchInfo.getName());
4848
}
4949

50-
getLog().info("Artifact versions updated with semVer build metadata: " + getAsBranchSnapshotVersion("", gitBranchInfo.getName()));
50+
getLog().info("Artifact versions updated with build metadata: " + getAsBranchSnapshotVersion("", gitBranchInfo.getName()));
5151
break;
5252
}
5353
}
@@ -84,8 +84,7 @@ private void updateArtifactVersion(Artifact a, String branchName) {
8484
* @return A mangled version string with the branchname and -SNAPSHOT.
8585
*/
8686
private String getAsBranchSnapshotVersion(final String version, final String branchName) {
87-
return version.replace("-SNAPSHOT", "") + "+" + branchName.replaceAll("[^0-9A-Za-z-.]", "-") + "-SNAPSHOT";
88-
87+
return version.replace("-SNAPSHOT", "") + otherBranchVersionDelimiter + branchName.replaceAll("[^0-9A-Za-z-.]", "-") + "-SNAPSHOT";
8988
}
9089

9190
private void setTargetSnapshots() throws MojoExecutionException, MojoFailureException {

src/test/java/com/e_gineering/maven/gitflowhelper/OtherBranchIT.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public void featureSnapshotSemVer() throws Exception {
1515
try {
1616
verifier.executeGoal("deploy");
1717

18-
verifier.verifyTextInLog("Artifact versions updated with semVer build metadata: +origin-feature-poc-my-feature-branch-SNAPSHOT");
18+
verifier.verifyTextInLog("Artifact versions updated with build metadata: +origin-feature-poc-my-feature-branch-SNAPSHOT");
1919
verifier.verifyErrorFreeLog();
2020
} finally {
2121
verifier.resetStreams();
@@ -28,7 +28,7 @@ public void featureSemVer() throws Exception {
2828
try {
2929
verifier.executeGoal("deploy");
3030

31-
verifier.verifyTextInLog("Artifact versions updated with semVer build metadata: +origin-feature-poc-my-feature-branch.with.other.identifiers-SNAPSHOT");
31+
verifier.verifyTextInLog("Artifact versions updated with build metadata: +origin-feature-poc-my-feature-branch.with.other.identifiers-SNAPSHOT");
3232
verifier.verifyErrorFreeLog();
3333
} finally {
3434
verifier.resetStreams();
@@ -55,19 +55,21 @@ public void automagicVersionDependenciesResolve() throws Exception {
5555
try {
5656
verifier.executeGoal("deploy");
5757

58-
verifier.verifyTextInLog("Artifact versions updated with semVer build metadata: +origin-feature-poc-long-running-SNAPSHOT");
58+
verifier.verifyTextInLog("Artifact versions updated with build metadata: +origin-feature-poc-long-running-SNAPSHOT");
5959
verifier.verifyErrorFreeLog();
6060
} finally {
6161
verifier.resetStreams();
6262
}
6363

6464
// Create a -SNAPSHOT of the project-alt1-stub that depends upon the other project's automagic version.
65+
// The alt project defines a `-` as the otherBranchVersionDelimiter.
6566
verifier = createVerifier("/project-alt1-stub", "origin/feature/poc/long-running", "2.0.0");
6667
try {
6768
verifier.getCliOptions().add("-Ddependency.stub.version=2.0.0+origin-feature-poc-long-running-SNAPSHOT");
6869
verifier.getCliOptions().add("-Dplugin.stub.version=2.0.0+origin-feature-poc-long-running-SNAPSHOT");
6970

7071
verifier.executeGoal("deploy");
72+
verifier.verifyTextInLog("Artifact versions updated with build metadata: -origin-feature-poc-long-running-SNAPSHOT");
7173
verifier.verifyErrorFreeLog();
7274
} finally {
7375
verifier.resetStreams();
@@ -80,7 +82,7 @@ public void attachDeployed() throws Exception {
8082
try {
8183
verifier.executeGoal("deploy");
8284

83-
verifier.verifyTextInLog("Artifact versions updated with semVer build metadata: +origin-feature-poc-reattach-SNAPSHOT");
85+
verifier.verifyTextInLog("Artifact versions updated with build metadata: +origin-feature-poc-reattach-SNAPSHOT");
8486
verifier.verifyErrorFreeLog();
8587
} finally {
8688
verifier.resetStreams();

src/test/resources/project-alt1-stub/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
<foo>bar</foo>
5858
</releaseBranchProperties>
5959
<otherDeployBranchPattern>(origin/)?feature/poc/.*</otherDeployBranchPattern>
60+
<otherBranchVersionDelimiter>-</otherBranchVersionDelimiter>
6061
</configuration>
6162
<executions>
6263
<execution>

0 commit comments

Comments
 (0)