ajoberstar / reckon

Infer a project's version from your Git repository.
Apache License 2.0
187 stars 28 forks source link

Incompatibility with Jetbrains Changelog plugin #154

Closed JavierSegoviaCordoba closed 3 years ago

JavierSegoviaCordoba commented 3 years ago
Caused by: java.lang.IllegalArgumentException: Unable to determine constructor argument #3: value 0.1.0-SNAPSHOT not assignable to type String.

Is there any way to force reckon to use project.version as String?

ajoberstar commented 3 years ago

I don't believe there's anything I can do to fix that. Many Gradle plugins rely on using project.version for setting conventional values in other parts of the model.

Gradle exposed the version as an Object value, which is how reckon hooks in and delays resolution until the version property is used. Eagerly evaluating the version is a won't fix for me.

I don't know how the Jetbrains plugin works, but until Gradle changes how project.version works they should be calling toString on the version.

JavierSegoviaCordoba commented 3 years ago

Yeah, I checked the Changelog plugin and I did a PR changing the type from String to Any, hope they accept it.

As a local workaround I am using this:

import org.jetbrains.changelog.closure
import org.jetbrains.changelog.date

// Workaround to fix: https://github.com/JetBrains/gradle-changelog-plugin/issues/26
// When it is fixed, remove `projectVersion` variable and `project.version = ...` assignments
val projectVersion = project.version

project.version = "$projectVersion"

plugins {
    id("org.jetbrains.changelog")
}

project.version = projectVersion

changelog {
    version = "${project.version}"
    header = closure { "[$version] - ${date()}" }
    keepUnreleasedSection = true
    unreleasedTerm = "[Unreleased]"
    groups = listOf("Added", "Changed", "Deprecated", "Removed", "Fixed", "Updated")
}