Skip to content

Confusing deprecation of Version.setPreReleaseVersion() #75

@rubenyo-group9

Description

@rubenyo-group9

Hello,

While updating our company’s Gradle scripting with jsemver (via the axion-release-plugin), I ran into a confusing deprecation.

Code example

In this example, we try to set a prerelease version if none exists yet.

if (context.currentVersion.preReleaseVersion().isEmpty()) {
    return context.currentVersion.incrementMinorVersion()
        .setPreReleaseVersion("rc.1");
}

Problem

  • Version.setPreReleaseVersion(String) is deprecated (link), with a Javadoc note suggesting nextPreReleaseVersion(String...) instead.
  • However, nextPreReleaseVersion fails when no pre-release version exists because of the isPreRelease() check.
  • This makes it impossible to replace the deprecated call in the example above.

Expected behavior

Either:

  1. The deprecation message should be updated to reflect the correct replacement (or lack thereof) when no pre-release exists.
  2. Or, a non-deprecated API should exist for the above code fragment (setting the first pre-release version).

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions