[ 
https://issues.apache.org/jira/browse/MRELEASE-979?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15897981#comment-15897981
 ] 

Henning Schmiedehausen edited comment on MRELEASE-979 at 3/6/17 8:15 PM:
-------------------------------------------------------------------------

Hello [~rfscholte],

thank you for merging some pieces of my pull request over the weekend. 
Unfortunately, this is still not working for me.

I will make another attempt at explaining what my problem is and where your 
changes fall short. If you are simply not willing to merge any of these 
changes, please simply say so and I can stop wasting your time. I will give you 
a step-by-step example of my scenario and what we are doing here and why it 
matters to us.

Our release process consists of multiple steps:

- first we create a tag using "mvn release:prepare". We drive this from a 
version policy and it yields a git tag called 
{{<project-name>-<major>.<minor>-rc}} E.g {{foo-service-2.5-rc}}. This is a tag 
in our git repository marking what is an RC.
- the next step is to checkout this tag. There is now a working directory that 
sits on this tag.
- the next step is to execute a command that looks like this:  {{mvn 
---batch-mode -Pcreate-branch release:branch}}. The goal of this command is to 
create a release branch from which we will cut the release. This is our use 
case for a naming policy. We want this branch to be called 
{{<project-name>-<major>.<minor>-release}}. In addition we also apply a 
versioning policy that turns the version on this branch to be 
{{<major>.<minor>.0-SNAPSHOT}} (e.g. 2.5.0-SNAPSHOT).

To accomplish that, we have created a NamingPolicy that looks like this: 
https://gist.github.com/hgschmie/d34ecc6c2c44c39870c86561fd0d0fc5. It is 
straightforward: Take the version proposed in the policy, remove the patch, add 
`-release`, prepend the project name, return as the branch name to use.

What the command executes is based off a release-plugin configuration that 
looks like this:

{code:xml}
<build>
    <plugins>
      <plugin>
        <artifactId>maven-release-plugin</artifactId>
        <dependencies>
          <dependency>
            <groupId>com.zuora.maven</groupId>
            <artifactId>zuora-release-policy</artifactId>
            <version>1.5</version>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
    <pluginManagement>
      <plugins>
        <plugin>
          <artifactId>maven-release-plugin</artifactId>
          <version>3.0.0</version>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

  <profiles>
    <profile>
      <id>create-branch</id>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-release-plugin</artifactId>
            <configuration>
              <projectVersionPolicyId>CreateBranch</projectVersionPolicyId>
              
<projectBranchNamingPolicyId>CreateBranch</projectBranchNamingPolicyId>
              <updateBranchVersions>true</updateBranchVersions>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
{code}

The {{zuora-release-policy}} jar contains the class mentioned above.

This is the fully resolved ({{help:effective-pom}}) configuration of the 
release plugin:

{code:xml}
      <plugin>
        <artifactId>maven-release-plugin</artifactId>
        <version>3.0.0</version>
        <dependencies>
          <dependency>
            <groupId>com.zuora.maven</groupId>
            <artifactId>zuora-release-policy</artifactId>
            <version>1.5</version>
            <scope>compile</scope>
          </dependency>
        </dependencies>
        <configuration>
          <projectVersionPolicyId>CreateBranch</projectVersionPolicyId>
          
<projectBranchNamingPolicyId>CreateBranch</projectBranchNamingPolicyId>
          <updateBranchVersions>true</updateBranchVersions>
          <releaseProfiles>zuora-release</releaseProfiles>
          <autoVersionSubmodules>true</autoVersionSubmodules>
          <mavenExecutorId>forked-path</mavenExecutorId>
          <pushChanges>false</pushChanges>
          <localCheckout>true</localCheckout>
          <preparationGoals>clean install</preparationGoals>
          <useReleaseProfile>false</useReleaseProfile>
          
<tagNameFormat>@{project.artifactId}-@{project.version}</tagNameFormat>
          <goals>deploy</goals>
        </configuration>
      </plugin>
{code}

All of this worked seamlessly with the three different options that I presented 
to you. With every change that you committed, I end up with this:

{noformat}
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.946 s
[INFO] Finished at: 2017-03-06T12:06:12-08:00
[INFO] Final Memory: 18M/309M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal 
org.apache.maven.plugins:maven-release-plugin:3.0.0:branch (default-cli) on 
project branch-project: No branch name was given. -> [Help 1]
[ERROR]
{noformat}

This is what happens:

- The code enters InputVariablesPhase#116 (execute) method
- the tag is null, so it enters the code wrapped by the if ( tag == null ) in 
line 129
- in the current code, the scmTagName is not null but the naming policy name is 
also not null, so it enters the else branch of the check in line 139 which 
starts at line 160 and executes the policy to get the default tag name.
- in line 185, because the release is non-interactive, it does not enter the 
prompter code but goes to the else if branch in line 210
- because it is a branch operation, it unconditionally fails in line 212.

I can not describe this any better. This is all I got. The code does not work 
for branch operations and will never work. In fact, there is *NO* code path 
where the defaultTag can make its way to line 216 to be assigned to the tag for 
a branch operation. None of your changes so far has addressed the actual 
problem.

I have tried to work with the current maven committers to get this fixed. I 
have offered a number of pull requests and I will offer another but at some 
point I will simply stop if I feel that my work leads nowhere. Thank you for 
understanding this. 





was (Author: hgschmie):
Hello [~rfscholte],

thank you for merging some pieces of my pull request over the weekend. 
Unfortunately, this is still not working for me.

I will make another attempt at explaining what my problem is and where your 
changes fall short. If you are simply not willing to merge any of these 
changes, please simply say so and I can stop wasting your time. I will give you 
a step-by-step example of my scenario and what we are doing here and why it 
matters to us.

Our release process consists of multiple steps:

- first we create a tag using "mvn release:prepare". We drive this from a 
version policy and it yields a git tag called 
"<project-name>-<major>.<minor>-rc" E.g "foo-service-2.5-rc". This is a tag in 
our git repository marking what is an RC.
- the next step is to checkout this tag. There is now a working directory that 
sits on this tag.
- the next step is to execute a command that looks like this:  `mvn 
---batch-mode -Pcreate-branch release:branch`. The goal of this command is to 
create a release branch from which we will cut the release. This is our use 
case for a naming policy. We want this branch to be called 
`<project-name>-<major>.<minor>-release`. In addition we also apply a 
versioning policy that turns the version on this branch to be 
"<major>.<minor>.0-SNAPSHOT" (e.g. 2.5.0-SNAPSHOT).

To accomplish that, we have created a NamingPolicy that looks like this: 
https://gist.github.com/hgschmie/d34ecc6c2c44c39870c86561fd0d0fc5. It is 
straightforward: Take the version proposed in the policy, remove the patch, add 
`-release`, prepend the project name, return as the branch name to use.

What the command executes is based off a release-plugin configuration that 
looks like this:

```
<build>
    <plugins>
      <plugin>
        <artifactId>maven-release-plugin</artifactId>
        <dependencies>
          <dependency>
            <groupId>com.zuora.maven</groupId>
            <artifactId>zuora-release-policy</artifactId>
            <version>1.5</version>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
    <pluginManagement>
      <plugins>
        <plugin>
          <artifactId>maven-release-plugin</artifactId>
          <version>3.0.0</version>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

  <profiles>
    <profile>
      <id>create-branch</id>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-release-plugin</artifactId>
            <configuration>
              <projectVersionPolicyId>CreateBranch</projectVersionPolicyId>
              
<projectBranchNamingPolicyId>CreateBranch</projectBranchNamingPolicyId>
              <updateBranchVersions>true</updateBranchVersions>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
```

The `zuora-release-policy` jar contains the class mentioned above.

This is the fully resolved (`help:effective-pom`) configuration of the release 
plugin:

```
      <plugin>
        <artifactId>maven-release-plugin</artifactId>
        <version>3.0.0</version>
        <dependencies>
          <dependency>
            <groupId>com.zuora.maven</groupId>
            <artifactId>zuora-release-policy</artifactId>
            <version>1.5</version>
            <scope>compile</scope>
          </dependency>
        </dependencies>
        <configuration>
          <projectVersionPolicyId>CreateBranch</projectVersionPolicyId>
          
<projectBranchNamingPolicyId>CreateBranch</projectBranchNamingPolicyId>
          <updateBranchVersions>true</updateBranchVersions>
          <releaseProfiles>zuora-release</releaseProfiles>
          <autoVersionSubmodules>true</autoVersionSubmodules>
          <mavenExecutorId>forked-path</mavenExecutorId>
          <pushChanges>false</pushChanges>
          <localCheckout>true</localCheckout>
          <preparationGoals>clean install</preparationGoals>
          <useReleaseProfile>false</useReleaseProfile>
          
<tagNameFormat>@{project.artifactId}-@{project.version}</tagNameFormat>
          <goals>deploy</goals>
        </configuration>
      </plugin>
```

All of this worked seamlessly with the three different options that I presented 
to you. With every change that you committed, I end up with this:

```
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.946 s
[INFO] Finished at: 2017-03-06T12:06:12-08:00
[INFO] Final Memory: 18M/309M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal 
org.apache.maven.plugins:maven-release-plugin:3.0.0:branch (default-cli) on 
project branch-project: No branch name was given. -> [Help 1]
[ERROR]
```

This is what happens:

- The code enters InputVariablesPhase#116 (execute) method
- the tag is null, so it enters the code wrapped by the if ( tag == null ) in 
line 129
- in the current code, the scmTagName is not null but the naming policy name is 
also not null, so it enters the else branch of the check in line 139 which 
starts at line 160 and executes the policy to get the default tag name.
- in line 185, because the release is non-interactive, it does not enter the 
prompter code but goes to the else if branch in line 210
- because it is a branch operation, it unconditionally fails in line 212.

I can not describe this any better. This is all I got. The code does not work 
for branch operations and will never work. In fact, there is *NO* code path 
where the defaultTag can make its way to line 216 to be assigned to the tag for 
a branch operation. None of your changes so far has addressed the actual 
problem.

I have tried to work with the current maven committers to get this fixed. I 
have offered a number of pull requests and I will offer another but at some 
point I will simply stop if I feel that my work leads nowhere. Thank you for 
understanding this. 




> Support NamingPolicies to manage Branch and Tag names
> -----------------------------------------------------
>
>                 Key: MRELEASE-979
>                 URL: https://issues.apache.org/jira/browse/MRELEASE-979
>             Project: Maven Release Plugin
>          Issue Type: Improvement
>          Components: branch, prepare, update-versions
>    Affects Versions: 2.5.3
>            Reporter: Henning Schmiedehausen
>             Fix For: 3.0.0
>
>
> The newly introduced VersionPolicy facility allows managing the development 
> and release versions of projects when releasing, branching and updating 
> versions.
> Most organizations will also have a policy around how branches and tags are 
> named (which often have to match specific versioning patterns). The current 
> VersionPolicy implementations do not allow this but it should be possible.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to