gradle-git-properties icon indicating copy to clipboard operation
gradle-git-properties copied to clipboard

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

Open eriknyk opened this issue 2 years ago • 6 comments

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.

eriknyk avatar Aug 09 '21 20:08 eriknyk

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.

sodevel avatar Aug 11 '21 23:08 sodevel

@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")

eriknyk avatar Aug 12 '21 00:08 eriknyk

@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

tha2015 avatar Aug 12 '21 00:08 tha2015

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

dotGitDirectory = file("${project.rootProject.rootDir}/.git")

mhuebner avatar Mar 29 '22 10:03 mhuebner

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

leo7 avatar May 09 '22 01:05 leo7

For Kotlin DSL:

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

jackson-chris avatar May 05 '23 22:05 jackson-chris