This message was deleted.
# community-support
s
This message was deleted.
v
I guess you talk about the one in the gradle user home? Would be bad if it did by default as that would mean the test runs different depending on who runs it. The TestKit tests have separate gradle user home directories to be isolated and reproducible. If you want the ones from the executing user in there, it is probably easiest you copy them in.
c
isn’t this the point of init scripts though?
to make adjustments to gradle builds such that they execute correctly in that environment
v
Yes, but not to tests of a project. Tests should be written in a way they work everwhere self-contained, and run the same everywhere. A test should not behave different just because someone else is executing it.
c
in my case I have a CI machine that uses init scripts to setup Gradle to use a Nexus proxy… buildsystem tests now cannot resolve dependencies because they don’t execute the init script and try to use repositories directly.
v
Maybe somehow extend the init script to manipulate test tasks to inject init scripts or something like that?
Or maybe instead use a DNS redirect or iptables entry to redirect the calls to the real repository to the proxy?
Or directly use your proxy in the tests?
c
ended up with:
Copy code
systemProperty("gradle-init-scripts",   gradle.startParameter.allInitScripts.join(File.pathSeparator))
and then:
Copy code
private static GradleRunner gradleRunnerWithInitScripts(Path projectDir, String ... arguments) {
  return GradleRunner.create().withProjectDir(projectDir.toFile()).withPluginClasspath()
          .withArguments(concat(of(getProperty("gradle-init-scripts").split(File.pathSeparator))
                  .flatMap(initScript -> of("--init-script", initScript)), of(arguments)).collect(toList())
          );
}
a little ugly… but functional
👌 1