Should ProjectBuilder be executing init.d scripts

(Eric Isakson) #1

So, I’m following the advice in the manual about using an init script to setup repositories similar to what is described here:

but I also add a few things in the allprojects block for example:


and I’m packaging that up in a custom Gradle distribution similar to what is described here:

Where I end up with distributions like:

and then I write and maintain several custom plugins using the distribution.

Everything works great until I try to write tests for my plugins that need to check the project.enterpriseReposVersion or anything else my init script does using a project created by a ProjectBuilder. It seems the init script is not applied. That surprised me since it is in the distribution (i.e. this is not user specific setup). Okay, so I noticed in Gradle 3 withGradleUserHomeDir was added to the ProjectBuilder api so I setup a temporary dir, added init.d/enterprise-repos.gradle copied from the gradle distribution I’m running in and call withGradleUserHomeDir pointed at the temporary dir. Still didn’t affect the project created by ProjectBuilder.

Do I have an incorrect assumption that the init script would be applied to my build after explicitly setting that up?

My GradleRunner tests are working as expected but I have a lot of cases that I normally covered by lighter ProjectBuilder based tests and since implementing this, I’m jumping through a lot of hoops in unit tests trying to get something that doesn’t end in a:

groovy.lang.MissingPropertyException: Could not get unknown property ‘enterpriseReposVersion’ for root project ‘test’ of type org.gradle.api.Project.