Yes ofcourse.

I have created the appropriate tickets and pull requests:

https://issues.apache.org/jira/browse/SCM-977
https://github.com/apache/maven-scm/pull/135

and

https://issues.apache.org/jira/browse/MRELEASE-1078
https://github.com/apache/maven-release/pull/104

This second pull request still has some rough edges:
- The config is not as clean as I would have liked it to be. I would have
liked to extend the XML schema for the configuration but because this is
really a plugin for a maven plugin I have not yet been able to figure out
how to do this.
- Some of the IT tests fail at this point.
- I would like to provide documentation for the web site.

The custom config allows you to have
- a custom format of the SCM tag and the system can still find and parse it.
- a custom set of patterns to look for in the commit messages to determine
if a patch/minor/major update is needed. The default rules assume the tag
to be just the version (i.e. "1.2.3") and the patterns to follow my
understanding of https://www.conventionalcommits.org/en/v1.0.0/

A "full" example (copied from the IT test I created):

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-release-plugin</artifactId>
  <version>@project.version@</version>
  <configuration>
    <allowReleasePluginSnapshot>true</allowReleasePluginSnapshot>
    <allowTimestampedSnapshots>true</allowTimestampedSnapshots>

    <pushChanges>false</pushChanges>
    <remoteTagging>false</remoteTagging>

    <scmCommentPrefix>ci(Release): </scmCommentPrefix>
    <scmReleaseCommitComment>ci(Release): Version
@{releaseLabel}</scmReleaseCommitComment>
    <tagNameFormat>v@{project.version}</tagNameFormat>
    <projectVersionPolicyId>CCSemVerVersionPolicy</projectVersionPolicyId>

    <!-- projectVersionPolicyConfig is an XML structure:  -->
    <!-- versionTag: A regex with 1 capture group that MUST extract
the project.version from the SCM tag. -->
    <!-- minorRules: A list regexes that will be matched against all
lines in each commit message since   -->
    <!--             the last tag. If matched the next version is at
least a MINOR update.                -->
    <!-- majorRules: A list regexes that will be matched against all
lines in each commit message since   -->
    <!--             the last tag. If matched the next version is at
least a MAJOR update.                -->
    <!-- If a match is found the commit will trigger either a minor or
major version increase             -->
    <!-- instead of only a patch increase.  -->
    <projectVersionPolicyConfig>
      <![CDATA[
      <cCSemverConfig>
        <versionTag>^v([0-9]+(?:\.[0-9]+(?:\.[0-9]+)?)?)$</versionTag>
        <majorRules>
          <majorRule>^[a-zA-Z]+!(?:\([a-zA-Z0-9_-]+\))?: .*$</majorRule>
          <majorRule>^BREAKING CHANGE:.*$</majorRule>
        </majorRules>
        <minorRules>
          <minorRule>^feat(?:\([a-zA-Z0-9_-]+\))?: .*$</minorRule>
        </minorRules>
      </cCSemverConfig>
      ]]>
    </projectVersionPolicyConfig>

  </configuration>
  <dependencies>
    <dependency>
      <groupId>org.apache.maven.its.release</groupId>
      <artifactId>maven-scm-provider-dummy</artifactId>
      <version>1.0</version>
    </dependency>
    <dependency>
      <groupId>org.apache.maven.release</groupId>
      <artifactId>maven-release-ccsemver-policy</artifactId>
      <version>@project.version@</version>
    </dependency>
  </dependencies>
</plugin>





I'm looking forward to your feedback.

Niels

On Tue, Feb 15, 2022 at 10:00 PM Olivier Lamy <ol...@apache.org> wrote:

> sounds an interesting idea.
> would you mind having this as PRs to ease code review?
>
> On Tue, 15 Feb 2022 at 03:00, Niels Basjes <ni...@basjes.nl> wrote:
>
> > Hi,
> >
> > I would like to use the ideas from the Conventional Commits to
> > automatically determine the next version for my release when releasing
> with
> > the maven-release-plugin.
> >
> > Since this is not yet a part of the current version of the release
> plugin I
> > decided to give it a go myself.
> >
> > So far I have succeeded in creating a new VersionPolicy that does this
> and
> > I'm wondering if the committers would consider including this idea or
> not.
> > I expect my code will need some more cleanups and changes on my end
> before
> > it can be included.
> >
> > Summary of what I had to change to make this work:
> > In maven-scm (
> > https://github.com/nielsbasjes/maven-scm/tree/SCM-xxx-ChangelogTags )
> > - I had to add the functionality that a ChangeSet could contain the tags
> > present on the commits as well.
> >   It is generic and I've added this functionality for gitexe and jgit.
> >   For gitexe I had to change the command used by the changelog command to
> > get the tags.
> >
> > In maven-release (
> > https://github.com/nielsbasjes/maven-release/tree/MRELEASE-xxx-CCSEMVER
> )
> > - I extended the VersionPolicyRequest to include the connection to the
> SCM
> > and a config parameter (right now a String) to configure the patterns to
> > look for in the pom.xml of the project that is to be released.
> > - I created a new VersionPolicy that examines the tags and commit
> messages
> > and from this computes if a patch, minor or major version update is
> needed.
> >
> > To check it actually works I created a dummy test project that has this
> > plugin:
> > https://github.com/nielsbasjes/releasetester/blob/main/pom.xml#L94
> >
> > So simply put: Should I file two jira tickets and put up the pull
> requests
> > so you can review my ideas ?
> >
> > --
> > Best regards / Met vriendelijke groeten,
> >
> > Niels Basjes
> >
>


-- 
Best regards / Met vriendelijke groeten,

Niels Basjes

Reply via email to