researchgate / gradle-release

gradle-release is a plugin for providing a Maven-like release process for projects using Gradle
MIT License
859 stars 223 forks source link

Ignoring requireBranch is not possible #368

Closed daspilker closed 2 years ago

daspilker commented 2 years ago

Since upgrading to 3.0.0, setting requireBranch to empty string is not working.

This is my (Kotlin) configuration:

configure<ReleaseExtension> {
    failOnPublishNeeded.set(false)
    buildTasks.set(listOf<String>())
    with(git) {
        requireBranch.set("")
        pushToRemote.set("")
    }
}

This is the build output:

* What went wrong:
Execution failed for task ':evi-service-release:initScmAdapter'.
> Current Git branch is "master" and not "".
Hillkorn commented 2 years ago

you can set the property to null and should have the same behavior as before. I updated the README.md

daspilker commented 2 years ago

OK, thanks. Unfortunately requireBranch.set(null) causes an Overload resolution ambiguity.

Overload resolution ambiguity: 
public abstract fun set(p0: String?): Unit defined in org.gradle.api.provider.Property
public abstract fun set(p0: Provider<out String!>!): Unit defined in org.gradle.api.provider.Property

So it must be requireBranch.set(null as String?) in Kotlin 😕

Hillkorn commented 2 years ago

I see :confused: Do you know a way to improve it from the groovy side that you don't have to cast it like this?

daspilker commented 2 years ago

Sorry, I do not see a way to fix that, but I'm not an expert. I would allow empty string to ignore the required branch as before to avoid the cast or put the example with the cast in the README.