n0mer / gradle-git-properties

Gradle plugin for `git.properties` file generation
https://plugins.gradle.org/plugin/com.gorylenko.gradle-git-properties
Apache License 2.0
321 stars 54 forks source link

Error trying to set a custom resources dir using `gitPropertiesResourceDir` config #185

Open eriknyk opened 3 years ago

eriknyk commented 3 years ago

I just got and error trying to set a custom resources dir using gitPropertiesResourceDir config:

org.gradle.api.GradleScriptException: A problem occurred evaluating root project.

Caused by: java.lang.IllegalArgumentException: Cannot set the value of extension 'gitProperties' property 'gitPropertiesResourceDir' of type org.gradle.api.file.Directory using an instance of type org.codehaus.groovy.runtime.GStringImpl.

I'm using gradle 7

Regards.

sodevel commented 3 years ago

It is always very helpful to provide zero context but the plain error message, now everyone can pull out their crystal balls and guess what you did, try to reproduce and supply numerous solutions that all don't work because they guessed wrong...

The error message says you tried to assign a GString to a Directory, i would try to assign a Directory instead.

eriknyk commented 3 years ago

@sodevel Error trying to set a custom resources dir using gitPropertiesResourceDir config. Not sure what context do we need explain when setting a config value not working. Also I've mentioned that I'm using gradle 7.

I'm only trying what docs says:

image

And the error that it cause is the displayed above. So seems we need fix docs.

Pdta.

I've fixed it changing as following:

gitPropertiesResourceDir = file("${project.rootDir}/my-generated/resources-dir")
tha2015 commented 3 years ago

@eriknyk You are right, the doc is out of date and should be fixed. In a recent commit, type of gitPropertiesResourceDir has been changed but README was not updated

mhuebner commented 2 years ago

Docs should also be updated for setting dotGitDirectory property, i.e.:

dotGitDirectory = file("${project.rootProject.rootDir}/.git")
leo7 commented 2 years ago

Works well with just string like gitPropertiesResourceDir = "${project.rootDir}/src/main/resources" for Gradle 6.8, but need to use gitPropertiesResourceDir = file("${project.rootDir}/src/main/resources") for Gradle 7.x.

Same for dotGitDirectory

jackson-chris commented 1 year ago

For Kotlin DSL:

configure<com.gorylenko.GitPropertiesPluginExtension> {
    (gitPropertiesResourceDir as DirectoryProperty).set(file("${project.rootDir}/some/path"))
}