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

branchVersionIncrementer cannot be serialized #590

Open
savasimic opened this issue Mar 2, 2023 · 5 comments
Open

branchVersionIncrementer cannot be serialized #590

savasimic opened this issue Mar 2, 2023 · 5 comments

Comments

@savasimic
Copy link

savasimic commented Mar 2, 2023

I tried to use different custom incrementers for different branches. When executing task currentVersion I was receiving error like:

* What went wrong:
Execution failed for task ':currentVersion'.
> Cannot fingerprint input property 'versionConfig.branchVersionIncrementer': value '...' cannot be serialized.

I tried to set branchVersionIncrementer with same values like in documentation

scmVersion {
    branchVersionIncrementer = [
            'feature/.*' : 'incrementMinor',
            'bugfix/.*' : { c -> return c.currentVersion.incrementPatchVersion() },
            'legacy/.*' : [ 'incrementMinorIfNotOnRelease', [releaseBranchPattern: 'legacy/release.*'] ],
    ]
    checks {
        uncommittedChanges.set(false)
    }
}

and got same error

* What went wrong:
Execution failed for task ':currentVersion'.
> Cannot fingerprint input property 'versionConfig.branchVersionIncrementer': value '{feature/.*=incrementMinor, bugfix/.*=build_ahvhhwjkzwvr3796kswh2j1q4$_run_closure1$_closure5$_closure12@7d8e0d33, legacy/.*=[incrementMinorIfNotOnRelease, {releaseBranchPattern=legacy/release.*}]}' cannot be serialized.

This is happening only when I'm using closures.

Did anyone had similar issue?

Just to note, I'm using gradle 7.5 and version of axion-release-plugin 1.14.4.

@bgalek
Copy link
Collaborator

bgalek commented Apr 4, 2023

hi! @savasimic could you create a repo than we can debug on? maybe we introduced some problems when adding kotlin dsl support - did it work on any version for you?

@savasimic
Copy link
Author

savasimic commented Apr 6, 2023

Hi @bgalek ,
here is sample repository with reproduced issue.
I included 2 branches where I'm running currentVersion task for 1.13.14 and 1.14.4 versions of axion-release plugin:

@duschata
Copy link
Contributor

duschata commented May 17, 2023

Hi All,
I've the same issue and have created a test here:
https://github.com/duschata/axion-release-plugin/blob/main/src/integration/groovy/pl/allegro/tech/build/axion/release/BranchVersionIncrementerTest.groovy

This test will allways fail since version 1.14.0 because the introduction of the @input annation with this commit:
#516

The simple fix is to remove the @input annotation above

    @Optional
    abstract MapProperty<String, Object> getBranchVersionIncrementer();

Probably these (and also other) @input annotations are usesless at this point because the closure is always evalated at configuration time and there is no expensive input/output (writing) task which needs caching,

Is it possible to remove them in 1.15.1?
Kind regards,
Tom

@bgalek
Copy link
Collaborator

bgalek commented May 17, 2023

@duschata nice! thx! Do you want to make a PR and remove unnecessary annotations? I can do it next week probably - and I'll be happy to release new version

@jjohannes
Copy link

@duschata I think the "better" fix would be to use the @Internal annotation.

    @Internal
    abstract MapProperty<String, Object> getBranchVersionIncrementer();

This clearly indicates to Gradle that this is something that is not part of the Task input. And it would be consistent with:

    @Internal
    abstract Property<VersionProperties.Incrementer> getVersionIncrementer()

in the same file.

I think @Optional can be left out, as it has no real effect on a Map/List (There is always an empty Map/List).

bgalek pushed a commit that referenced this issue May 22, 2023
* Test to reproduce #590

* @input replaced with @internal as discussed in #590

* gradle 7+ fix: property annotated with @internal should not be also annotated with @optional.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants